Search in sources :

Example 11 with PaginationWrapper

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

the class PaginationServiceTest method testPaginationPrevAndNext.

@Test
public void testPaginationPrevAndNext() {
    final PaginationService paginationService = new PaginationService();
    final PaginationWrapper paginationWrapper = paginationService.paginate(2, 3, "/schemas", (o, l) -> Lists.newArrayList("One", "Two", "Three", "Four"), () -> 1);
    Assert.assertEquals("/schemas?offset=5&limit=3", paginationWrapper.getLinks().getNext().get().getHref());
    Assert.assertEquals("/schemas?offset=0&limit=3", paginationWrapper.getLinks().getPrev().get().getHref());
}
Also used : PaginationWrapper(org.zalando.nakadi.domain.PaginationWrapper) Test(org.junit.Test)

Example 12 with PaginationWrapper

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

the class SubscriptionAT method testListSubscriptions.

@Test
public void testListSubscriptions() throws IOException {
    final String etName = createEventType().getName();
    final String filterApp = randomUUID();
    final Subscription sub1 = createSubscription(RandomSubscriptionBuilder.builder().withEventType(etName).withOwningApplication(filterApp).buildSubscriptionBase());
    final Subscription sub2 = createSubscription(RandomSubscriptionBuilder.builder().withEventType(etName).withOwningApplication(filterApp).buildSubscriptionBase());
    createSubscription(RandomSubscriptionBuilder.builder().withEventType(etName).buildSubscriptionBase());
    final PaginationWrapper expectedList = new PaginationWrapper(ImmutableList.of(sub2, sub1), new PaginationLinks());
    given().param("owning_application", filterApp).get("/subscriptions").then().statusCode(HttpStatus.SC_OK).body(JSON_HELPER.matchesObject(expectedList));
}
Also used : PaginationLinks(org.zalando.nakadi.domain.PaginationLinks) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Subscription(org.zalando.nakadi.domain.Subscription) NakadiTestUtils.createSubscription(org.zalando.nakadi.webservice.utils.NakadiTestUtils.createSubscription) PaginationWrapper(org.zalando.nakadi.domain.PaginationWrapper) Test(org.junit.Test)

Aggregations

PaginationWrapper (org.zalando.nakadi.domain.PaginationWrapper)12 Test (org.junit.Test)11 PaginationLinks (org.zalando.nakadi.domain.PaginationLinks)5 Subscription (org.zalando.nakadi.domain.Subscription)4 List (java.util.List)1 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)1 NakadiTestUtils.createSubscription (org.zalando.nakadi.webservice.utils.NakadiTestUtils.createSubscription)1