use of org.wikidata.query.rdf.updater.MutationEventDataGenerator in project wikidata-query-rdf by wikimedia.
the class UpdatePatchAccumulatorUnitTest method test_leak_data_from_accumulator.
@Test
public void test_leak_data_from_accumulator() {
MutationEventDataGenerator eventGenerator = new MutationEventDataGenerator(serializer, RDFFormat.TURTLE.getDefaultMIMEType(), 300);
PatchAccumulator accumulator = new PatchAccumulator(deserializer);
List<MutationEventData> events = eventGenerator.diffEvent(metaGenerator("Q1"), "Q1", 1, Instant.EPOCH, singletonList(stmt("uri:added-Q1")), singletonList(stmt("uri:deleted-Q1")), asList(stmt("uri:linked-shared"), stmt("uri:")), singletonList(stmt("uri:unlinked-shared")));
events.forEach(accumulator::accumulate);
ConsumerPatch expectedPatch = accumulator.asPatch();
List<MutationEventData> events2 = eventGenerator.diffEvent(metaGenerator("Q2"), "Q2", 1, Instant.EPOCH, asList(stmt("uri:added-Q2"), stmt("uri:added-Q1")), singletonList(stmt("uri:deleted-Q1")), asList(stmt("uri:linked-shared"), stmt("uri:")), singletonList(stmt("uri:unlinked-shared")));
assertThatThrownBy(() -> events2.forEach(accumulator::accumulate)).isInstanceOf(IllegalArgumentException.class);
ConsumerPatch secondPatch = accumulator.asPatch();
assertThat(secondPatch).isEqualTo(expectedPatch);
}
use of org.wikidata.query.rdf.updater.MutationEventDataGenerator in project wikidata-query-rdf by wikimedia.
the class UpdatePatchAccumulatorUnitTest method test_reconcile_operation_can_be_accumulated.
@Test
public void test_reconcile_operation_can_be_accumulated() {
PatchAccumulator accumulator = new PatchAccumulator(deserializer);
MutationEventDataGenerator bigChunkEventGenerator = new MutationEventDataGenerator(serializer, RDFFormat.TURTLE.getDefaultMIMEType(), Integer.MAX_VALUE);
accumulateDiff(accumulator, "Q1", asList(stmt("uri:added-1"), stmt("uri:added-1")), asList(stmt("uri:removed-1"), stmt("uri:removed-1")), asList(stmt("uri:linked-shared"), stmt("uri:linked-shared-1")), asList(stmt("uri:unlinked-shared"), stmt("uri:unlinked-shared-1")), bigChunkEventGenerator);
accumulateDiff(accumulator, "Q2", asList(stmt("uri:added-2"), stmt("uri:added-2")), asList(stmt("uri:removed-2"), stmt("uri:removed-2")), asList(stmt("uri:linked-shared"), stmt("uri:linked-shared-2")), asList(stmt("uri:unlinked-shared"), stmt("uri:unlinked-shared-2")), bigChunkEventGenerator);
accumulateReconciliation(accumulator, "Q1", singletonList(stmt("uri:reconciled-1")));
ConsumerPatch consumerPatch = accumulator.asPatch();
assertThat(consumerPatch.getAdded()).containsExactlyInAnyOrder(stmt("uri:added-2"));
assertThat(consumerPatch.getRemoved()).containsExactlyInAnyOrder(stmt("uri:removed-2"));
assertThat(consumerPatch.getLinkedSharedElements()).containsExactlyInAnyOrder(stmt("uri:linked-shared"), stmt("uri:linked-shared-2"));
assertThat(consumerPatch.getUnlinkedSharedElements()).contains(stmt("uri:unlinked-shared"), stmt("uri:unlinked-shared-2"));
assertThat(consumerPatch.getReconciliations()).containsOnlyKeys("Q1");
assertThat(consumerPatch.getReconciliations()).containsValue(singletonList(stmt("uri:reconciled-1")));
}
use of org.wikidata.query.rdf.updater.MutationEventDataGenerator in project wikidata-query-rdf by wikimedia.
the class UpdatePatchAccumulatorUnitTest method test_duplicated_values_can_be_accumulated.
@Test
public void test_duplicated_values_can_be_accumulated() {
PatchAccumulator accumulator = new PatchAccumulator(deserializer);
MutationEventDataGenerator bigChunkEventGenerator = new MutationEventDataGenerator(serializer, RDFFormat.TURTLE.getDefaultMIMEType(), Integer.MAX_VALUE);
accumulateDiff(accumulator, "Q1", asList(stmt("uri:added-1"), stmt("uri:added-1")), asList(stmt("uri:removed-1"), stmt("uri:removed-1")), asList(stmt("uri:linked-shared"), stmt("uri:linked-shared")), asList(stmt("uri:unlinked-shared"), stmt("uri:unlinked-shared")), bigChunkEventGenerator);
ConsumerPatch actual = accumulator.asPatch();
assertThat(actual.getAdded()).containsExactlyInAnyOrder(stmt("uri:added-1"));
assertThat(actual.getRemoved()).contains(stmt("uri:removed-1"));
assertThat(actual.getLinkedSharedElements()).containsExactlyInAnyOrder(stmt("uri:linked-shared"));
assertThat(actual.getUnlinkedSharedElements()).contains(stmt("uri:unlinked-shared"));
}
Aggregations