Search in sources :

Example 6 with Batch

use of org.wikidata.query.rdf.tool.change.RecentChangesPoller.Batch in project wikidata-query-rdf by wikimedia.

the class RecentChangesPollerUnitTest method delete.

/**
 * Check that delete is processed.
 * @throws RetryableException
 */
@Test
@SuppressWarnings("unchecked")
public void delete() throws RetryableException {
    // Use old date to remove backoff
    Instant startTime = Instant.now().minus(10, ChronoUnit.DAYS);
    // Build a result from wikibase with duplicate recent changes
    WikibaseApiError error = null;
    Continue aContinue = null;
    List<RecentChange> recentChanges = new ArrayList<>();
    recentChanges.add(new RecentChange(0L, "Q424242", Instant.now(), 0L, 42L, "log"));
    recentChanges.add(new RecentChange(0L, "Q424242", Instant.now(), 7L, 45L, "edit"));
    Query query = new Query(recentChanges);
    RecentChangeResponse result = new RecentChangeResponse(error, aContinue, query);
    firstBatchReturns(startTime, result);
    RecentChangesPoller poller = new RecentChangesPoller(repository, startTime, batchSize, new MetricRegistry());
    Batch batch = poller.firstBatch();
    List<Change> changes = batch.changes();
    assertThat(changes).hasSize(1);
    assertThat(changes.get(0).entityId()).isEqualTo("Q424242");
    assertThat(changes.get(0).offset()).isEqualTo(42L);
    assertThat(changes.get(0).revision()).isEqualTo(-1L);
}
Also used : Query(org.wikidata.query.rdf.tool.wikibase.RecentChangeResponse.Query) Instant(java.time.Instant) MetricRegistry(com.codahale.metrics.MetricRegistry) ArrayList(java.util.ArrayList) RecentChange(org.wikidata.query.rdf.tool.wikibase.RecentChangeResponse.RecentChange) Continue(org.wikidata.query.rdf.tool.wikibase.Continue) WikibaseApiError(org.wikidata.query.rdf.tool.wikibase.WikibaseApiError) RecentChange(org.wikidata.query.rdf.tool.wikibase.RecentChangeResponse.RecentChange) Batch(org.wikidata.query.rdf.tool.change.RecentChangesPoller.Batch) RecentChangeResponse(org.wikidata.query.rdf.tool.wikibase.RecentChangeResponse) Test(org.junit.Test)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)6 Instant (java.time.Instant)6 Batch (org.wikidata.query.rdf.tool.change.RecentChangesPoller.Batch)6 Continue (org.wikidata.query.rdf.tool.wikibase.Continue)6 RecentChangeResponse (org.wikidata.query.rdf.tool.wikibase.RecentChangeResponse)6 Query (org.wikidata.query.rdf.tool.wikibase.RecentChangeResponse.Query)6 WikibaseApiError (org.wikidata.query.rdf.tool.wikibase.WikibaseApiError)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 RecentChange (org.wikidata.query.rdf.tool.wikibase.RecentChangeResponse.RecentChange)5