use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method saveReplacesAnExistingVertexForTheCollection.
@Test
public void saveReplacesAnExistingVertexForTheCollection() {
final Vertex existingVertex = graph.addVertex(DATABASE_LABEL);
existingVertex.property(Collection.COLLECTION_NAME_PROPERTY_NAME, "persons");
final Vre vre = new Vre(vreName);
timbuctooCollection("persons", "").build(vre);
final Vertex result = save(vre.getCollectionForCollectionName("persons").get(), graph);
assertThat(result, equalTo(existingVertex));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre 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.model.vre.Vre in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method saveDropsRelatedExistingPropertyVertices.
@Test
public void saveDropsRelatedExistingPropertyVertices() {
final Vre vre = new Vre(vreName);
final Vertex existingVertex = graph.addVertex(DATABASE_LABEL);
final Vertex existingPropertyVertex = graph.addVertex(ReadableProperty.DATABASE_LABEL);
final Vertex existingPropertyVertex2 = graph.addVertex(ReadableProperty.DATABASE_LABEL);
final Vertex existingPropertyVertex3 = graph.addVertex(ReadableProperty.DATABASE_LABEL);
existingVertex.property(Collection.COLLECTION_NAME_PROPERTY_NAME, "persons");
existingVertex.addEdge(HAS_PROPERTY_RELATION_NAME, existingPropertyVertex);
existingVertex.addEdge(HAS_DISPLAY_NAME_RELATION_NAME, existingPropertyVertex2);
existingVertex.addEdge(HAS_INITIAL_PROPERTY_RELATION_NAME, existingPropertyVertex3);
timbuctooCollection("persons", "").build(vre);
save(vre.getCollectionForCollectionName("persons").get(), graph);
assertThat(graph.traversal().V().hasLabel(ReadableProperty.DATABASE_LABEL).hasNext(), equalTo(false));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method saveSavesThePropertyConfigurations.
@Test
public void saveSavesThePropertyConfigurations() {
final Vre vre = new Vre(vreName);
timbuctooCollection("persons", "").withProperty("prop1", localProperty("person_prop1")).withProperty("prop2", localProperty("person_prop2")).withProperty("prop3", localProperty("person_prop3")).withDisplayName(localProperty("person_prop1")).build(vre);
final Vertex result = save(vre.getCollectionForCollectionName("persons").get(), graph);
final List<Vertex> propertyVertices = Lists.newArrayList(result.vertices(Direction.OUT, Collection.HAS_PROPERTY_RELATION_NAME));
assertThat(propertyVertices, containsInAnyOrder(likeVertex().withLabel(ReadableProperty.DATABASE_LABEL).withProperty(ReadableProperty.CLIENT_PROPERTY_NAME, "prop1").withProperty(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop1"), likeVertex().withLabel(ReadableProperty.DATABASE_LABEL).withProperty(ReadableProperty.CLIENT_PROPERTY_NAME, "prop2").withProperty(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop2"), likeVertex().withLabel(ReadableProperty.DATABASE_LABEL).withProperty(ReadableProperty.CLIENT_PROPERTY_NAME, "prop3").withProperty(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop3")));
assertThat(result.vertices(Direction.OUT, HAS_DISPLAY_NAME_RELATION_NAME).next(), likeVertex().withLabel(ReadableProperty.DATABASE_LABEL).withProperty(ReadableProperty.CLIENT_PROPERTY_NAME, ReadableProperty.DISPLAY_NAME_PROPERTY_NAME).withProperty(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop1"));
assertThat(result.vertices(Direction.OUT, HAS_INITIAL_PROPERTY_RELATION_NAME).next(), likeVertex().withLabel(ReadableProperty.DATABASE_LABEL).withProperty(ReadableProperty.CLIENT_PROPERTY_NAME, "prop1").withProperty(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop1"));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method saveAddsOrderingRelationsBetweenItsPropertyVerticesToMaintainSortorder.
@Test
public void saveAddsOrderingRelationsBetweenItsPropertyVerticesToMaintainSortorder() {
final Vre vre = new Vre(vreName);
timbuctooCollection("persons", "").withProperty("prop1", localProperty("person_prop1")).withProperty("prop2", localProperty("person_prop2")).withProperty("prop3", localProperty("person_prop3")).withDisplayName(localProperty("person_prop1")).build(vre);
Vertex current = save(vre.getCollectionForCollectionName("persons").get(), graph).vertices(Direction.OUT, HAS_INITIAL_PROPERTY_RELATION_NAME).next();
List<Vertex> result = Lists.newArrayList();
result.add(current);
while (current.vertices(Direction.OUT, ReadableProperty.HAS_NEXT_PROPERTY_RELATION_NAME).hasNext()) {
current = current.vertices(Direction.OUT, ReadableProperty.HAS_NEXT_PROPERTY_RELATION_NAME).next();
result.add(current);
}
assertThat(result.size(), equalTo(3));
assertThat(result, contains(likeVertex().withLabel(ReadableProperty.DATABASE_LABEL).withProperty(ReadableProperty.CLIENT_PROPERTY_NAME, "prop1").withProperty(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop1"), likeVertex().withLabel(ReadableProperty.DATABASE_LABEL).withProperty(ReadableProperty.CLIENT_PROPERTY_NAME, "prop2").withProperty(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop2"), likeVertex().withLabel(ReadableProperty.DATABASE_LABEL).withProperty(ReadableProperty.CLIENT_PROPERTY_NAME, "prop3").withProperty(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop3")));
}
Aggregations