Search in sources :

Example 6 with ItemsWrapper

use of org.zalando.nakadi.domain.ItemsWrapper in project nakadi by zalando.

the class CursorsControllerTest method whenCommitInvalidCursorsThenOk.

@Test
public void whenCommitInvalidCursorsThenOk() throws Exception {
    when(cursorsService.commitCursors(any(), any(), any())).thenReturn(DUMMY_CURSORS.stream().map(v -> Boolean.FALSE).collect(Collectors.toList()));
    final ItemsWrapper<CursorCommitResult> expectation = new ItemsWrapper<>(DUMMY_CURSORS.stream().map(c -> new CursorCommitResult(c, false)).collect(Collectors.toList()));
    postCursors(DUMMY_CURSORS).andExpect(status().isOk()).andExpect(content().string(TestUtils.JSON_TEST_HELPER.matchesObject(expectation)));
}
Also used : CursorCommitResult(org.zalando.nakadi.view.CursorCommitResult) ItemsWrapper(org.zalando.nakadi.domain.ItemsWrapper) Test(org.junit.Test)

Example 7 with ItemsWrapper

use of org.zalando.nakadi.domain.ItemsWrapper in project nakadi by zalando.

the class SubscriptionAT method whenStatsOnNotInitializedSubscriptionThanCorrectResponse.

@Test
public void whenStatsOnNotInitializedSubscriptionThanCorrectResponse() throws IOException {
    final String et = createEventType().getName();
    final Subscription s = createSubscriptionForEventType(et);
    final Response response = when().get("/subscriptions/{sid}/stats", s.getId()).thenReturn();
    final ItemsWrapper<SubscriptionEventTypeStats> statsItems = MAPPER.readValue(response.print(), new TypeReference<ItemsWrapper<SubscriptionEventTypeStats>>() {
    });
    Assert.assertEquals(1, statsItems.getItems().size());
    final SubscriptionEventTypeStats stats = statsItems.getItems().get(0);
    Assert.assertEquals(et, stats.getEventType());
    Assert.assertEquals(1, stats.getPartitions().size());
    for (final SubscriptionEventTypeStats.Partition partition : stats.getPartitions()) {
        Assert.assertNotNull(partition);
        Assert.assertNotNull(partition.getPartition());
        Assert.assertEquals("", partition.getStreamId());
        Assert.assertNull(partition.getUnconsumedEvents());
        Assert.assertEquals(partition.getState(), "unassigned");
    }
}
Also used : Response(com.jayway.restassured.response.Response) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) SubscriptionEventTypeStats(org.zalando.nakadi.domain.SubscriptionEventTypeStats) Subscription(org.zalando.nakadi.domain.Subscription) NakadiTestUtils.createSubscription(org.zalando.nakadi.webservice.utils.NakadiTestUtils.createSubscription) ItemsWrapper(org.zalando.nakadi.domain.ItemsWrapper) Test(org.junit.Test)

Aggregations

ItemsWrapper (org.zalando.nakadi.domain.ItemsWrapper)7 Subscription (org.zalando.nakadi.domain.Subscription)6 Test (org.junit.Test)5 ImmutableList (com.google.common.collect.ImmutableList)4 List (java.util.List)4 EventType (org.zalando.nakadi.domain.EventType)4 SubscriptionEventTypeStats (org.zalando.nakadi.domain.SubscriptionEventTypeStats)4 SubscriptionCursor (org.zalando.nakadi.view.SubscriptionCursor)4 NakadiTestUtils.createSubscription (org.zalando.nakadi.webservice.utils.NakadiTestUtils.createSubscription)3 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 RestAssured.given (com.jayway.restassured.RestAssured.given)2 RestAssured.when (com.jayway.restassured.RestAssured.when)2 JSON (com.jayway.restassured.http.ContentType.JSON)2 Response (com.jayway.restassured.response.Response)2 IOException (java.io.IOException)2 MessageFormat.format (java.text.MessageFormat.format)2 Collectors (java.util.stream.Collectors)2 HttpStatus (org.apache.http.HttpStatus)2 Assert (org.junit.Assert)2