use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_INITIAL_PROPERTY_RELATION_NAME in project timbuctoo by HuygensING.
the class CollectionTest method addPropertyAddsThePropertyConfigurationOfThePropertyToTheCollectionVertex.
@Test
public void addPropertyAddsThePropertyConfigurationOfThePropertyToTheCollectionVertex() {
CollectionDescription description = mock(CollectionDescription.class);
String collectionPropertyName = "propertyName";
when(description.createPropertyName(anyString())).thenReturn(collectionPropertyName);
when(description.getVreName()).thenReturn(VRE_NAME);
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME)).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper, description);
Vertex entityVertex = mock(Vertex.class);
String propValue = "propValue";
String propName = "propName";
instance.addProperty(entityVertex, propName, propValue, type);
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).out(HAS_PROPERTY_RELATION_NAME).has("dbName", collectionPropertyName).has("clientName", propName).count().next(), is(1L));
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).out(HAS_INITIAL_PROPERTY_RELATION_NAME).has("dbName", collectionPropertyName).has("clientName", propName).count().next(), is(1L));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_INITIAL_PROPERTY_RELATION_NAME in project timbuctoo by HuygensING.
the class CollectionTest method addPropertyAddsOnlyOneInitialProperties.
@Test
public void addPropertyAddsOnlyOneInitialProperties() {
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME)).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
instance.addProperty(mock(Vertex.class), "prop1", "val1", type);
instance.addProperty(mock(Vertex.class), "prop2", "val2", type);
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).out(HAS_INITIAL_PROPERTY_RELATION_NAME).count().next(), is(1L));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.HAS_INITIAL_PROPERTY_RELATION_NAME in project timbuctoo by HuygensING.
the class CollectionTest method addPropertyAddsHasNextEdgeBetweenTheProperties.
@Test
public void addPropertyAddsHasNextEdgeBetweenTheProperties() {
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME)).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
instance.addProperty(mock(Vertex.class), "prop1", "val1", type);
instance.addProperty(mock(Vertex.class), "prop2", "val2", type);
instance.addProperty(mock(Vertex.class), "prop3", "val3", type);
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).out(HAS_INITIAL_PROPERTY_RELATION_NAME).out(HAS_NEXT_PROPERTY_RELATION_NAME).out(HAS_NEXT_PROPERTY_RELATION_NAME).count().next(), is(1L));
}
Aggregations