### Question:
VertexGraph extends ElementGraph { public <V extends Vertex> Vertex addVertex(V vertex) { vertex.validate(); org.apache.tinkerpop.gremlin.structure.Vertex delegate; switch (should()) { case CREATE: delegate = complete(create(vertex)); break; case MERGE: delegate = complete(g.inject(1).coalesce( update(vertex), create(vertex))); break; case REPLACE: delegate = complete(g.inject(1).coalesce( clear(vertex), update(vertex), create(vertex))); break; case INSERT: delegate = insert(vertex); break; case IGNORE: default: delegate = complete(g.inject(1).coalesce(find(vertex), create(vertex))); break; } vertex.setDelegate(delegate); vertex.setUserSuppliedId(delegate.id()); delegates.put(vertex.id(), delegate); this.vertex = Parser.as(delegate, vertex.getClass()); observers.notifyAll(observer -> observer.vertexAdded(vertex, this.vertex)); return this.vertex; } VertexGraph(Graph graph, GraphTraversalSource g); org.apache.tinkerpop.gremlin.structure.Vertex delegate(V vertex); Vertex addVertex(V vertex); Vertex removeVertex(V vertex); void reset();  }### Answer:
@Test public void testAddVertex() { Person marko = createElement(); vertexGraph.addVertex(marko); InOrder inOrder = inOrder(g, traversal); switch (should) { case MERGE: inOrder.verify(g, times(1)).inject(1); inOrder.verify(traversal, times(1)).coalesce(traversal, traversal); break; case REPLACE: inOrder.verify(g, times(1)).inject(1); inOrder.verify(traversal, times(1)).coalesce(traversal, traversal, traversal); break; case INSERT: inOrder.verify(g, times(1)).V(); inOrder.verify(traversal, times(1)).coalesce(traversal, traversal); break; case IGNORE: inOrder.verify(g, times(1)).inject(1); inOrder.verify(traversal, times(1)).coalesce(traversal, traversal); break; default: break; } }
@Test(expected = IllegalArgumentException.class) public void testAddInvalidVertex() { Person marko = createElement(); marko.name(null); vertexGraph.addVertex(marko); }