Teh-Hai Julian Zheng před 7 roky
rodič
revize
3cf2f5c614

+ 0 - 6
.project

@@ -10,14 +10,8 @@
 			<arguments>
 			</arguments>
 		</buildCommand>
-		<buildCommand>
-			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
 	</buildSpec>
 	<natures>
 		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
 	</natures>
 </projectDescription>

+ 66 - 7
src/tests/praktikumHolonsTestClasses.java

@@ -3,6 +3,7 @@ package tests;
 import classes.*;
 import static org.junit.Assert.assertTrue;
 
+import java.awt.Color;
 import java.util.ArrayList;
 
 import org.junit.Before;
@@ -17,7 +18,6 @@ public class praktikumHolonsTestClasses {
 		HolonObject obj1 = new HolonObject("Test Object");
 		ArrayList<AbstractCpsObject> arr = new ArrayList<>();
 
-		
 		assertTrue("Name not correct", test1.getName().equals("Test1"));
 		assertTrue("Name not correct", test2.getName().equals("Test2"));
 		assertTrue("Name should not be the same", !test1.getName().equals(test2.getName()));
@@ -34,17 +34,17 @@ public class praktikumHolonsTestClasses {
 		arr = test2.getObjects();
 		assertTrue("Shoud not be empty", !arr.isEmpty());
 	}
-	
+
 	@Test
 	public void testHolonObject() {
-		
+
 		HolonObject test1 = new HolonObject("Test1");
 		HolonObject test2 = new HolonObject("Test2");
 		HolonObject test3 = new HolonObject(test1);
 		HolonElement ele = new HolonElement("Element", 1, 10);
-		
+
 		ArrayList<HolonElement> arr = new ArrayList<>();
-		
+
 		assertTrue("Should be Empty", test1.getElements().isEmpty());
 		test1.setElements(arr);
 		assertTrue("Should be Empty", test1.getElements().isEmpty());
@@ -59,15 +59,74 @@ public class praktikumHolonsTestClasses {
 		String str = test2.toStringElements();
 		assertTrue("String not corrent", str.equals("Element, Element"));
 		test2.deleteElement(0);
-		assertTrue("Current Energy not corrent", test2.getCurrentEnergy() == 10);
-		
+		test2.addElements(ele);
+		assertTrue("Current Energy not corrent", test2.getCurrentEnergy() == 20);
+
 		assertTrue("Should be Empty", test3.getElements().isEmpty());
 		test3.setElements(test2.copyElements(test2.getElements()));
 		assertTrue("Should be Empty", !test3.getElements().isEmpty());
 		assertTrue("Should be state 0", test3.getState() == 0);
 		test3.setState(1);
+		assertTrue("Should be state 1", test3.getState() == 1);
+		test3.setState(2);
+		assertTrue("Should be state 2", test3.getState() == 2);
+		test3.setState(3);
+		assertTrue("Should be state 3", test3.getState() == 3);
+		test3.setState(4);
+		assertTrue("Should be state 4", test3.getState() == 4);
+		assertTrue("Element not Found", test3.searchElement("Element") != null);
+		test1.setElements(new ArrayList<>());
+		assertTrue("Not Empty", !test1.checkIfPartiallySupplied(1));
+		test3.addElements(new HolonElement("Element2", 1, -10));
+
+		assertTrue("Not Partially Supplied", test3.checkIfPartiallySupplied(1));
+		test3.addElements(new HolonElement("Element2", 2, -10));
+		assertTrue("Not Partially Supplied", test3.checkIfPartiallySupplied(1));
+		test1.addElements(new HolonElement("Element2", 2, -10));
+		assertTrue("minSupply < 0", !test1.checkIfPartiallySupplied(1));
+		Color color = test3.getColor();
+		test3.setColor(new Color(0, 255, 255));
+		assertTrue(color.getBlue() != test3.getColor().getBlue());
+	}
+
+	@Test
+	public void testHolonSwitch() {
+		HolonSwitch test1 = new HolonSwitch("Test1");
+		HolonSwitch test2 = new HolonSwitch(test1);
 		
+		assertTrue("Manuel Mode is on", !test2.getManualMode());
+		test2.switchState();
+		assertTrue(test2.getState());
+		assertTrue(test2.getState(1));
+		test2.setManualMode(true);
+		test2.switchState();
+		test2.switchState();
+		assertTrue(test2.getState());
+		assertTrue(test2.getState(1));
+		assertTrue("Manuel Mode is off", test2.getManualMode());
+		assertTrue("ManuelActive is off", test2.getActiveManual());
+		test2.switchState();
+		assertTrue("ManuelActive is on", !test2.getActiveManual());
+		test2.switchState();
+		assertTrue("ManuelActive is off", test2.getActiveManual());
+		assertTrue(test1.getGraphPoints() != test2.getGraphPoints());
+		test2.setGraphPoints(test1.getGraphPoints());
+		assertTrue(test1.getGraphPoints() == test2.getGraphPoints());
 	}
 	
+	@Test
+	public void testCpsEdge() {
+		CpsNode node1 = new CpsNode("Node1");
+		CpsNode node2 = new CpsNode("Node2");
+		CpsNode node3 = new CpsNode("Node3");
+		CpsEdge edge1 = new CpsEdge(node1, node2, 100);
+		CpsEdge edge2 = new CpsEdge(node2, node3);
+		
+	}
 	
+	@Test
+	public void testHolonElement() {
+		
+	}
+
 }

+ 2 - 2
src/tests/praktikumHolonsTestLoadAndStoreController.java

@@ -238,9 +238,9 @@ public class praktikumHolonsTestLoadAndStoreController {
 			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 (AbstractCpsObject obj : model.getObjectsOnCanvas()) {
-				assertTrue("Not instance of HolonObject", obj instanceof HolonObject);
+				assertTrue("Not instance of HolonObject", obj instanceof HolonObject || obj instanceof HolonSwitch);
 
 			}