Search in sources :

Example 1 with HyperLinksProperty

use of nl.knaw.huygens.timbuctoo.core.dto.property.HyperLinksProperty in project timbuctoo by HuygensING.

the class EntityToJsonMapperTest method doesNotAddNonConvertableProperties.

@Test
public void doesNotAddNonConvertableProperties() {
    ReadEntityImpl readEntity = new ReadEntityImpl();
    readEntity.setId(UUID.randomUUID());
    String userId = "userId";
    Change change = new Change(Instant.now().toEpochMilli(), userId, null);
    readEntity.setCreated(change);
    readEntity.setModified(change);
    String type = "otherType";
    readEntity.setTypes(Lists.newArrayList("type", type));
    readEntity.setDeleted(false);
    readEntity.setRev(1);
    readEntity.setPid("pid");
    ArrayList<TimProperty<?>> properties = Lists.newArrayList();
    properties.add(new HyperLinksProperty("nonParsableProp", "Name"));
    readEntity.setProperties(properties);
    EntityToJsonMapper instance = new EntityToJsonMapper(userValidator, (collection, id1, rev) -> URI.create("www.example.com"));
    Collection collection = mock(Collection.class);
    when(collection.getEntityTypeName()).thenReturn(type);
    ObjectNode resutlJson = instance.mapEntity(collection, readEntity, false, (readEntity1, resultJson) -> {
    }, (relationRef, resultJson) -> {
    });
    assertThat(Lists.newArrayList(resutlJson.fieldNames()), not(hasItem("nonParsableProp")));
}
Also used : ReadEntityImpl(nl.knaw.huygens.timbuctoo.core.dto.ReadEntityImpl) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) HyperLinksProperty(nl.knaw.huygens.timbuctoo.core.dto.property.HyperLinksProperty) EntityToJsonMapper(nl.knaw.huygens.timbuctoo.crud.conversion.EntityToJsonMapper) TimProperty(nl.knaw.huygens.timbuctoo.core.dto.property.TimProperty) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) Change(nl.knaw.huygens.timbuctoo.model.Change) Test(org.junit.Test)

Example 2 with HyperLinksProperty

use of nl.knaw.huygens.timbuctoo.core.dto.property.HyperLinksProperty in project timbuctoo by HuygensING.

the class TriplePropertyConverterTest method toCreatesABlankNodeForALink.

@Test
public void toCreatesABlankNodeForALink() throws Exception {
    Tuple<String, List<Triple>> to = instance.to(new HyperLinksProperty(PROP_NAME, "[{\"url\":\"http://www.example.org\",\"label\":\"label\"}]"));
    assertThat(to.getRight(), containsInAnyOrder(allOf(hasProperty("subject", is(SUBJECT_URI)), hasProperty("predicate", endsWith(PROP_NAME)), hasProperty("object", startsWith("_:"))), allOf(hasProperty("subject", startsWith("_:")), hasProperty("predicate", endsWith(PROP_NAME + "url")), hasProperty("object", is("http://www.example.org"))), allOf(hasProperty("subject", startsWith("_:")), hasProperty("predicate", endsWith(PROP_NAME + "label")), hasProperty("object", is("label")))));
}
Also used : HyperLinksProperty(nl.knaw.huygens.timbuctoo.core.dto.property.HyperLinksProperty) List(java.util.List) Test(org.junit.Test)

Aggregations

HyperLinksProperty (nl.knaw.huygens.timbuctoo.core.dto.property.HyperLinksProperty)2 Test (org.junit.Test)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 List (java.util.List)1 ReadEntityImpl (nl.knaw.huygens.timbuctoo.core.dto.ReadEntityImpl)1 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)1 TimProperty (nl.knaw.huygens.timbuctoo.core.dto.property.TimProperty)1 EntityToJsonMapper (nl.knaw.huygens.timbuctoo.crud.conversion.EntityToJsonMapper)1 Change (nl.knaw.huygens.timbuctoo.model.Change)1