use of com.jayway.restassured.http.ContentType.JSON 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());
}
use of com.jayway.restassured.http.ContentType.JSON in project nakadi by zalando.
the class SubscriptionAT method testSubscriptionWithManyEventTypesIsNotCreated.
@Test
public void testSubscriptionWithManyEventTypesIsNotCreated() {
final List<String> eventTypes = IntStream.range(0, 31).mapToObj(i -> createEventType()).map(et -> et.getName()).collect(Collectors.toList());
final String subscription = "{\"owning_application\":\"app\",\"event_types\":" + "[" + eventTypes.stream().map(et -> "\"" + et + "\"").collect(Collectors.joining(",")) + "]}";
final Response response = given().body(subscription).contentType(JSON).post(SUBSCRIPTIONS_URL);
// assert response
response.then().statusCode(HttpStatus.SC_UNPROCESSABLE_ENTITY).contentType(JSON).body("title", equalTo("Unprocessable Entity")).body("detail", equalTo("total partition count for subscription is 31, but the maximum partition count is 30"));
}
use of com.jayway.restassured.http.ContentType.JSON in project nakadi by zalando.
the class SubscriptionAT method testSubscriptionWithManyEventTypesIsCreated.
@Test
public void testSubscriptionWithManyEventTypesIsCreated() throws IOException {
final List<String> eventTypes = IntStream.range(0, 10).mapToObj(i -> createEventType()).map(EventTypeBase::getName).collect(Collectors.toList());
final String subscription = "{\"owning_application\":\"app\",\"event_types\":" + "[" + eventTypes.stream().map(et -> "\"" + et + "\"").collect(Collectors.joining(",")) + "]}";
final Response response = given().body(subscription).contentType(JSON).post(SUBSCRIPTIONS_URL);
// assert response
response.then().statusCode(HttpStatus.SC_CREATED).contentType(JSON);
final Subscription gotSubscription = MAPPER.readValue(response.print(), Subscription.class);
Assert.assertNotNull(gotSubscription.getId());
}
Aggregations