1 package test.crispy.util; 2 3 import test.crispy.example.model.Adresse; 4 import test.crispy.example.model.Kunde; 5 import net.sf.crispy.util.Edge; 6 import net.sf.crispy.util.Graph; 7 import junit.framework.TestCase; 8 9 public class GraphTest extends TestCase { 10 11 12 public void testEdge() throws Exception { 13 Kunde lvKunde = new Kunde(); 14 Adresse lvAdresse = new Adresse(); 15 lvKunde.getAdressen().add(lvAdresse); 16 17 Edge lvEdge1 = new Edge(lvKunde, lvAdresse); 18 Edge lvEdge2 = new Edge(lvKunde, lvAdresse); 19 assertEquals(lvEdge1, lvEdge2); 20 21 Edge lvEdge3 = new Edge(lvAdresse, lvKunde); 22 assertFalse(lvEdge2.equals(lvEdge3)); 23 24 assertFalse(lvEdge2.equals(null)); 25 26 assertFalse(lvEdge2.equals(lvKunde)); 27 28 assertNotNull(lvEdge1.toString()); 29 assertNull(lvEdge1.getMethodName()); 30 31 lvEdge1.setMethodName("method"); 32 assertNotNull(lvEdge1.getMethodName()); 33 assertNotNull(lvEdge1.toString()); 34 35 lvEdge1 = new Edge(null, lvAdresse); 36 assertFalse(lvEdge2.equals(lvEdge1)); 37 38 lvEdge1 = new Edge(lvAdresse, null); 39 assertFalse(lvEdge2.equals(lvEdge1)); 40 } 41 42 public void testGraph() throws Exception { 43 Graph lvGraph = new Graph(); 44 45 Kunde lvKunde = new Kunde(); 46 Adresse lvAdresse = new Adresse(); 47 lvKunde.getAdressen().add(lvAdresse); 48 49 Edge lvEdge1 = new Edge(lvKunde, lvAdresse); 50 Edge lvEdge2 = new Edge(lvKunde, lvAdresse); 51 52 lvGraph.addVertex(lvKunde); 53 54 assertTrue(lvGraph.getVertexCount(lvKunde)); 55 assertFalse(lvGraph.getVertexCount(lvAdresse)); 56 57 lvGraph.put(lvEdge1, lvEdge1); 58 lvGraph.put(lvEdge2, lvEdge2); 59 60 assertNotNull(lvGraph.isFromContains(lvKunde)); 61 assertNull(lvGraph.isFromContains(lvAdresse)); 62 63 assertNull(lvGraph.isToContains(lvKunde)); 64 assertNotNull(lvGraph.isToContains(lvAdresse)); 65 } 66 67 public void testGraphWithNullEdge() throws Exception { 68 Graph lvGraph = new Graph(); 69 70 assertNull(lvGraph.isFromContains(null)); 71 assertNull(lvGraph.isToContains(null)); 72 assertNull(lvGraph.getProblemEdge(null)); 73 74 Kunde lvKunde = new Kunde(); 75 Adresse lvAdresse = new Adresse(); 76 lvKunde.getAdressen().add(lvAdresse); 77 78 Edge lvEdge1 = new Edge(lvKunde, lvAdresse); 79 lvGraph.put(lvEdge1, lvEdge1); 80 assertNull(lvGraph.getProblemEdge(lvEdge1)); 81 lvEdge1.setMethodName("method"); 82 assertNotNull(lvGraph.getProblemEdge(lvAdresse)); 83 } 84 85 }