use of org.apache.http.HttpStatus.SC_NO_CONTENT in project nakadi by zalando.
the class HilaAT method whenResetCursorsThenStreamFromResetCursorOffset.
@Test(timeout = 15000)
public void whenResetCursorsThenStreamFromResetCursorOffset() throws Exception {
publishEvents(eventType.getName(), 20, i -> "{\"foo\":\"bar\"}");
final TestStreamingClient client1 = TestStreamingClient.create(subscription.getId()).start();
waitFor(() -> assertThat(client1.getBatches(), hasSize(10)));
int statusCode = commitCursors(subscription.getId(), Collections.singletonList(client1.getBatches().get(9).getCursor()), client1.getSessionId());
Assert.assertEquals(SC_NO_CONTENT, statusCode);
final List<SubscriptionCursor> resetCursors = Collections.singletonList(client1.getBatches().get(4).getCursor());
statusCode = given().body(MAPPER.writeValueAsString(new ItemsWrapper<>(resetCursors))).contentType(JSON).patch("/subscriptions/{id}/cursors", subscription.getId()).getStatusCode();
Assert.assertEquals(SC_NO_CONTENT, statusCode);
Assert.assertFalse(client1.isRunning());
Assert.assertTrue(client1.getBatches().stream().anyMatch(streamBatch -> streamBatch.getMetadata() != null && streamBatch.getMetadata().getDebug().equals("Resetting subscription cursors")));
final TestStreamingClient client2 = TestStreamingClient.create(subscription.getId()).start();
waitFor(() -> assertThat(client2.getBatches(), hasSize(10)));
Assert.assertEquals("001-0001-000000000000000005", client2.getBatches().get(0).getCursor().getOffset());
}
Aggregations