Fix dependency issue on older version of Tinkerpop
[aai/gizmo.git] / src / test / java / org / openecomp / crud / dao / champ / ChampDaoTest.java
1 package org.openecomp.crud.dao.champ;
2
3 import org.junit.After;
4 import org.junit.Before;
5 import org.junit.Ignore;
6 import org.junit.Test;
7 import org.openecomp.aai.champ.graph.impl.InMemoryChampGraphImpl;
8 import org.openecomp.crud.dao.GraphDao;
9 import org.openecomp.crud.entity.Edge;
10 import org.openecomp.crud.entity.Vertex;
11 import org.openecomp.crud.exception.CrudException;
12
13 import java.util.HashMap;
14 import java.util.List;
15 import java.util.Map;
16
17 import static org.junit.Assert.*;
18
19
20 /**
21  * This suite of tests validates the basic functionality of the {@link ChampDao}.
22  */
23 public class ChampDaoTest {
24
25   private static final String GRAPH_NAME = "my_test_graph";
26
27   private GraphDao champDao = null;
28
29
30   /**
31    * Perform setup steps that must be done prior to executing each test.
32    */
33   @Before
34   public void setup() {
35
36     // Create an instance of the Champ DAO, backed by the Champ library's in-memory back end
37     // for testing purposes.
38           Map<String, Object> champDaoProperties = new HashMap<String, Object>();
39     champDaoProperties.put(ChampDao.CONFIG_STORAGE_BACKEND, "in-memory");
40     champDaoProperties.put(ChampDao.CONFIG_GRAPH_NAME, GRAPH_NAME);
41     champDao = new ChampDao(new InMemoryChampGraphImpl.Builder().properties(champDaoProperties).build());
42   }
43
44
45   /**
46    * Perform tear down steps that must be done after executing each test.
47    */
48   @After
49   public void tearDown() {
50
51     // Release the Champ DAO instance that we were using for the test.
52     if (champDao != null) {
53       ((ChampDao) champDao).close();
54     }
55   }
56
57
58   /**
59    * Tests the ability of the {@link ChampDao} to create a vertex.
60    *
61    * @throws CrudException
62    */
63   @Test
64   public void createVertexTest() throws CrudException {
65
66     String VERTEX_TYPE = "Test_Vertex";
67
68     Map<String, Object> properties = new HashMap<String, Object>();
69     properties.put("property1", "something");
70     properties.put("property2", "something else");
71
72     // Create the vertex.
73     Vertex createdVertex = champDao.addVertex(VERTEX_TYPE, properties);
74
75     // Validate that the returned {@link Vertex} has the right label assigned to it.
76     assertTrue("Unexpected vertex type '" + createdVertex.getType() + "' returned from DAO",
77         createdVertex.getType().equals(VERTEX_TYPE));
78
79     // Validate that all of the properties that we provided to the DAO are in fact assigned
80     // to the {@link Vertex} that we got back.
81     assertTrue("Vertex property list returned from DAO did not contain all expected properties - expected: " +
82             properties.keySet() + " actual: " + createdVertex.getProperties().keySet(),
83         createdVertex.getProperties().keySet().containsAll(properties.keySet()));
84
85     // Validate that the values assigned to the properties in the returned {@link Vertex}
86     // match the ones that we provided.
87     for (String propertyKey : properties.keySet()) {
88
89       assertTrue(createdVertex.getProperties().get(propertyKey).equals(properties.get(propertyKey)));
90     }
91   }
92
93
94   /**
95    * Tests the ability of the {@link ChampDao} to retrieve a vertex from the graph data store
96    * by its unique identifier.
97    *
98    * @throws CrudException
99    */
100   @Test
101   public void getVertexByIdTest() throws CrudException {
102
103     String VERTEX_TYPE = "Test_Vertex";
104
105     Map<String, Object> properties = new HashMap<String, Object>();
106     properties.put("property1", "something");
107     properties.put("property2", "something else");
108
109     // Create the vertex.
110     Vertex createdVertex = champDao.addVertex(VERTEX_TYPE, properties);
111
112     // Make sure the {@link Vertex} returned from the create method includes an id that we can
113     // use to retrieve it.
114     assertTrue("No valid id returned for the created vertex", createdVertex.getId().isPresent());
115
116     // Now, retrieve the {@link Vertex} by its identifier.
117     Vertex retrievedVertex = champDao.getVertex(createdVertex.getId().get(), VERTEX_TYPE);
118
119     // Validate that the retrieved {@link Vertex} has the right label assigned to it.
120     assertTrue("Unexpected vertex type '" + retrievedVertex.getType() + "' returned from DAO",
121         retrievedVertex.getType().equals(VERTEX_TYPE));
122
123     // Validate that all of the properties that we provided when we created the {@link Vertex}
124     // are present in the {@link Vertex} that we retrieved.
125     assertTrue("Vertex property list returned from DAO did not contain all expected properties - expected: " +
126             properties.keySet() + " actual: " + retrievedVertex.getProperties().keySet(),
127         retrievedVertex.getProperties().keySet().containsAll(properties.keySet()));
128
129     // Validate that the values assigned to the properties in the retrieved {@link Vertex}
130     // match the ones that we provided when we created it.
131     for (String propertyKey : properties.keySet()) {
132
133       assertTrue(retrievedVertex.getProperties().get(propertyKey).equals(properties.get(propertyKey)));
134     }
135   }
136
137
138   /**
139    * Tests the ability of the {@link ChampDao} to update an already existing vertex.
140    *
141    * @throws CrudException
142    */
143   @Test
144   public void updateVertexTest() throws CrudException {
145
146     final String VERTEX_TYPE = "Test_Vertex";
147
148     Map<String, Object> properties = new HashMap<String, Object>();
149     properties.put("property1", "something");
150     properties.put("property2", "something else");
151
152     // Create the vertex.
153     Vertex createdVertex = champDao.addVertex(VERTEX_TYPE, properties);
154
155     // Make sure the {@link Vertex} returned from the create method includes an id that we can
156     // use to retrieve it.
157     assertTrue("No valid id returned for the created vertex", createdVertex.getId().isPresent());
158
159     // Modify the properties list...
160     properties.put("property3", "a new property");
161     properties.remove("property1");
162
163     // ...and apply it to our vertex.
164     Vertex updatedVertex = champDao.updateVertex(createdVertex.getId().get(), createdVertex.getType(), properties);
165
166     assertTrue("Vertex property list returned from DAO update operation did not contain all expected properties - expected: " +
167             properties.keySet() + " actual: " + updatedVertex.getProperties().keySet(),
168         updatedVertex.getProperties().keySet().containsAll(properties.keySet()));
169
170     // Validate that the values assigned to the properties in the updated {@link Vertex}
171     // match the ones that we provided when we created it.
172     for (String propertyKey : properties.keySet()) {
173
174       assertTrue("Unexpected value for property '" + propertyKey + "' - Expected: " +
175               properties.get(propertyKey) + "  Actual: " +
176               updatedVertex.getProperties().get(propertyKey),
177           updatedVertex.getProperties().get(propertyKey).equals(properties.get(propertyKey)));
178     }
179
180     // Validate that the property that we removed is NOT in the set of properties from our
181     // updated {@link Vertex}.
182     assertFalse("Property 'property1' should no longer be associated with updated vertex",
183         updatedVertex.getProperties().containsKey("property1"));
184   }
185
186
187   /**
188    * Tests the ability of the {@link ChampDao} to retrieve multiple vertices which match
189    * a particular set of supplied properties.
190    *
191    * @throws CrudException
192    */
193   @Test
194   public void getVerticesTest() throws CrudException {
195
196     final String FIRST_VERTEX_TYPE = "pserver";
197     final String SECOND_VERTEX_TYPE = "complex";
198
199     // Create some vertices.
200
201     Map<String, Object> vertex1Properties = new HashMap<String, Object>();
202     vertex1Properties.put("O/S", "Linux");
203     vertex1Properties.put("version", "6.5");
204     vertex1Properties.put("hostname", "kll0001");
205     champDao.addVertex(FIRST_VERTEX_TYPE, vertex1Properties);
206
207     Map<String, Object> vertex2Properties = new HashMap<String, Object>();
208     vertex2Properties.put("O/S", "Linux");
209     vertex2Properties.put("version", "6.5");
210     vertex2Properties.put("hostname", "kll0002");
211     champDao.addVertex(FIRST_VERTEX_TYPE, vertex2Properties);
212
213     Map<String, Object> vertex3Properties = new HashMap<String, Object>();
214     vertex3Properties.put("O/S", "Linux");
215     vertex3Properties.put("version", "7.2");
216     vertex3Properties.put("hostname", "kll0003");
217     champDao.addVertex(FIRST_VERTEX_TYPE, vertex3Properties);
218
219     Map<String, Object> vertex4Properties = new HashMap<String, Object>();
220     vertex4Properties.put("O/S", "Windows");
221     vertex4Properties.put("version", "10");
222     vertex4Properties.put("hostname", "Dev Laptop");
223     champDao.addVertex(FIRST_VERTEX_TYPE, vertex4Properties);
224
225     Map<String, Object> vertex5Properties = new HashMap<String, Object>();
226     vertex5Properties.put("Street", "Baker");
227     vertex5Properties.put("Number", "222B");
228     champDao.addVertex(SECOND_VERTEX_TYPE, vertex5Properties);
229
230     // Create a set of properties to use for our query.
231     Map<String, Object> queryProperties = new HashMap<String, Object>();
232     queryProperties.put("O/S", "Linux");
233     queryProperties.put("version", "6.5");
234
235     // Validate that we filter our 'get vertices' results by type
236     List<Vertex> allVerticesByType = champDao.getVertices(FIRST_VERTEX_TYPE, MapBuilder.builder().build());
237     for (Vertex v : allVerticesByType) {
238       assertTrue("Unexpected vertex type returned from query.  Expected: " +
239               FIRST_VERTEX_TYPE + " Actual: " + v.getType(),
240           v.getType().equals(FIRST_VERTEX_TYPE));
241     }
242
243     // Now, request the vertices that match our parameters.
244     List<Vertex> vertices = champDao.getVertices(FIRST_VERTEX_TYPE, queryProperties);
245
246     // Validate that got back the expected number of vertices.
247     assertEquals(vertices.size(), 2);
248
249     // Validate that the vertices we got back contain the expected parameters.
250     for (Vertex v : vertices) {
251
252       assertTrue("Vertex from query result does not contain expected vertex 'O/S'",
253           v.getProperties().containsKey("O/S"));
254       assertTrue("Vertex from query result contains unexpected value for 'O/S' parameter - Expected: 'Linux'  Actual: '" +
255               v.getProperties().get("O/S") + "'",
256           v.getProperties().get("O/S").equals("Linux"));
257
258       assertTrue("Vertex from query result does not contain expected vertex 'O/S'",
259           v.getProperties().containsKey("version"));
260       assertTrue("Vertex from query result contains unexpected value for 'O/S' parameter - Expected: 'Linux'  Actual: '" +
261               v.getProperties().get("O/S") + "'",
262           v.getProperties().get("version").equals("6.5"));
263     }
264   }
265
266   @Test
267   public void deleteVertexTest() throws CrudException {
268
269     boolean deletedVertexNotFound = false;
270
271     // Create a vertex.
272     Vertex createdVertex = champDao.addVertex("test_type", MapBuilder.builder()
273         .withKeyValue("O/S", "Linux")
274         .withKeyValue("version", "6.5")
275         .withKeyValue("hostname", "kll0001")
276         .build());
277
278     // Verify that we can retrieve the vertex from the graph data base.
279     Vertex retrievedVertex = champDao.getVertex(createdVertex.getId().get(), "test_type");
280
281     // Now, delete the vertex.
282     champDao.deleteVertex(createdVertex.getId().get(), "test_type");
283
284     // Now, try to retrieve it again.  This time we should fail to find it.
285     try {
286       champDao.getVertex(createdVertex.getId().get(), "test_type");
287
288     } catch (CrudException e) {
289       assertTrue(e.getMessage().contains("No vertex with id"));
290       deletedVertexNotFound = true;
291     }
292
293     assertTrue("Should not have been able to retrieve deleted vertex", deletedVertexNotFound);
294   }
295
296   @Test
297   public void createEdgeTest() throws CrudException {
298
299     String EDGE_TYPE = "has";
300
301     // Create the source vertex for the edge.
302     Map<String, Object> srcVertexProperties = new HashMap<String, Object>();
303     srcVertexProperties.put("O/S", "Linux");
304     srcVertexProperties.put("version", "6.5");
305     srcVertexProperties.put("hostname", "kll0001");
306     Vertex sourceVertex = champDao.addVertex("vserver", srcVertexProperties);
307
308     // Create the target vertex for the edge.
309     Map<String, Object> dstVertexProperties = new HashMap<String, Object>();
310     dstVertexProperties.put("O/S", "Linux");
311     dstVertexProperties.put("version", "6.5");
312     dstVertexProperties.put("hostname", "kll0002");
313     Vertex destVertex = champDao.addVertex("VNF", dstVertexProperties);
314
315     // Now, create the edge itself.
316     Map<String, Object> edgeProperties = new HashMap<String, Object>();
317     edgeProperties.put("prop", "val");
318     Edge createdEdge = champDao.addEdge("has", sourceVertex, destVertex, edgeProperties);
319
320     // Validate that the Edge object returned from the create method matches what we were
321     // trying to create.
322     assertTrue("Unexpected type for Edge returned from create method.  Expected: " + EDGE_TYPE
323             + " Actual: " + createdEdge.getType(),
324         createdEdge.getType().equals("has"));
325     assertTrue("Unexpected properties for Edge returned from create method.  Expected: " + edgeProperties
326             + " Actual: " + createdEdge.getProperties(),
327         createdEdge.getProperties().equals(edgeProperties));
328
329   }
330
331   @Test
332   public void createEdgeWithMissingSrcOrTargetTest() throws CrudException {
333
334     String EDGE_TYPE = "has";
335
336     // Create the source vertex for the edge.
337     Map<String, Object> srcVertexProperties = new HashMap<String, Object>();
338     srcVertexProperties.put("O/S", "Linux");
339     srcVertexProperties.put("version", "6.5");
340     srcVertexProperties.put("hostname", "kll0001");
341     Vertex sourceVertex = champDao.addVertex("vserver", srcVertexProperties);
342
343     // Create the target vertex for the edge.
344     Map<String, Object> dstVertexProperties = new HashMap<String, Object>();
345     dstVertexProperties.put("O/S", "Linux");
346     dstVertexProperties.put("version", "6.5");
347     dstVertexProperties.put("hostname", "kll0002");
348     Vertex destVertex = champDao.addVertex("VNF", dstVertexProperties);
349
350     // Now, try creating the Edge but specify an id for the source vertex that does
351     // not exist.
352     Map<String, Object> edgeProperties = new HashMap<String, Object>();
353     edgeProperties.put("prop", "val");
354     try {
355       champDao.addEdge(EDGE_TYPE, new Vertex.Builder("miss").id("99").build(), destVertex, edgeProperties);
356     } catch (CrudException e) {
357       assertTrue(e.getMessage().contains("Error creating edge - source vertex"));
358     }
359
360     // Now, try created the Edge with a valid source vertex, but specify an id for the
361     // target vertex that does not exist.
362     try {
363       champDao.addEdge(EDGE_TYPE, sourceVertex, new Vertex.Builder("miss").id("99").build(), edgeProperties);
364     } catch (CrudException e) {
365       assertTrue(e.getMessage().contains("Error creating edge - target vertex"));
366     }
367
368   }
369
370   @Test
371   public void getEdgeByIdTest() throws CrudException {
372
373     String EDGE_TYPE = "has";
374
375     // Create the source vertex for the edge.
376     Map<String, Object> srcVertexProperties = new HashMap<String, Object>();
377     srcVertexProperties.put("O/S", "Linux");
378     srcVertexProperties.put("version", "6.5");
379     srcVertexProperties.put("hostname", "kll0001");
380     Vertex sourceVertex = champDao.addVertex("vserver", srcVertexProperties);
381
382     // Create the target vertex for the edge.
383     Map<String, Object> dstVertexProperties = new HashMap<String, Object>();
384     dstVertexProperties.put("O/S", "Linux");
385     dstVertexProperties.put("version", "6.5");
386     dstVertexProperties.put("hostname", "kll0002");
387     Vertex destVertex = champDao.addVertex("VNF", dstVertexProperties);
388
389     // Now, create the edge itself.
390     Map<String, Object> edgeProperties = new HashMap<String, Object>();
391     edgeProperties.put("prop", "val");
392     Edge createdEdge = champDao.addEdge("has", sourceVertex, destVertex, edgeProperties);
393
394     // Retrieve the edge we just created by specifying its unique identifier.
395     Edge retrievedEdge = champDao.getEdge(createdEdge.getId().get(), "has");
396
397     // Validate that the contents of the object that we got back matches what we thought we
398     // created.
399     assertTrue("Unexpected type for Edge returned from get method.  Expected: " + EDGE_TYPE
400             + " Actual: " + retrievedEdge.getType(),
401         retrievedEdge.getType().equals(EDGE_TYPE));
402     assertTrue("Unexpected properties for Edge returned from get method.  Expected: " + edgeProperties
403             + " Actual: " + retrievedEdge.getProperties(),
404         retrievedEdge.getProperties().equals(edgeProperties));
405   }
406
407   @Test
408   public void getEdgesTest() throws CrudException {
409
410     final String EDGE_TYPE_HAS = "has";
411     final String EDGE_TYPE_RUNS = "runs";
412
413     // Create some vertices and edges that we can query agains.
414     Vertex complex = champDao.addVertex("complex", MapBuilder.builder()
415         .withKeyValue("Province", "Ontario")
416         .withKeyValue("City", "Ottawa")
417         .withKeyValue("Street", "303 Terry Fox")
418         .build());
419
420     Vertex vserver = champDao.addVertex("vserver", MapBuilder.builder()
421         .withKeyValue("O/S", "Linux")
422         .withKeyValue("version", "6.5")
423         .withKeyValue("hostname", "kll0001")
424         .build());
425
426     Vertex vnf1 = champDao.addVertex("vserver", MapBuilder.builder()
427         .withKeyValue("Application", "OpenDaylight")
428         .build());
429
430     Vertex vnf2 = champDao.addVertex("vserver", MapBuilder.builder()
431         .withKeyValue("Application", "Cammunda")
432         .build());
433
434     Edge edge1 = champDao.addEdge(EDGE_TYPE_HAS, complex, vserver,
435         MapBuilder.builder()
436             .withKeyValue("usesResource", "false")
437             .withKeyValue("hasDelTarget", "false")
438             .build());
439
440     Edge edge2 = champDao.addEdge(EDGE_TYPE_RUNS, vserver, vnf1,
441         MapBuilder.builder()
442             .withKeyValue("usesResource", "false")
443             .withKeyValue("hasDelTarget", "true")
444             .build());
445
446     Edge edge3 = champDao.addEdge(EDGE_TYPE_RUNS, vserver, vnf2,
447         MapBuilder.builder()
448             .withKeyValue("usesResource", "false")
449             .withKeyValue("hasDelTarget", "false")
450             .build());
451
452     // Query for all HAS edges.
453     List<Edge> hasEdges = champDao.getEdges(EDGE_TYPE_HAS, new HashMap<String, Object>());
454
455     assertEquals("Unexpected number of edges of type 'has' found.  Expected: 1 Actual: " + hasEdges.size(),
456         hasEdges.size(), 1);
457     assertTrue("Result of query for 'has' type edges does not contain the expected results",
458         containsEdge(edge1, hasEdges));
459
460     // Query for all RUNS edges.
461     List<Edge> runsEdges = champDao.getEdges(EDGE_TYPE_RUNS, new HashMap<String, Object>());
462
463     assertEquals("Unexpected number of edges of type 'runs' found.  Expected: 2 Actual: " + runsEdges.size(),
464         runsEdges.size(), 2);
465     assertTrue("Result of query for 'runs' type edges does not contain the expected results",
466         containsEdge(edge2, runsEdges));
467     assertTrue("Result of query for 'runs' type edges does not contain the expected results",
468         containsEdge(edge2, runsEdges));
469
470     // Query for all HAS edges with the property 'hasDelTarget' equal to 'true'.
471     List<Edge> runsEdgesWithDelTargetTrue =
472         champDao.getEdges(EDGE_TYPE_RUNS, MapBuilder.builder()
473             .withKeyValue("hasDelTarget", "true")
474             .build());
475
476     assertEquals("Unexpected number of edges of type 'has' with 'hasDelTarget=true' found.  Expected: 1 Actual: "
477             + runsEdgesWithDelTargetTrue.size(),
478         runsEdgesWithDelTargetTrue.size(), 1);
479     assertTrue("Result of query for 'runs' type edges with delTarget set to TRUE does not contain the expected results",
480         containsEdge(edge2, runsEdgesWithDelTargetTrue));
481   }
482
483   @Test
484   @Ignore   // For now - pending some expected fixes to the Champ library.
485   public void updateEdgeTest() throws CrudException {
486
487     // Create the source vertex for the edge.
488     Vertex sourceVertex = champDao.addVertex("vserver", MapBuilder.builder()
489         .withKeyValue("O/S", "Linux")
490         .withKeyValue("version", "6.5")
491         .withKeyValue("hostname", "kll0001")
492         .build());
493
494     // Create the target vertex for the edge.
495     Vertex destVertex = champDao.addVertex("VNF", MapBuilder.builder()
496         .withKeyValue("O/S", "Linux")
497         .withKeyValue("version", "6.5")
498         .withKeyValue("hostname", "kll0002")
499         .build());
500
501     // Now, create the edge itself.
502     Edge createdEdge = champDao.addEdge("has",
503         sourceVertex,
504         destVertex,
505         MapBuilder.builder()
506             .withKeyValue("key1", "value1")
507             .withKeyValue("key2", "value2")
508             .withKeyValue("key3", "value3")
509             .build());
510
511     // Make sure the Edge returned from the create method includes an id that we can
512     // use to retrieve it.
513     assertTrue("No valid id returned for the created edge", createdEdge.getId().isPresent());
514
515     // Retrieve the properties map for our edge and make some changes.
516     Map<String, Object> properties = createdEdge.getProperties();
517     properties.put("key4", "value4");
518     properties.remove("key2");
519
520     // Now update the edge with the new properties map.
521     Edge updatedEdge = champDao.updateEdge(createdEdge);
522
523     assertTrue("Edge property list returned from DAO update operation did not contain all expected properties - expected: " +
524             properties.keySet() + " actual: " + updatedEdge.getProperties().keySet(),
525         updatedEdge.getProperties().keySet().containsAll(properties.keySet()));
526
527     // Validate that the values assigned to the properties in the updated Edge
528     // match the ones that we provided when we created it.
529     for (String propertyKey : properties.keySet()) {
530
531       assertTrue("Unexpected value for property '" + propertyKey + "' - Expected: " +
532               properties.get(propertyKey) + "  Actual: " +
533               updatedEdge.getProperties().get(propertyKey),
534           updatedEdge.getProperties().get(propertyKey).equals(properties.get(propertyKey)));
535     }
536
537     // Validate that the property that we removed is NOT in the set of properties from our
538     // updated edge.
539     // *** We will leave this validation commented out for now, as the Champ library actually
540     //     merges update properties instead of replacing them...
541                 assertFalse("Property 'key2' should no longer be associated with updated edge",
542                                     updatedEdge.getProperties().containsKey("key2"));
543   }
544
545   @Test
546   public void deleteEdgeTest() throws CrudException {
547
548     boolean deletedEdgeNotFound = false;
549
550     // Create the source vertex for the edge.
551     Vertex sourceVertex = champDao.addVertex("vserver", MapBuilder.builder()
552         .withKeyValue("O/S", "Linux")
553         .withKeyValue("version", "6.5")
554         .withKeyValue("hostname", "kll0001")
555         .build());
556
557     // Create the target vertex for the edge.
558     Vertex destVertex = champDao.addVertex("VNF", MapBuilder.builder()
559         .withKeyValue("O/S", "Linux")
560         .withKeyValue("version", "6.5")
561         .withKeyValue("hostname", "kll0002")
562         .build());
563
564     // Now, create the edge itself.
565     Edge createdEdge = champDao.addEdge("has",
566         sourceVertex,
567         destVertex,
568         MapBuilder.builder()
569             .withKeyValue("key1", "value1")
570             .withKeyValue("key2", "value2")
571             .withKeyValue("key3", "value3")
572             .build());
573
574     // Verify that we can retrieve the edge that we just created.
575     Edge retrievedEdge = champDao.getEdge(createdEdge.getId().get(), "has");
576
577     // Now, delete it.
578     champDao.deleteEdge(createdEdge.getId().get(), "has");
579
580     // Try retrieving it again.  This time we should not find it.
581     try {
582       champDao.getEdge(createdEdge.getId().get(), "has");
583     } catch (CrudException e) {
584
585       assertTrue(e.getMessage().contains("No edge with id"));
586       deletedEdgeNotFound = true;
587     }
588
589     assertTrue("Should not have been able to retrieve deleted edge.", deletedEdgeNotFound);
590   }
591
592   private boolean containsEdge(Edge anEdge, List<Edge> edges) {
593
594     for (Edge e : edges) {
595       if (e.getId().isPresent() && anEdge.getId().isPresent() && (e.getId().get().equals(anEdge.getId().get()))) {
596         return true;
597       }
598
599     }
600     return false;
601   }
602
603   public static class MapBuilder {
604
605     private Map<String, Object> map;
606
607     private MapBuilder() {
608       map = new HashMap<String, Object>();
609     }
610
611     public static MapBuilder builder() {
612       return new MapBuilder();
613     }
614
615     public MapBuilder withKeyValue(String key, Object value) {
616       map.put(key, value);
617       return this;
618     }
619
620     public Map<String, Object> build() {
621       return map;
622     }
623   }
624 }