|
@@ -2,20 +2,24 @@ package tests;
|
|
|
|
|
|
import java.awt.Point;
|
|
|
import java.io.File;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.LinkedList;
|
|
|
|
|
|
import org.junit.Before;
|
|
|
import org.junit.Test;
|
|
|
+import java.lang.Error;
|
|
|
|
|
|
import com.sun.security.auth.UnixNumericGroupPrincipal;
|
|
|
|
|
|
import classes.Category;
|
|
|
import classes.CpsEdge;
|
|
|
+import classes.CpsNode;
|
|
|
import classes.CpsObject;
|
|
|
import classes.HolonElement;
|
|
|
import classes.HolonObject;
|
|
|
+import classes.HolonSwitch;
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
import static org.junit.Assert.assertFalse;
|
|
@@ -106,6 +110,10 @@ public class praktikumHolonsTestLoadAndStoreController {
|
|
|
&& model.getObjectsOnCanvas().get(i - 1).getObjName().equals("House"));
|
|
|
}
|
|
|
|
|
|
+ HolonSwitch sw = new HolonSwitch(mp.searchCatObj(mp.searchCat("Component"), "Switch"));
|
|
|
+ sw.setPosition(77, 88);
|
|
|
+ cvs.addNewObject(sw);
|
|
|
+
|
|
|
try {
|
|
|
File sav = new File(path + "TestSavBasic.json");
|
|
|
storeController.writeSaveFile(sav.getAbsolutePath());
|
|
@@ -146,6 +154,7 @@ public class praktikumHolonsTestLoadAndStoreController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
try {
|
|
|
File sav = new File(path + "TestSavAdvanced.json");
|
|
|
storeController.writeSaveFile(sav.getAbsolutePath());
|
|
@@ -207,9 +216,9 @@ public class praktikumHolonsTestLoadAndStoreController {
|
|
|
assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 0);
|
|
|
assertTrue("Canvas File was not found", new File(path + "TestCanvasBasic.json").exists());
|
|
|
loadController.readJSON(path + "TestCanvasBasic.json");
|
|
|
- assertTrue("NUmber of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 10);
|
|
|
+ assertTrue("NUmber of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 11);
|
|
|
for (CpsObject obj : model.getObjectsOnCanvas()) {
|
|
|
- assertTrue("Not instance of HolonObject", obj instanceof HolonObject);
|
|
|
+ assertTrue("Not instance of HolonObject", obj instanceof HolonObject || obj instanceof HolonSwitch);
|
|
|
}
|
|
|
|
|
|
assertTrue("NUmber of Categories not match", model.getCategories().size() == 3);
|
|
@@ -242,18 +251,24 @@ public class praktikumHolonsTestLoadAndStoreController {
|
|
|
assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 0);
|
|
|
assertTrue("Save File was not found", new File(path + "TestSavAdvanced.json").exists());
|
|
|
loadController.readJSON(path + "TestSavAdvanced.json");
|
|
|
- assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 100);
|
|
|
+ assertTrue("Objects on Canvas is not 100", model.getObjectsOnCanvas().size() == 100);
|
|
|
|
|
|
int n = model.getObjectsOnCanvas().size();
|
|
|
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);
|
|
|
-
|
|
|
+
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Test (expected=FileNotFoundException.class)
|
|
|
+ public void testLoadException() throws IOException {
|
|
|
+ assertTrue("Save File was not found", !new File(path + "TestSavDummy.json").exists());
|
|
|
+ loadController.readJSON(path + "TestSavDummy.json");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
*
|