/** * Check if two vertices are equal. * Elements should be considered equal here if their properties and label are equal. * * @param expected The expectedValue vertex value. * @param actual The actual vertex value. */ private void assertVertexEquals(EPGMVertex expected, EPGMVertex actual) { assertNotNull(expected); assertNotNull(actual); assertEquals(expected.getLabel(), actual.getLabel()); assertEquals(expected.getPropertyCount(), actual.getPropertyCount()); if (expected.getPropertyCount() > 0) { assertEquals(expected.getProperties(), actual.getProperties()); } } }
@Test public void createWithIDTest() { GradoopId vertexID = GradoopId.get(); EPGMVertex v = new VertexFactory().initVertex(vertexID); assertThat(v.getId(), is(vertexID)); assertThat(v.getPropertyCount(), is(0)); assertThat(v.getGraphCount(), is(0)); }
@Test public void testVertex() throws Exception { GradoopId vertexId = GradoopId.get(); String label = "A"; Properties props = Properties.create(); props.set("k1", "v1"); props.set("k2", "v2"); EPGMVertex vertex = new VertexFactory().initVertex(vertexId, label, props); HashMap<String, String> newProps = new HashMap<>(); newProps.put("k1", "new_k1"); TransformationFunction<EPGMVertex> renameFunction = new RenamePropertyKeys<>(newProps); renameFunction.apply(vertex, vertex); assertThat(vertex.getPropertyCount(), is(2)); assertEquals(label, vertex.getLabel()); assertThat(vertex.getPropertyValue("new_k1").toString(), Is.<Object>is("v1")); assertThat(vertex.getPropertyValue("k2").toString(), Is.<Object>is("v2")); assertNull(vertex.getPropertyValue("k1")); } }
@Test public void createVertexPojoTest() { GradoopId vertexID = GradoopId.get(); String label = "A"; Properties props = Properties.create(); props.set("k1", "v1"); props.set("k2", "v2"); GradoopId graphId1 = GradoopId.get(); GradoopId graphId2 = GradoopId.get(); GradoopIdSet graphIds = new GradoopIdSet(); graphIds.add(graphId1); graphIds.add(graphId2); EPGMVertex vertex = new VertexFactory() .initVertex(vertexID, label, props, graphIds); assertThat(vertex.getId(), is(vertexID)); assertEquals(label, vertex.getLabel()); assertThat(vertex.getPropertyCount(), is(2)); assertThat(vertex.getPropertyValue("k1").getString(), Is.<Object>is("v1")); assertThat(vertex.getPropertyValue("k2").getString(), Is.<Object>is("v2")); assertThat(vertex.getGraphCount(), is(2)); assertTrue(vertex.getGraphIds().contains(graphId1)); assertTrue(vertex.getGraphIds().contains(graphId2)); }