use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_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.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.
the class CollectionTest method addPropertyOnlyAddsThePropertyConfigurationForNewProperties.
@Test
public void addPropertyOnlyAddsThePropertyConfigurationForNewProperties() {
CollectionDescription description = mock(CollectionDescription.class);
String collectionPropertyName = "propertyName";
when(description.createPropertyName(anyString())).thenReturn(collectionPropertyName);
when(description.getVreName()).thenReturn(VRE_NAME);
String propName = "propName";
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";
Vertex otherVertex = mock(Vertex.class);
instance.addProperty(entityVertex, propName, propValue, type);
instance.addProperty(otherVertex, 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));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.
the class CollectionTest method setArchetypeConnectsTheCollectionToTheNewArchetype.
@Test
public void setArchetypeConnectsTheCollectionToTheNewArchetype() {
String newArchetypeEntity = "newArchetype";
GraphWrapper graphWrapper = newGraph().withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).withProperty(COLLECTION_NAME_PROPERTY_NAME, COLLECTION_NAME)).withVertex(v -> v.withLabel(DATABASE_LABEL).withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity)).wrap();
Vertex collectionVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL)).has(ENTITY_TYPE_NAME_PROPERTY_NAME, ENTITY_NAME).next();
Collection instance = new Collection(VRE_NAME, collectionVertex, graphWrapper);
Vertex archetypeVertex = graphWrapper.getGraph().traversal().V().has(T.label, LabelP.of(DATABASE_LABEL)).has(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity).next();
Collection archetype = new Collection("", archetypeVertex, graphWrapper);
instance.setArchetype(archetype, "");
assertThat(graphWrapper.getGraph().traversal().V(collectionVertex.id()).out(HAS_ARCHETYPE_RELATION_NAME).toList(), hasItem(likeVertex().withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, newArchetypeEntity)));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.
the class CollectionTest method addPropertyAddsThePropertyForTheCurrentCollectionToTheEntityVertex.
@Test
public void addPropertyAddsThePropertyForTheCurrentCollectionToTheEntityVertex() {
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";
instance.addProperty(entityVertex, "propName", propValue, type);
verify(entityVertex).property(collectionPropertyName, propValue);
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection.COLLECTION_NAME_PROPERTY_NAME in project timbuctoo by HuygensING.
the class DatabaseTest method findArchetypeCollectionReturnsTheArchetypeCollectionWrappedInAnOptional.
@Test
public void findArchetypeCollectionReturnsTheArchetypeCollectionWrappedInAnOptional() {
TinkerPopGraphManager graphWrapper = newGraph().withVertex(v -> v.withLabel(Vre.DATABASE_LABEL).withProperty(Vre.VRE_NAME_PROPERTY_NAME, "Admin").withOutgoingRelation(Vre.HAS_COLLECTION_RELATION_NAME, "defaultArchetype").withOutgoingRelation(Vre.HAS_COLLECTION_RELATION_NAME, "knownArchetype")).withVertex("defaultArchetype", v -> v.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "concept").withProperty(COLLECTION_NAME_PROPERTY_NAME, "concepts")).withVertex("knownArchetype", v -> v.withProperty(ENTITY_TYPE_NAME_PROPERTY_NAME, "knownArchetype").withProperty(COLLECTION_NAME_PROPERTY_NAME, "knownArchetypes")).wrap();
Node node = mock(Node.class);
when(node.getLocalName()).thenReturn("knownArchetype");
Database instance = new Database(graphWrapper);
Optional<Collection> archetypeCollection = instance.findArchetypeCollection(node.getLocalName());
assertThat(archetypeCollection, is(present()));
}
Aggregations