use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class BdbSchemaStoreTest method generatesASchemaForAllAdded.
@Test
public void generatesASchemaForAllAdded() throws Exception {
final DummyDataStorage dataStore = new DummyDataStorage();
ChangeFetcher changeFetcher = new DummyChangeFetcher(CursorQuad.create("subj", "pred", Direction.OUT, ChangeType.ASSERTED, "obj", null, null, null, ""), CursorQuad.create("subj", "langPred", Direction.OUT, ChangeType.ASSERTED, "value", RdfConstants.LANGSTRING, "en", null, ""), CursorQuad.create("subj", RdfConstants.RDF_TYPE, Direction.OUT, ChangeType.ASSERTED, "type", null, null, null, ""), CursorQuad.create("obj", "pred", Direction.IN, ChangeType.ASSERTED, "subj", null, null, null, ""));
BdbSchemaStore schemaStore = new BdbSchemaStore(dataStore, new ImportStatus(new LogList()));
schemaStore.start();
schemaStore.onChangedSubject("subj", changeFetcher);
schemaStore.onChangedSubject("obj", changeFetcher);
schemaStore.finish();
assertThat(dataStore.getResult(), is("{\n" + " \"type\" : {\n" + " \"name\" : \"type\",\n" + " \"predicates\" : [ {\n" + " \"name\" : \"langPred\",\n" + " \"direction\" : \"OUT\",\n" + " \"valueTypes\" : {\n" + " \"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString\" : 1\n" + " },\n" + " \"referenceTypes\" : { },\n" + " \"languages\" : [ \"en\" ],\n" + " \"subjectsWithThisPredicate\" : 1,\n" + " \"subjectsWithThisPredicateAsList\" : 0,\n" + " \"hasBeenList\" : false,\n" + " \"hasBeenSingular\" : true\n" + " }, {\n" + " \"name\" : \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\",\n" + " \"direction\" : \"OUT\",\n" + " \"valueTypes\" : { },\n" + " \"referenceTypes\" : {\n" + " \"http://www.w3.org/2000/01/rdf-schema#Resource\" : 1\n" + " },\n" + " \"languages\" : [ ],\n" + " \"subjectsWithThisPredicate\" : 1,\n" + " \"subjectsWithThisPredicateAsList\" : 0,\n" + " \"hasBeenList\" : false,\n" + " \"hasBeenSingular\" : true\n" + " }, {\n" + " \"name\" : \"pred\",\n" + " \"direction\" : \"OUT\",\n" + " \"valueTypes\" : { },\n" + " \"referenceTypes\" : {\n" + " \"http://www.w3.org/2000/01/rdf-schema#Resource\" : 1\n" + " },\n" + " \"languages\" : [ ],\n" + " \"subjectsWithThisPredicate\" : 1,\n" + " \"subjectsWithThisPredicateAsList\" : 0,\n" + " \"hasBeenList\" : false,\n" + " \"hasBeenSingular\" : true\n" + " } ],\n" + " \"subjectsWithThisType\" : 1\n" + " },\n" + " \"http://www.w3.org/2000/01/rdf-schema#Resource\" : {\n" + " \"name\" : \"http://www.w3.org/2000/01/rdf-schema#Resource\",\n" + " \"predicates\" : [ {\n" + " \"name\" : \"pred\",\n" + " \"direction\" : \"IN\",\n" + " \"valueTypes\" : { },\n" + " \"referenceTypes\" : {\n" + " \"type\" : 1\n" + " },\n" + " \"languages\" : [ ],\n" + " \"subjectsWithThisPredicate\" : 1,\n" + " \"subjectsWithThisPredicateAsList\" : 0,\n" + " \"hasBeenList\" : false,\n" + " \"hasBeenSingular\" : true\n" + " }, {\n" + " \"name\" : \"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\",\n" + " \"direction\" : \"IN\",\n" + " \"valueTypes\" : { },\n" + " \"referenceTypes\" : {\n" + " \"type\" : 1\n" + " },\n" + " \"languages\" : [ ],\n" + " \"subjectsWithThisPredicate\" : 0,\n" + " \"subjectsWithThisPredicateAsList\" : 0,\n" + " \"hasBeenList\" : false,\n" + " \"hasBeenSingular\" : true\n" + " } ],\n" + " \"subjectsWithThisType\" : 1\n" + " }\n" + "}"));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class CreateMutationChangeLogTest method getAdditionsForListReturnsCreations.
@Test
public void getAdditionsForListReturnsCreations() throws Exception {
String addedValue1 = "newValue1";
String addedValue2 = "newValue2";
Map<Object, Object> creations = Maps.newHashMap();
creations.put(NAMES_FIELD, newArrayList(createPropertyInput(addedValue1), createPropertyInput(addedValue2)));
Map<Object, Object> entity = Maps.newHashMap();
entity.put("creations", creations);
CreateMutationChangeLog instance = new CreateMutationChangeLog(new Graph(GRAPH), SUBJECT, TYPE_URI, entity);
List<Change> adds = instance.getAdditions(dataSet).collect(toList());
assertThat(adds.size(), is(2));
assertThat(adds.get(0), is(likeChange().withValues(new Value(TYPE_URI, null)).oldValuesIsEmpty()));
assertThat(adds.get(1), is(likeChange().withValues(new Value(addedValue1, STRING), new Value(addedValue2, STRING)).oldValuesIsEmpty()));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class DeleteMutationChangeLogTest method getDeletionsReturnsDeletions.
@Test
public void getDeletionsReturnsDeletions() throws Exception {
String existingValue1 = "existingValue1";
String existingValue2 = "existingValue2";
DeleteMutationChangeLog instance = new DeleteMutationChangeLog(new Graph(GRAPH), SUBJECT, null);
valuesInQuadStore(NAMES_PRED, existingValue1, existingValue2);
List<Change> deletions = instance.getDeletions(dataSet).collect(toList());
assertThat(deletions.size(), is(1));
assertThat(deletions, contains(likeChange().valuesIsEmpty().withOldValues(new Value(existingValue1, STRING), new Value(existingValue2, STRING))));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class EditMutationChangeLogTest method getReplacementsForListReturnsReplacementsWithOldValues.
@Test
public void getReplacementsForListReturnsReplacementsWithOldValues() throws Exception {
String addedValue1 = "newValue1";
String addedValue2 = "newValue2";
String oldValue = "oldValue";
Map<Object, Object> replacements = Maps.newHashMap();
replacements.put(NAMES_FIELD, newArrayList(createPropertyInput(addedValue1), createPropertyInput(addedValue2)));
Map<Object, Object> entity = Maps.newHashMap();
entity.put("replacements", replacements);
EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
valuesInQuadStore(NAMES_PRED, oldValue);
List<Change> reps = instance.getReplacements(dataSet).collect(toList());
assertThat(reps.size(), is(1));
assertThat(reps, contains(likeChange().withValues(new Value(addedValue1, STRING), new Value(addedValue2, STRING)).withOldValues(new Value(oldValue, STRING))));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class EditMutationChangeLogTest method getAdditionsForListReturnsReplacements.
@Test
public void getAdditionsForListReturnsReplacements() throws Exception {
String addedValue1 = "newValue1";
String addedValue2 = "newValue2";
Map<Object, Object> replacements = Maps.newHashMap();
replacements.put(NAMES_FIELD, newArrayList(createPropertyInput(addedValue1), createPropertyInput(addedValue2)));
Map<Object, Object> entity = Maps.newHashMap();
entity.put("replacements", replacements);
EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
List<Change> adds = instance.getAdditions(dataSet).collect(toList());
assertThat(adds.size(), is(1));
assertThat(adds, contains(likeChange().withValues(new Value(addedValue1, STRING), new Value(addedValue2, STRING)).oldValuesIsEmpty()));
}
Aggregations