@Test @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldReadWriteVertexPropertyNoMetaProperties() throws Exception { try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) { final GraphWriter writer = writerMaker.apply(graph); final VertexProperty p = g.V(convertToVertexId("marko")).next().property("name"); writer.writeVertexProperty(os, p); final AtomicBoolean called = new AtomicBoolean(false); final GraphReader reader = readerMaker.apply(graph); try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) { reader.readVertexProperty(bais, propertyAttachable -> { assertEquals(p.value(), propertyAttachable.get().value()); assertEquals(p.key(), propertyAttachable.get().key()); assertEquals(0, IteratorUtils.count(propertyAttachable.get().properties())); called.set(true); return propertyAttachable.get(); }); } assertTrue(called.get()); } }
@Test @LoadGraphWith(LoadGraphWith.GraphData.CREW) public void shouldReadWriteVertexPropertyWithMetaProperties() throws Exception { try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) { final GraphWriter writer = writerMaker.apply(graph); // select any vertexproperty that has both start/end time final VertexProperty p = (VertexProperty) g.V(convertToVertexId("marko")).properties("location").as("p").has("endTime").select("p").next(); writer.writeVertexProperty(os, p); final AtomicBoolean called = new AtomicBoolean(false); final GraphReader reader = readerMaker.apply(graph); try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) { reader.readVertexProperty(bais, propertyAttachable -> { assertEquals(p.value(), propertyAttachable.get().value()); assertEquals(p.key(), propertyAttachable.get().key()); assertEquals(IteratorUtils.count(p.properties()), IteratorUtils.count(propertyAttachable.get().properties())); assertEquals(p.property("startTime").value(), ((Property) propertyAttachable.get().properties("startTime").next()).value()); assertEquals(p.property("endTime").value(), ((Property) propertyAttachable.get().properties("endTime").next()).value()); called.set(true); return propertyAttachable.get(); }); } assertTrue(called.get()); } }
@Test @LoadGraphWith(LoadGraphWith.GraphData.MODERN) public void shouldReadWriteVertexPropertyNoMetaProperties() throws Exception { try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) { final GraphWriter writer = writerMaker.apply(graph); final VertexProperty p = g.V(convertToVertexId("marko")).next().property("name"); writer.writeVertexProperty(os, p); final AtomicBoolean called = new AtomicBoolean(false); final GraphReader reader = readerMaker.apply(graph); try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) { reader.readVertexProperty(bais, propertyAttachable -> { assertEquals(p.value(), propertyAttachable.get().value()); assertEquals(p.key(), propertyAttachable.get().key()); assertEquals(0, IteratorUtils.count(propertyAttachable.get().properties())); called.set(true); return propertyAttachable.get(); }); } assertTrue(called.get()); } }
@Test @LoadGraphWith(LoadGraphWith.GraphData.CREW) public void shouldReadWriteVertexPropertyWithMetaProperties() throws Exception { try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) { final GraphWriter writer = writerMaker.apply(graph); // select any vertexproperty that has both start/end time final VertexProperty p = (VertexProperty) g.V(convertToVertexId("marko")).properties("location").as("p").has("endTime").select("p").next(); writer.writeVertexProperty(os, p); final AtomicBoolean called = new AtomicBoolean(false); final GraphReader reader = readerMaker.apply(graph); try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) { reader.readVertexProperty(bais, propertyAttachable -> { assertEquals(p.value(), propertyAttachable.get().value()); assertEquals(p.key(), propertyAttachable.get().key()); assertEquals(IteratorUtils.count(p.properties()), IteratorUtils.count(propertyAttachable.get().properties())); assertEquals(p.property("startTime").value(), ((Property) propertyAttachable.get().properties("startTime").next()).value()); assertEquals(p.property("endTime").value(), ((Property) propertyAttachable.get().properties("endTime").next()).value()); called.set(true); return propertyAttachable.get(); }); } assertTrue(called.get()); } }