|
@@ -169,7 +169,6 @@ public class PraktikumHolonsTestLoadAndStoreController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
try {
|
|
try {
|
|
File sav = new File(path + "TestSavAdvanced.json");
|
|
File sav = new File(path + "TestSavAdvanced.json");
|
|
storeController.writeSaveFile(sav.getAbsolutePath());
|
|
storeController.writeSaveFile(sav.getAbsolutePath());
|
|
@@ -188,27 +187,28 @@ public class PraktikumHolonsTestLoadAndStoreController {
|
|
@Test
|
|
@Test
|
|
public void testLoadMinimal() {
|
|
public void testLoadMinimal() {
|
|
try {
|
|
try {
|
|
- //Category Tests
|
|
|
|
|
|
+ // Category Tests
|
|
Category building = mp.searchCat("Building");
|
|
Category building = mp.searchCat("Building");
|
|
assertTrue("Number of Categories does not match", model.getCategories().size() == 3);
|
|
assertTrue("Number of Categories does not match", model.getCategories().size() == 3);
|
|
assertTrue("TestFile was not found", new File(path + "TestCategoryMinimal.json").exists());
|
|
assertTrue("TestFile was not found", new File(path + "TestCategoryMinimal.json").exists());
|
|
loadController.readJSON(path + "TestCategoryMinimal.json");
|
|
loadController.readJSON(path + "TestCategoryMinimal.json");
|
|
assertTrue("Number of Categories does not match", model.getCategories().size() == 3);
|
|
assertTrue("Number of Categories does not match", model.getCategories().size() == 3);
|
|
- //Tests if its same instance and if Name is the same
|
|
|
|
|
|
+ // Tests if its same instance and if Name is the same
|
|
assertTrue("Same instance of Category:Building", building != mp.searchCat("Building")
|
|
assertTrue("Same instance of Category:Building", building != mp.searchCat("Building")
|
|
&& building.getName().equals(mp.searchCat("Building").getName()));
|
|
&& building.getName().equals(mp.searchCat("Building").getName()));
|
|
-
|
|
|
|
- //Canvas Tests.. basically nothing happens because nothing is on the Canvas
|
|
|
|
|
|
+
|
|
|
|
+ // Canvas Tests.. basically nothing happens because nothing is on
|
|
|
|
+ // the Canvas
|
|
assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
|
|
assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
|
|
assertTrue("TestFile was not found", new File(path + "TestCanvasMinimal.json").exists());
|
|
assertTrue("TestFile was not found", new File(path + "TestCanvasMinimal.json").exists());
|
|
loadController.readJSON(path + "TestCanvasMinimal.json");
|
|
loadController.readJSON(path + "TestCanvasMinimal.json");
|
|
assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
|
|
assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
|
|
-
|
|
|
|
- //Save File tests basically both Test from Above Combined
|
|
|
|
|
|
+
|
|
|
|
+ // Save File tests basically both Test from Above Combined
|
|
building = mp.searchCat("Building");
|
|
building = mp.searchCat("Building");
|
|
assertTrue("Number of Objects in Energy does not Match", mp.searchCat("Energy").getObjects().size() == 1);
|
|
assertTrue("Number of Objects in Energy does not Match", mp.searchCat("Energy").getObjects().size() == 1);
|
|
assertTrue("TestFile was not found", new File(path + "TestSavMinimal.json").exists());
|
|
assertTrue("TestFile was not found", new File(path + "TestSavMinimal.json").exists());
|
|
- loadController.readJSON( path + "TestSavMinimal.json");
|
|
|
|
|
|
+ loadController.readJSON(path + "TestSavMinimal.json");
|
|
assertTrue("Number of Objects in Energy does not Match", mp.searchCat("Energy").getObjects().size() == 1);
|
|
assertTrue("Number of Objects in Energy does not Match", mp.searchCat("Energy").getObjects().size() == 1);
|
|
assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
|
|
assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
|
|
assertTrue("Same instance of Category:Building", building != mp.searchCat("Building")
|
|
assertTrue("Same instance of Category:Building", building != mp.searchCat("Building")
|
|
@@ -219,7 +219,7 @@ public class PraktikumHolonsTestLoadAndStoreController {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* basic tests for loading a save file.
|
|
* basic tests for loading a save file.
|
|
*/
|
|
*/
|
|
@@ -231,8 +231,7 @@ public class PraktikumHolonsTestLoadAndStoreController {
|
|
assertTrue("Non-Existant Category Exists", mp.searchCat("I") == null);
|
|
assertTrue("Non-Existant Category Exists", mp.searchCat("I") == null);
|
|
assertTrue("Non-Existant Category Exists", mp.searchCat("A") == null);
|
|
assertTrue("Non-Existant Category Exists", mp.searchCat("A") == null);
|
|
assertTrue("Non-Existant Category Exists", mp.searchCat("N") == null);
|
|
assertTrue("Non-Existant Category Exists", mp.searchCat("N") == null);
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
try {
|
|
try {
|
|
assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 0);
|
|
assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 0);
|
|
assertTrue("Canvas File was not found", new File(path + "TestCanvasBasic.json").exists());
|
|
assertTrue("Canvas File was not found", new File(path + "TestCanvasBasic.json").exists());
|
|
@@ -243,7 +242,7 @@ public class PraktikumHolonsTestLoadAndStoreController {
|
|
assertTrue("Not instance of HolonObject", obj instanceof HolonObject || obj instanceof HolonSwitch);
|
|
assertTrue("Not instance of HolonObject", obj instanceof HolonObject || obj instanceof HolonSwitch);
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
assertTrue("NUmber of Categories not match", model.getCategories().size() == 3);
|
|
assertTrue("NUmber of Categories not match", model.getCategories().size() == 3);
|
|
assertTrue("Canvas File was not found", new File(path + "TestSavBasic.json").exists());
|
|
assertTrue("Canvas File was not found", new File(path + "TestSavBasic.json").exists());
|
|
loadController.readJSON(path + "TestSavBasic.json");
|
|
loadController.readJSON(path + "TestSavBasic.json");
|
|
@@ -260,37 +259,40 @@ public class PraktikumHolonsTestLoadAndStoreController {
|
|
assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "D") != null);
|
|
assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "D") != null);
|
|
assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "E") != null);
|
|
assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "E") != null);
|
|
assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "F") != null);
|
|
assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "F") != null);
|
|
-
|
|
|
|
|
|
+
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* advanced tests for loading a save file.
|
|
* advanced tests for loading a save file.
|
|
*/
|
|
*/
|
|
@Test
|
|
@Test
|
|
public void testLoadAdvanced() {
|
|
public void testLoadAdvanced() {
|
|
-
|
|
|
|
|
|
+
|
|
try {
|
|
try {
|
|
assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 0);
|
|
assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 0);
|
|
assertTrue("Save File was not found", new File(path + "TestSavAdvanced.json").exists());
|
|
assertTrue("Save File was not found", new File(path + "TestSavAdvanced.json").exists());
|
|
loadController.readJSON(path + "TestSavAdvanced.json");
|
|
loadController.readJSON(path + "TestSavAdvanced.json");
|
|
assertTrue("Objects on Canvas is not 100", model.getObjectsOnCanvas().size() == 100);
|
|
assertTrue("Objects on Canvas is not 100", model.getObjectsOnCanvas().size() == 100);
|
|
-
|
|
|
|
|
|
+
|
|
int n = model.getObjectsOnCanvas().size();
|
|
int n = model.getObjectsOnCanvas().size();
|
|
assertTrue("Number of Edges does not Match", model.getEdgesOnCanvas().size() == (n * (n - 1)) / 2);
|
|
assertTrue("Number of Edges does not Match", model.getEdgesOnCanvas().size() == (n * (n - 1)) / 2);
|
|
- assertTrue("Element has no UnitGraph", !mp.searchEle((HolonObject)model.getObjectsOnCanvas().get(77), "Fridge").getGraphPoints().isEmpty());
|
|
|
|
- assertTrue("Points in UnitGraph does not Match", mp.searchEle((HolonObject)model.getObjectsOnCanvas().get(77), "Fridge").getGraphPoints().size() == 3);
|
|
|
|
-
|
|
|
|
|
|
+ assertTrue("Element has no UnitGraph", !mp
|
|
|
|
+ .searchEle((HolonObject) model.getObjectsOnCanvas().get(77), "Fridge").getGraphPoints().isEmpty());
|
|
|
|
+ assertTrue("Points in UnitGraph does not Match",
|
|
|
|
+ mp.searchEle((HolonObject) model.getObjectsOnCanvas().get(77), "Fridge").getGraphPoints()
|
|
|
|
+ .size() == 3);
|
|
|
|
+
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- @Test (expected=FileNotFoundException.class)
|
|
|
|
|
|
+
|
|
|
|
+ @Test(expected = FileNotFoundException.class)
|
|
public void testLoadException() throws IOException {
|
|
public void testLoadException() throws IOException {
|
|
assertTrue("Save File was not found", !new File(path + "TestSavDummy.json").exists());
|
|
assertTrue("Save File was not found", !new File(path + "TestSavDummy.json").exists());
|
|
loadController.readJSON(path + "TestSavDummy.json");
|
|
loadController.readJSON(path + "TestSavDummy.json");
|
|
@@ -299,7 +301,8 @@ public class PraktikumHolonsTestLoadAndStoreController {
|
|
/**
|
|
/**
|
|
* sets the graph points in all elements of an Object.
|
|
* sets the graph points in all elements of an Object.
|
|
*
|
|
*
|
|
- * @param obj the Object
|
|
|
|
|
|
+ * @param obj
|
|
|
|
+ * the Object
|
|
*/
|
|
*/
|
|
public void setGraphPoints(HolonObject obj) {
|
|
public void setGraphPoints(HolonObject obj) {
|
|
LinkedList<Point> list = new LinkedList<>();
|
|
LinkedList<Point> list = new LinkedList<>();
|