use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method saveCreatesARelationToTheArchetypeVariantCollectionVertex.
@Test
public void saveCreatesARelationToTheArchetypeVariantCollectionVertex() {
final Vre vre = new Vre(vreName);
final Graph graph = newGraph().withVertex(v -> {
v.withLabel(DATABASE_LABEL);
v.withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, "persons");
v.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "person");
}).build();
timbuctooCollection("prefixedpersons", "prefixed").build(vre);
final Vertex result = save(vre.getCollectionForCollectionName("prefixedpersons").get(), graph);
assertThat(result.vertices(Direction.OUT, Collection.HAS_ARCHETYPE_RELATION_NAME).hasNext(), equalTo(true));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL in project timbuctoo by HuygensING.
the class CollectionTest method addPropertyDoesNotEvenAddThePropertyWhenTheCollectionIsAnArchetypeAndDoesHaveAConfigForTheProperty.
@Test
public void addPropertyDoesNotEvenAddThePropertyWhenTheCollectionIsAnArchetypeAndDoesHaveAConfigForTheProperty() {
GraphWrapper graphWrapper = newGraph().withVertex("concepts", v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "concept").withProperty(COLLECTION_NAME_PROPERTY_NAME, "concepts")).withVertex(v -> v.withLabel(LocalProperty.DATABASE_LABEL).withProperty(LocalProperty.DATABASE_PROPERTY_NAME, "concept_prop1").withIncomingRelation(HAS_PROPERTY_RELATION_NAME, "concepts")).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().next();
CollectionDescription collectionDescription = CollectionDescription.createForAdmin("concept");
Collection instance = new Collection("Admin", collectionVertex, graphWrapper, collectionDescription);
Vertex entityVertex = mock(Vertex.class);
instance.addProperty(entityVertex, "prop1", "val1", type);
verify(entityVertex, never()).property("concept_prop1", "val1");
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL 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.DATABASE_LABEL in project timbuctoo by HuygensING.
the class CollectionTest method removeRemovesTheCollectionPropertiesFromTheVertex.
@Test
public void removeRemovesTheCollectionPropertiesFromTheVertex() {
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 -> v.withOutgoingRelation(HAS_ENTITY_RELATION_NAME, "entity")).withVertex("entity", v -> v.withLabel("entity")).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of("collection")).next();
Vertex entityVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of("entity")).next();
CollectionDescription description = CollectionDescription.createCollectionDescription(ENTITY_NAME, VRE_NAME);
PropertyHelper propertyHelper = mock(PropertyHelper.class);
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper, description, propertyHelper);
instance.remove(entityVertex);
verify(propertyHelper).removeProperties(entityVertex, description);
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.DATABASE_LABEL in project timbuctoo by HuygensING.
the class CollectionTest method addPropertyDoesNotAddThePropertyWhenTheCollectionIsAnArchetypeAndDoesNotHaveAConfigForTheProperty.
@Test
public void addPropertyDoesNotAddThePropertyWhenTheCollectionIsAnArchetypeAndDoesNotHaveAConfigForTheProperty() {
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "concept").withProperty(COLLECTION_NAME_PROPERTY_NAME, "concepts")).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().next();
CollectionDescription collectionDescription = CollectionDescription.createForAdmin("concept");
Collection instance = new Collection("Admin", collectionVertex, graphWrapper, collectionDescription);
Vertex entityVertex = mock(Vertex.class);
instance.addProperty(entityVertex, "prop1", "val1", type);
verify(entityVertex, never()).property("concept_prop1", "val1");
}
Aggregations