use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class JsonToEntityMapperTest method newCreateEntityThrowsAnIoExceptionWhenThePropertyIsUnknown.
@Test(expected = IOException.class)
public void newCreateEntityThrowsAnIoExceptionWhenThePropertyIsUnknown() throws Exception {
Collection collection = new VresBuilder().withVre("WomenWriters", "ww", vre -> vre.withCollection("wwpersons", c -> c.withProperty("name", localProperty("wwname")).withProperty("age", localProperty("wwage")))).build().getCollection("wwpersons").get();
ObjectNode input = JsonBuilder.jsnO("unknownProperty", jsn("value"), "age", jsn("12"));
JsonToEntityMapper instance = new JsonToEntityMapper();
instance.getDataProperties(collection, input);
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method loadLoadsTheDisplayName.
@Test
public void loadLoadsTheDisplayName() {
final Vertex collectionVertex = graph.addVertex(Collection.DATABASE_LABEL);
final Vertex displayNameVertex = graph.addVertex(ReadableProperty.DATABASE_LABEL);
final String collectionName = "persons";
final String entityTypeName = "person";
final String propertyType = new StringToStringConverter().getUniqueTypeIdentifier();
collectionVertex.property(COLLECTION_NAME_PROPERTY_NAME, collectionName);
collectionVertex.property(ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName);
collectionVertex.property(IS_RELATION_COLLECTION_PROPERTY_NAME, false);
displayNameVertex.property(LocalProperty.CLIENT_PROPERTY_NAME, "@displayName");
displayNameVertex.property(LocalProperty.DATABASE_PROPERTY_NAME, "person_prop1");
displayNameVertex.property(LocalProperty.PROPERTY_TYPE_NAME, propertyType);
collectionVertex.addEdge(HAS_DISPLAY_NAME_RELATION_NAME, displayNameVertex);
final Collection instance = load(collectionVertex);
assertThat(instance.getDisplayName(), instanceOf(ReadableProperty.class));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method loadLoadsACollectionFromAVertex.
@Test
public void loadLoadsACollectionFromAVertex() {
final Vertex collectionVertex = graph.addVertex(Collection.DATABASE_LABEL);
final String collectionName = "persons";
final String entityTypeName = "person";
collectionVertex.property(COLLECTION_NAME_PROPERTY_NAME, collectionName);
collectionVertex.property(ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName);
collectionVertex.property(IS_RELATION_COLLECTION_PROPERTY_NAME, false);
final Collection instance = load(collectionVertex);
assertThat(instance.getEntityTypeName(), equalTo(entityTypeName));
assertThat(instance.getCollectionName(), equalTo(collectionName));
assertThat(instance.getAbstractType(), equalTo(entityTypeName));
assertThat(instance.isRelationCollection(), equalTo(false));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class LoadSaveCollectionTest method loadLoadsAnInheritingCollectionFromAVertexWithHasArchetypeRelation.
@Test
public void loadLoadsAnInheritingCollectionFromAVertexWithHasArchetypeRelation() {
final Vertex collectionVertex = graph.addVertex(Collection.DATABASE_LABEL);
final Vertex abstractCollectionVertex = graph.addVertex(Collection.DATABASE_LABEL);
final String collectionName = "wwpersons";
final String entityTypeName = "wwperson";
final String abstractCollectionName = "persons";
final String abstractEntityTypeName = "person";
collectionVertex.property(COLLECTION_NAME_PROPERTY_NAME, collectionName);
collectionVertex.property(ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName);
collectionVertex.property(IS_RELATION_COLLECTION_PROPERTY_NAME, false);
abstractCollectionVertex.property(COLLECTION_NAME_PROPERTY_NAME, abstractCollectionName);
abstractCollectionVertex.property(ENTITY_TYPE_NAME_PROPERTY_NAME, abstractEntityTypeName);
collectionVertex.addEdge(HAS_ARCHETYPE_RELATION_NAME, abstractCollectionVertex);
final Collection instance = load(collectionVertex);
assertThat(instance.getAbstractType(), equalTo(abstractEntityTypeName));
}
use of nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection in project timbuctoo by HuygensING.
the class LoadSaveVreTest method loadLoadsRelationCollections.
@Test
public void loadLoadsRelationCollections() {
final String entityTypeName = "relation";
final String collectionName = "relations";
final Vre instance = load(initGraph(g -> g.withVertex("vre", v -> v.withLabel(Vre.DATABASE_LABEL).withProperty(VRE_NAME_PROPERTY_NAME, "VreName")).withVertex("collection", v -> v.withLabel(entityTypeName).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, collectionName).withProperty(Collection.ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName).withProperty(Collection.IS_RELATION_COLLECTION_PROPERTY_NAME, true).withIncomingRelation(HAS_COLLECTION_RELATION_NAME, "vre"))));
final Collection collectionByName = instance.getCollectionForCollectionName(collectionName).get();
assertThat(instance.getRelationCollection().get(), equalTo(collectionByName));
}
Aggregations