Search in sources :

Example 11 with CustomProvenance

use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.CustomProvenance in project timbuctoo by HuygensING.

the class DerivedSchemaContainerTest method createWithProvenance.

private DerivedSchemaContainer createWithProvenance(CustomProvenance customProvenance) {
    DerivedSchemaContainer instance = new DerivedSchemaContainer(ROOT_TYPE, nameGenerator, argumentsHelper, readOnlyChecker, customProvenance);
    Predicate predicate = predicate().withName(VALUE_TYPE_URI).hasDirection(Direction.OUT).build();
    DerivedObjectTypeSchemaGenerator typeSchemaGenerator = instance.addObjectType(OBJECT_TYPE_URI);
    typeSchemaGenerator.valueField(null, predicate, STRING);
    return instance;
}
Also used : Predicate(nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate)

Example 12 with CustomProvenance

use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.CustomProvenance in project timbuctoo by HuygensING.

the class ProvenanceChangeLogTest method getProvenanceForField.

@Test
public void getProvenanceForField() throws Exception {
    CustomProvenance customProvenance = CustomProvenance.getCustomProvenance(ImmutableMap.of("fields", Lists.newArrayList(ImmutableMap.of("uri", NAME_URI, "isList", false, "valueType", STRING))));
    when(dataSet.getCustomProvenance()).thenReturn(customProvenance);
    String value = "value";
    Map<Object, Object> provenance = Maps.newHashMap();
    provenance.put(NAME_FIELD, createPropertyInput(value));
    Map<Object, Object> entity = Maps.newHashMap();
    entity.put("provenance", provenance);
    ProvenanceChangeLog instance = new ProvenanceChangeLog(entity);
    List<Change> provChanges = instance.getProvenance(dataSet, SUBJECT).collect(toList());
    assertThat(provChanges.size(), is(1));
    assertThat(provChanges.get(0), is(likeChange().withSubject(SUBJECT).withPredicate(NAME_URI).withValues(new Value(value, STRING)).oldValuesIsEmpty()));
}
Also used : Value(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value) ProvenanceChangeLog(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.ProvenanceChangeLog) ChangeMatcher.likeChange(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.ChangeMatcher.likeChange) CustomProvenance(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.CustomProvenance) Test(org.junit.Test)

Example 13 with CustomProvenance

use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.CustomProvenance in project timbuctoo by HuygensING.

the class ProvenanceChangeLogTest method getProvenanceForObjectFieldWihoutUri.

@Test
public void getProvenanceForObjectFieldWihoutUri() throws Exception {
    CustomProvenance customProvenance = CustomProvenance.getCustomProvenance(ImmutableMap.of("fields", Lists.newArrayList(ImmutableMap.of("uri", NAME_URI, "isList", false, "object", ImmutableMap.of("type", TYPE_URI, "fields", Lists.newArrayList(ImmutableMap.of("uri", FIRST_NAME_URI, "isList", false, "valueType", STRING)))))));
    when(dataSet.getCustomProvenance()).thenReturn(customProvenance);
    String value = "value";
    Map<Object, Object> name = Maps.newHashMap();
    name.put(FIRST_NAME_FIELD, createPropertyInput(value));
    Map<Object, Object> provenance = Maps.newHashMap();
    provenance.put(NAME_FIELD, name);
    Map<Object, Object> entity = Maps.newHashMap();
    entity.put("provenance", provenance);
    ProvenanceChangeLog instance = new ProvenanceChangeLog(entity);
    List<Change> provChanges = instance.getProvenance(dataSet, SUBJECT).collect(toList());
    assertThat(provChanges.get(1).getSubject(), startsWith("http://example.org/datasets/rootType/schema_Person/"));
    assertThat(provChanges.get(2).getSubject(), startsWith("http://example.org/datasets/rootType/schema_Person/"));
}
Also used : ProvenanceChangeLog(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.ProvenanceChangeLog) ChangeMatcher.likeChange(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.ChangeMatcher.likeChange) CustomProvenance(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.CustomProvenance) Test(org.junit.Test)

Aggregations

CustomProvenance (nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.CustomProvenance)9 Test (org.junit.Test)7 ChangeMatcher.likeChange (nl.knaw.huygens.timbuctoo.v5.graphql.mutations.ChangeMatcher.likeChange)5 ProvenanceChangeLog (nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.ProvenanceChangeLog)5 Value (nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value)4 DataSet (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)3 Predicate (nl.knaw.huygens.timbuctoo.v5.datastores.schemastore.dto.Predicate)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 JsonSubTypes (com.fasterxml.jackson.annotation.JsonSubTypes)2 JsonTypeInfo (com.fasterxml.jackson.annotation.JsonTypeInfo)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Lists (com.google.common.collect.Lists)2 List (java.util.List)2 Map (java.util.Map)2 Spliterator (java.util.Spliterator)2 Spliterators (java.util.Spliterators)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2