private void assertVertexToSerialize(final Vertex toSerialize, final boolean assertProperties) throws IOException {
        try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
            final GraphWriter writer = writerMaker.apply(graph);
            writer.writeVertex(os, toSerialize);

            final AtomicBoolean called = new AtomicBoolean(false);
            final GraphReader reader = readerMaker.apply(graph);
            try (final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray())) {
                reader.readVertex(bais, attachable -> {
                    final Vertex detachedVertex = attachable.get();
                    if (assertViaDirectEquality) {
                        TestHelper.validateVertexEquality(toSerialize, detachedVertex, false); // don't assert edges - there are none
                    } else {
                        assertEquals(toSerialize.id(), graph.vertices(detachedVertex.id().toString()).next().id());
                        assertEquals(toSerialize.label(), detachedVertex.label());
                        if (assertProperties) {
                            assertEquals(2, IteratorUtils.count(detachedVertex.properties()));
                            assertEquals(toSerialize.value("name"), detachedVertex.value("name").toString());
                            assertEquals(toSerialize.value("acl"), detachedVertex.value("acl").toString());
                        } else {
                            assertEquals(0, IteratorUtils.count(detachedVertex.properties()));
                        }
                    }

                    assertEquals(0, IteratorUtils.count(detachedVertex.edges(Direction.BOTH)));

                    called.set(true);
                    return mock(Vertex.class);
                });
            }
            assertTrue(called.get());
        }
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoVertexTest.java