Search in sources :

Example 1 with ImmutableCreateProperty

use of nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutableCreateProperty in project timbuctoo by HuygensING.

the class TinkerPopOperationsTest method addPropertiesToCollectionsAddsPropertyDescriptionsToTheCollection.

@Test
public void addPropertiesToCollectionsAddsPropertyDescriptionsToTheCollection() {
    TinkerPopGraphManager graphManager = newGraph().wrap();
    TinkerPopOperations instance = forGraphWrapper(graphManager);
    Vre vre = instance.ensureVreExists("vre");
    instance.addCollectionToVre(vre, CreateCollection.defaultCollection("vre"));
    vre = instance.loadVres().getVre("vre");
    Collection collection = vre.getCollectionForTypeName(defaultEntityTypeName(vre));
    ImmutableCreateProperty prop1 = ImmutableCreateProperty.builder().clientName("clientName1").propertyType("string").rdfUri("http://example.org/pred1").typeUri("http://example.org/string").build();
    ImmutableCreateProperty prop2 = ImmutableCreateProperty.builder().clientName("clientName2").propertyType("string").rdfUri("http://example.org/pred2").typeUri("http://example.org/string").build();
    instance.addPropertiesToCollection(collection, Lists.newArrayList(prop1, prop2));
    collection = instance.loadVres().getCollectionForType(defaultEntityTypeName(vre)).get();
    assertThat(collection.getReadableProperties().values(), hasSize(2));
    List<Vertex> properties = graphManager.getGraph().traversal().V().hasLabel("property").toList();
    assertThat(properties, containsInAnyOrder(likeVertex().withProperty("clientName", "@displayName"), likeVertex().withProperty("clientName", "clientName1").withProperty("dbName", collection.getEntityTypeName() + "_" + "http://example.org/pred1").withProperty("propertyType", "string").withProperty("rdfUri", "http://example.org/pred1").withProperty("typeUri", "http://example.org/string"), likeVertex().withProperty("clientName", "clientName2").withProperty("dbName", collection.getEntityTypeName() + "_" + "http://example.org/pred2").withProperty("propertyType", "string").withProperty("rdfUri", "http://example.org/pred2").withProperty("typeUri", "http://example.org/string")));
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) VreStubs.minimalCorrectVre(nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre) ImmutableCreateProperty(nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutableCreateProperty) CreateCollection(nl.knaw.huygens.timbuctoo.core.dto.CreateCollection) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) Test(org.junit.Test)

Aggregations

CreateCollection (nl.knaw.huygens.timbuctoo.core.dto.CreateCollection)1 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)1 ImmutableCreateProperty (nl.knaw.huygens.timbuctoo.core.dto.rdf.ImmutableCreateProperty)1 Vre (nl.knaw.huygens.timbuctoo.model.vre.Vre)1 VreStubs.minimalCorrectVre (nl.knaw.huygens.timbuctoo.model.vre.VreStubs.minimalCorrectVre)1 TinkerPopGraphManager (nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager)1 VertexMatcher.likeVertex (nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex)1 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)1 Test (org.junit.Test)1