Search in sources :

Example 31 with GraphWrapper

use of nl.knaw.huygens.timbuctoo.server.GraphWrapper in project timbuctoo by HuygensING.

the class GraphLogValidatorTest method writeReportWritesALineForEachInvalidVertex.

@Test
public void writeReportWritesALineForEachInvalidVertex() throws Exception {
    GraphWrapper wrapper = newGraph().withVertex(v -> v.withTimId(VERTEX_ID_1).withProperty("rev", 1).withLabel("document")).withVertex(v -> v.withTimId(VERTEX_ID_2).withProperty("rev", 1).withLabel("document")).withVertex(v -> v.withTimId(VERTEX_ID_1).withProperty("rev", 2).withLabel("document")).withVertex(v -> v.withTimId(VERTEX_ID_2).withProperty("rev", 2).withLabel("document")).withVertex(v -> v.withLabel("history").withOutgoingRelation("NEXT_ITEM", "v1")).withVertex("v1", v -> v.withProperty("TIM_tim_id", VERTEX_ID_1).withProperty("rev", 1).withLabel("createVertexEntry").withOutgoingRelation("NEXT_ITEM", "v2")).withVertex("v2", v -> v.withProperty("TIM_tim_id", VERTEX_ID_1).withProperty("rev", 2).withLabel("updateVertexEntry")).wrap();
    GraphLogValidator graphLogValidator = new GraphLogValidator(wrapper);
    Writer writer = mock(Writer.class);
    graphLogValidator.writeReport(writer);
    ArgumentCaptor<String> stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
    verify(writer, times(2)).write(stringArgumentCaptor.capture());
    assertThat(stringArgumentCaptor.getAllValues(), containsInAnyOrder(stringContainsInOrder(Lists.newArrayList("Vertex", VERTEX_ID_2, "2")), stringContainsInOrder(Lists.newArrayList("Vertex", VERTEX_ID_2, "1"))));
    verifyNoMoreInteractions(writer);
}
Also used : StringContainsInOrder.stringContainsInOrder(org.hamcrest.text.StringContainsInOrder.stringContainsInOrder) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) UUID(java.util.UUID) Mockito.verify(org.mockito.Mockito.verify) Assert.assertThat(org.junit.Assert.assertThat) Lists(com.google.common.collect.Lists) GraphWrapper(nl.knaw.huygens.timbuctoo.server.GraphWrapper) ArgumentCaptor(org.mockito.ArgumentCaptor) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) Writer(java.io.Writer) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Mockito.mock(org.mockito.Mockito.mock) GraphWrapper(nl.knaw.huygens.timbuctoo.server.GraphWrapper) Writer(java.io.Writer) Test(org.junit.Test)

Aggregations

GraphWrapper (nl.knaw.huygens.timbuctoo.server.GraphWrapper)31 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)31 Test (org.junit.Test)31 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)28 Mockito.mock (org.mockito.Mockito.mock)25 VertexMatcher.likeVertex (nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex)24 Mockito.verify (org.mockito.Mockito.verify)23 EdgeMatcher.likeEdge (nl.knaw.huygens.timbuctoo.util.EdgeMatcher.likeEdge)22 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)20 MockitoHamcrest.argThat (org.mockito.hamcrest.MockitoHamcrest.argThat)18 Iterator (java.util.Iterator)17 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)17 Mockito.verifyNoMoreInteractions (org.mockito.Mockito.verifyNoMoreInteractions)15 COLLECTION_NAME_PROPERTY_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME)13 DATABASE_LABEL (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL)13 ENTITY_TYPE_NAME_PROPERTY_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.ENTITY_TYPE_NAME_PROPERTY_NAME)13 HAS_ARCHETYPE_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME)13 HAS_DISPLAY_NAME_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_DISPLAY_NAME_RELATION_NAME)13 HAS_ENTITY_NODE_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_NODE_RELATION_NAME)13 HAS_ENTITY_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_RELATION_NAME)13