|
@@ -7,7 +7,9 @@ import static org.junit.Assert.assertTrue;
|
|
import org.junit.Before;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
+import classes.CpsObject;
|
|
import classes.HolonObject;
|
|
import classes.HolonObject;
|
|
|
|
+import ui.controller.CanvasController;
|
|
import ui.controller.CategoryController;
|
|
import ui.controller.CategoryController;
|
|
import ui.controller.MultiPurposeController;
|
|
import ui.controller.MultiPurposeController;
|
|
import ui.controller.ObjectController;
|
|
import ui.controller.ObjectController;
|
|
@@ -19,6 +21,7 @@ public class praktikumHolonsTestObjectController {
|
|
protected Model model;
|
|
protected Model model;
|
|
protected MultiPurposeController mp;
|
|
protected MultiPurposeController mp;
|
|
protected CategoryController cg;
|
|
protected CategoryController cg;
|
|
|
|
+ protected CanvasController cvs;
|
|
protected ObjectController controller;
|
|
protected ObjectController controller;
|
|
|
|
|
|
@Before
|
|
@Before
|
|
@@ -27,6 +30,7 @@ public class praktikumHolonsTestObjectController {
|
|
model = new Model();
|
|
model = new Model();
|
|
mp = new MultiPurposeController(model);
|
|
mp = new MultiPurposeController(model);
|
|
cg = new CategoryController(model, mp);
|
|
cg = new CategoryController(model, mp);
|
|
|
|
+ cvs = new CanvasController(model, mp);
|
|
controller = new ObjectController(model, mp);
|
|
controller = new ObjectController(model, mp);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -46,17 +50,19 @@ public class praktikumHolonsTestObjectController {
|
|
assertTrue("Non-Existant Element is Found",
|
|
assertTrue("Non-Existant Element is Found",
|
|
mp.searchEle((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"), "") == null);
|
|
mp.searchEle((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"), "") == null);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Test
|
|
@Test
|
|
public void testAddingAndDeletingInCategory() {
|
|
public void testAddingAndDeletingInCategory() {
|
|
controller.addNewElementIntoCategoryObject("Building", "House", "A", 1, -10);
|
|
controller.addNewElementIntoCategoryObject("Building", "House", "A", 1, -10);
|
|
for (int i = 2; i < 27; i++) {
|
|
for (int i = 2; i < 27; i++) {
|
|
controller.addNewElementIntoCategoryObject("Building", "House", adapter.generate(i), i, -10);
|
|
controller.addNewElementIntoCategoryObject("Building", "House", adapter.generate(i), i, -10);
|
|
- // n(n+1) / 2
|
|
|
|
- assertTrue("Total Energy does not match",((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House")).getCurrentEnergy() == -1800 + ((i* (i+1)) / 2) * -10);
|
|
|
|
- assertTrue("Number of Elements does not Match", ((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House")).getElements().size() == 6+i);
|
|
|
|
|
|
+ // n(n+1) / 2
|
|
|
|
+ assertTrue("Total Energy does not match", ((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"))
|
|
|
|
+ .getCurrentEnergy() == -1800 + ((i * (i + 1)) / 2) * -10);
|
|
|
|
+ assertTrue("Number of Elements does not Match",
|
|
|
|
+ ((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House")).getElements().size() == 6 + i);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
controller.deleteElementInCategory("Building", "House", "B");
|
|
controller.deleteElementInCategory("Building", "House", "B");
|
|
controller.deleteElementInCategory("Building", "House", "D");
|
|
controller.deleteElementInCategory("Building", "House", "D");
|
|
controller.deleteElementInCategory("Building", "House", "F");
|
|
controller.deleteElementInCategory("Building", "House", "F");
|
|
@@ -65,19 +71,50 @@ public class praktikumHolonsTestObjectController {
|
|
controller.deleteElementInCategory("Building", "House", "I");
|
|
controller.deleteElementInCategory("Building", "House", "I");
|
|
controller.deleteElementInCategory("Building", "House", "Z");
|
|
controller.deleteElementInCategory("Building", "House", "Z");
|
|
controller.deleteElementInCategory("Building", "House", "TV");
|
|
controller.deleteElementInCategory("Building", "House", "TV");
|
|
- assertTrue("Element:B was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "B") == null);
|
|
|
|
- assertTrue("Element:D was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "D") == null);
|
|
|
|
- assertTrue("Element:F was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "F") == null);
|
|
|
|
- assertTrue("Element:G was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "G") == null);
|
|
|
|
- assertTrue("Element:H was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "H") == null);
|
|
|
|
- assertTrue("Element:I was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "I") == null);
|
|
|
|
- assertTrue("Element:Z was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "Z") == null);
|
|
|
|
- assertTrue("Element:TV was not Found", mp.searchEle((HolonObject)mp.searchCatObj(mp.searchCat("Building"), "House"), "TV") == null);
|
|
|
|
|
|
+ assertTrue("Element:B was Found",
|
|
|
|
+ mp.searchEle((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"), "B") == null);
|
|
|
|
+ assertTrue("Element:D was Found",
|
|
|
|
+ mp.searchEle((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"), "D") == null);
|
|
|
|
+ assertTrue("Element:F was Found",
|
|
|
|
+ mp.searchEle((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"), "F") == null);
|
|
|
|
+ assertTrue("Element:G was Found",
|
|
|
|
+ mp.searchEle((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"), "G") == null);
|
|
|
|
+ assertTrue("Element:H was Found",
|
|
|
|
+ mp.searchEle((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"), "H") == null);
|
|
|
|
+ assertTrue("Element:I was Found",
|
|
|
|
+ mp.searchEle((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"), "I") == null);
|
|
|
|
+ assertTrue("Element:Z was Found",
|
|
|
|
+ mp.searchEle((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"), "Z") == null);
|
|
|
|
+ assertTrue("Element:TV was Found",
|
|
|
|
+ mp.searchEle((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"), "TV") == null);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@Test
|
|
@Test
|
|
public void testAddingAndDeletingInCanvas() {
|
|
public void testAddingAndDeletingInCanvas() {
|
|
-
|
|
|
|
|
|
+ for (int i = 0; i < 100; i++) {
|
|
|
|
+ cvs.addNewObject(new HolonObject(mp.searchCatObj(mp.searchCat("Building"), "House")));
|
|
|
|
+ }
|
|
|
|
+ for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
|
|
+ for (int i = 0; i < 27; i++) {
|
|
|
|
+ controller.addNewElementIntoCanvasObject(cps.getID(), adapter.generate(i), 1, -100);
|
|
|
|
+ assertTrue("Element:" + adapter.generate(i) + " was not Created", mp
|
|
|
|
+ .searchEle((HolonObject) mp.searchByID(cps.getID()), adapter.generate(i)) != null);
|
|
|
|
+ }
|
|
|
|
+ assertTrue("Element:B was not Found", mp
|
|
|
|
+ .searchEle((HolonObject) mp.searchByID(cps.getID()), "B") != null);
|
|
|
|
+ assertTrue("Element:D was not Found", mp
|
|
|
|
+ .searchEle((HolonObject) mp.searchByID(cps.getID()), "D") != null);
|
|
|
|
+ assertTrue("Element:F was not Found", mp
|
|
|
|
+ .searchEle((HolonObject) mp.searchByID(cps.getID()), "F") != null);
|
|
|
|
+ assertTrue("Element:G was not Found", mp
|
|
|
|
+ .searchEle((HolonObject) mp.searchByID(cps.getID()), "G") != null);
|
|
|
|
+ assertTrue("Element:H was not Found", mp
|
|
|
|
+ .searchEle((HolonObject) mp.searchByID(cps.getID()), "H") != null);
|
|
|
|
+ assertTrue("Element:I was not Found", mp
|
|
|
|
+ .searchEle((HolonObject) mp.searchByID(cps.getID()), "I") != null);
|
|
|
|
+ assertTrue("Element:B was not Found", mp
|
|
|
|
+ .searchEle((HolonObject) mp.searchByID(cps.getID()), "B") != null);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|