Search in sources :

Example 1 with MutationEventDataGenerator

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);
}
Also used : MutationEventDataGenerator(org.wikidata.query.rdf.updater.MutationEventDataGenerator) MutationEventData(org.wikidata.query.rdf.updater.MutationEventData) ConsumerPatch(org.wikidata.query.rdf.tool.rdf.ConsumerPatch) Test(org.junit.Test)

Example 2 with MutationEventDataGenerator

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")));
}
Also used : MutationEventDataGenerator(org.wikidata.query.rdf.updater.MutationEventDataGenerator) ConsumerPatch(org.wikidata.query.rdf.tool.rdf.ConsumerPatch) Test(org.junit.Test)

Example 3 with MutationEventDataGenerator

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"));
}
Also used : MutationEventDataGenerator(org.wikidata.query.rdf.updater.MutationEventDataGenerator) ConsumerPatch(org.wikidata.query.rdf.tool.rdf.ConsumerPatch) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 ConsumerPatch (org.wikidata.query.rdf.tool.rdf.ConsumerPatch)3 MutationEventDataGenerator (org.wikidata.query.rdf.updater.MutationEventDataGenerator)3 MutationEventData (org.wikidata.query.rdf.updater.MutationEventData)1