Source:
public void readWriteOffsets() throws Exception { KafkaConsumer<String, ChangeEvent> consumer = mock(KafkaConsumer.class); Uris uris = Uris.fromString("<LINK_0>").setEntityNamespaces(new long[]{0}); Instant startTime = Instant.ofEpochMilli(BEGIN_DATE); Collection<String> topics = ImmutableList.of("topictest", "othertopic"); when(consumer.partitionsFor(any())).thenAnswer(inv -> { String pName = inv.getArgumentAt(0, String.class); PartitionInfo pi = new PartitionInfo(pName, 0, null, null, null); return ImmutableList.of(pi); }); HttpClient httpClient = buildHttpClient(getHttpProxyHost(), getHttpProxyPort()); RdfClient rdfClient = buildRdfClient( url("/namespace/" + "wdq" + "/sparql"), httpClient ); try { rdfClient.update("CLEAR ALL"); cleanupPoller(); KafkaOffsetsRepository kafkaOffsetsRepository = new KafkaOffsetsRepository(uris.builder().build(), rdfClient); poller = new KafkaPoller(consumer, uris, startTime, 5, topics, kafkaOffsetsRepository); when(consumer.position(any())).thenReturn(1L, 2L, 3L, 4L); kafkaOffsetsRepository.store(poller.currentOffsets()); Map<TopicPartition, OffsetAndTimestamp> offsets = kafkaOffsetsRepository.load(startTime); assertThat(offsets.get(new TopicPartition("topictest", 0)).offset(), is(1L)); assertThat(offsets.get(new TopicPartition("othertopic", 0)).offset(), is(2L)); kafkaOffsetsRepository.store(poller.currentOffsets()); offsets = kafkaOffsetsRepository.load(startTime); assertThat(offsets.get(new TopicPartition("topictest", 0)).offset(), is(3L)); assertThat(offsets.get(new TopicPartition("othertopic", 0)).offset(), is(4L)); } finally { rdfClient.update("CLEAR ALL"); httpClient.stop(); if (poller != null) { poller.close(); } } }

Target:
public void readWriteOffsets() throws Exception { KafkaConsumer<String, ChangeEvent> consumer = mock(KafkaConsumer.class); Uris uris = Uris.fromString("<LINK_0>").setEntityNamespaces(new long[]{0}); Instant startTime = Instant.ofEpochMilli(BEGIN_DATE); Collection<String> topics = ImmutableList.of("topictest", "othertopic"); when(consumer.partitionsFor(any())).thenAnswer(inv -> { String pName = inv.getArgumentAt(0, String.class); PartitionInfo pi = new PartitionInfo(pName, 0, null, null, null); return ImmutableList.of(pi); }); HttpClient httpClient = buildHttpClient(getHttpProxyHost(), getHttpProxyPort()); RdfClient rdfClient = buildRdfClient( url("/namespace/wdq/sparql"), httpClient ); try { rdfClient.update("CLEAR ALL"); cleanupPoller(); KafkaOffsetsRepository kafkaOffsetsRepository = new KafkaOffsetsRepository(uris.builder().build(), rdfClient); poller = new KafkaPoller(consumer, uris, startTime, 5, topics, kafkaOffsetsRepository); when(consumer.position(any())).thenReturn(1L, 2L, 3L, 4L); kafkaOffsetsRepository.store(poller.currentOffsets()); Map<TopicPartition, OffsetAndTimestamp> offsets = kafkaOffsetsRepository.load(startTime); assertThat(offsets.get(new TopicPartition("topictest", 0)).offset(), is(1L)); assertThat(offsets.get(new TopicPartition("othertopic", 0)).offset(), is(2L)); kafkaOffsetsRepository.store(poller.currentOffsets()); offsets = kafkaOffsetsRepository.load(startTime); assertThat(offsets.get(new TopicPartition("topictest", 0)).offset(), is(3L)); assertThat(offsets.get(new TopicPartition("othertopic", 0)).offset(), is(4L)); } finally { rdfClient.update("CLEAR ALL"); httpClient.stop(); if (poller != null) { poller.close(); } } }