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