public static void validateVertexPropertyEquality( final VertexProperty originalVertexProperty, final VertexProperty otherVertexProperty) { assertEquals(originalVertexProperty, otherVertexProperty); assertEquals(otherVertexProperty, originalVertexProperty); if (originalVertexProperty.isPresent()) { assertEquals(originalVertexProperty.key(), otherVertexProperty.key()); assertEquals(originalVertexProperty.value(), otherVertexProperty.value()); assertEquals(originalVertexProperty.element(), otherVertexProperty.element()); final boolean originalSupportsMetaProperties = originalVertexProperty.graph().features().vertex().supportsMetaProperties(); final boolean otherSupportsMetaProperties = otherVertexProperty.graph().features().vertex().supportsMetaProperties(); // if one supports and the other doesn't then neither should have meta properties. if (originalSupportsMetaProperties && !otherSupportsMetaProperties) assertEquals(0, originalVertexProperty.keys().size()); else if (!originalSupportsMetaProperties && otherSupportsMetaProperties) assertEquals(0, otherVertexProperty.keys().size()); else { // both support it, so assert in full assertEquals(originalVertexProperty.keys().size(), otherVertexProperty.keys().size()); for (final String key : originalVertexProperty.keys()) { validatePropertyEquality( originalVertexProperty.property(key), otherVertexProperty.property(key)); } } } }
public static void validateEquality(final Object original, final Object other) { if (original instanceof Vertex) validateVertexEquality((Vertex) original, (Vertex) other, true); else if (original instanceof VertexProperty) validateVertexPropertyEquality((VertexProperty) original, (VertexProperty) other); else if (original instanceof Edge) validateEdgeEquality((Edge) original, (Edge) other); else if (original instanceof Property) validatePropertyEquality((Property) original, (Property) other); else throw new IllegalArgumentException( "The provided object must be a graph object: " + original.getClass().getCanonicalName()); }
public static void validateEdgeEquality(final Edge originalEdge, final Edge otherEdge) { assertEquals(originalEdge, otherEdge); assertEquals(otherEdge, originalEdge); assertEquals(originalEdge.id(), otherEdge.id()); assertEquals(originalEdge.label(), otherEdge.label()); assertEquals(originalEdge.inVertex(), otherEdge.inVertex()); assertEquals(originalEdge.outVertex(), otherEdge.outVertex()); assertEquals(originalEdge.keys().size(), otherEdge.keys().size()); for (final String key : originalEdge.keys()) { validatePropertyEquality(originalEdge.property(key), otherEdge.property(key)); } }