Search in sources :

Example 1 with FastNoSuchElementException

use of org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException in project timbuctoo by HuygensING.

the class CollectionTest method removeDoesNothingWhenTheEntityIsNotPartOfTheCollection.

@Test
public void removeDoesNothingWhenTheEntityIsNotPartOfTheCollection() {
    GraphWrapper graphWrapper = newGraph().withVertex("collection", v -> v.withLabel(DATABASE_LABEL).withOutgoingRelation(HAS_ENTITY_NODE_RELATION_NAME, "entityNode").withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME)).withVertex("entityNode", v -> {
    }).withVertex("entity", v -> v.withLabel("entity")).wrap();
    Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL)).next();
    Vertex entityVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of("entity")).next();
    Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
    try {
        instance.remove(entityVertex);
    } catch (FastNoSuchElementException e) {
        fail("Should not throw an exception.");
    }
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) HAS_ARCHETYPE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME) LocalProperty(nl.knaw.huygens.timbuctoo.model.properties.LocalProperty) PROPERTY_TYPE_NAME(nl.knaw.huygens.timbuctoo.model.properties.ReadableProperty.PROPERTY_TYPE_NAME) LabelP(org.apache.tinkerpop.gremlin.neo4j.process.traversal.LabelP) DATABASE_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.model.properties.LocalProperty.DATABASE_PROPERTY_NAME) Matchers.not(org.hamcrest.Matchers.not) CLIENT_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.model.properties.ReadableProperty.CLIENT_PROPERTY_NAME) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) HAS_INITIAL_PROPERTY_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_INITIAL_PROPERTY_RELATION_NAME) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) MockitoHamcrest.argThat(org.mockito.hamcrest.MockitoHamcrest.argThat) HAS_ENTITY_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_RELATION_NAME) Assert.fail(org.junit.Assert.fail) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) FastNoSuchElementException(org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException) StringToStringConverter(nl.knaw.huygens.timbuctoo.model.properties.converters.StringToStringConverter) HAS_ENTITY_NODE_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_NODE_RELATION_NAME) Iterator(java.util.Iterator) COLLECTION_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME) ENTITY_TYPE_NAME_PROPERTY_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.ENTITY_TYPE_NAME_PROPERTY_NAME) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Mockito.when(org.mockito.Mockito.when) T(org.apache.tinkerpop.gremlin.structure.T) HAS_NEXT_PROPERTY_RELATION_NAME(nl.knaw.huygens.timbuctoo.model.properties.ReadableProperty.HAS_NEXT_PROPERTY_RELATION_NAME) Mockito.verify(org.mockito.Mockito.verify) DATABASE_LABEL(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL) Mockito.never(org.mockito.Mockito.never) GraphWrapper(nl.knaw.huygens.timbuctoo.server.GraphWrapper) EdgeMatcher.likeEdge(nl.knaw.huygens.timbuctoo.util.EdgeMatcher.likeEdge) Matchers.hasItem(org.hamcrest.Matchers.hasItem) HAS_DISPLAY_NAME_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_DISPLAY_NAME_RELATION_NAME) RDF_URI_PROP(nl.knaw.huygens.timbuctoo.rdf.Database.RDF_URI_PROP) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Matchers.is(org.hamcrest.Matchers.is) HAS_PROPERTY_RELATION_NAME(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_PROPERTY_RELATION_NAME) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphWrapper(nl.knaw.huygens.timbuctoo.server.GraphWrapper) FastNoSuchElementException(org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException) Test(org.junit.Test)

Aggregations

Iterator (java.util.Iterator)1 COLLECTION_NAME_PROPERTY_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME)1 DATABASE_LABEL (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL)1 ENTITY_TYPE_NAME_PROPERTY_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.ENTITY_TYPE_NAME_PROPERTY_NAME)1 HAS_ARCHETYPE_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ARCHETYPE_RELATION_NAME)1 HAS_DISPLAY_NAME_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_DISPLAY_NAME_RELATION_NAME)1 HAS_ENTITY_NODE_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_NODE_RELATION_NAME)1 HAS_ENTITY_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_ENTITY_RELATION_NAME)1 HAS_INITIAL_PROPERTY_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_INITIAL_PROPERTY_RELATION_NAME)1 HAS_PROPERTY_RELATION_NAME (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_PROPERTY_RELATION_NAME)1 LocalProperty (nl.knaw.huygens.timbuctoo.model.properties.LocalProperty)1 DATABASE_PROPERTY_NAME (nl.knaw.huygens.timbuctoo.model.properties.LocalProperty.DATABASE_PROPERTY_NAME)1 CLIENT_PROPERTY_NAME (nl.knaw.huygens.timbuctoo.model.properties.ReadableProperty.CLIENT_PROPERTY_NAME)1 HAS_NEXT_PROPERTY_RELATION_NAME (nl.knaw.huygens.timbuctoo.model.properties.ReadableProperty.HAS_NEXT_PROPERTY_RELATION_NAME)1 PROPERTY_TYPE_NAME (nl.knaw.huygens.timbuctoo.model.properties.ReadableProperty.PROPERTY_TYPE_NAME)1 StringToStringConverter (nl.knaw.huygens.timbuctoo.model.properties.converters.StringToStringConverter)1 RDF_URI_PROP (nl.knaw.huygens.timbuctoo.rdf.Database.RDF_URI_PROP)1 GraphWrapper (nl.knaw.huygens.timbuctoo.server.GraphWrapper)1 EdgeMatcher.likeEdge (nl.knaw.huygens.timbuctoo.util.EdgeMatcher.likeEdge)1 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)1