use of org.zalando.nakadi.domain.PaginationWrapper in project nakadi by zalando.
the class SubscriptionControllerTest method whenListSubscriptionsWithQueryParamsThenOk.
@Test
public void whenListSubscriptionsWithQueryParamsThenOk() throws Exception {
final List<Subscription> subscriptions = createRandomSubscriptions(10);
when(subscriptionRepository.listSubscriptions(any(), any(), anyInt(), anyInt())).thenReturn(subscriptions);
final PaginationWrapper subscriptionList = new PaginationWrapper(subscriptions, new PaginationLinks());
getSubscriptions(ImmutableSet.of("et1", "et2"), "app", 0, 30).andExpect(status().isOk()).andExpect(content().string(TestUtils.JSON_TEST_HELPER.matchesObject(subscriptionList)));
verify(subscriptionRepository, times(1)).listSubscriptions(ImmutableSet.of("et1", "et2"), Optional.of("app"), 0, 30);
}
use of org.zalando.nakadi.domain.PaginationWrapper in project nakadi by zalando.
the class SubscriptionControllerTest method whenListSubscriptionsThenPaginationIsOk.
@Test
public void whenListSubscriptionsThenPaginationIsOk() throws Exception {
final List<Subscription> subscriptions = createRandomSubscriptions(10);
when(subscriptionRepository.listSubscriptions(any(), any(), anyInt(), anyInt())).thenReturn(subscriptions);
final PaginationLinks.Link prevLink = new PaginationLinks.Link("/subscriptions?event_type=et1&event_type=et2&owning_application=app&offset=0&limit=10");
final PaginationLinks.Link nextLink = new PaginationLinks.Link("/subscriptions?event_type=et1&event_type=et2&owning_application=app&offset=15&limit=10");
final PaginationLinks links = new PaginationLinks(Optional.of(prevLink), Optional.of(nextLink));
final PaginationWrapper expectedResult = new PaginationWrapper(subscriptions, links);
getSubscriptions(ImmutableSet.of("et1", "et2"), "app", 5, 10).andExpect(status().isOk()).andExpect(content().string(TestUtils.JSON_TEST_HELPER.matchesObject(expectedResult)));
}
use of org.zalando.nakadi.domain.PaginationWrapper in project nakadi by zalando.
the class PaginationServiceTest method testPaginationPrev.
@Test
public void testPaginationPrev() {
final PaginationService paginationService = new PaginationService();
final PaginationWrapper paginationWrapper = paginationService.paginate(2, 5, "/schemas", (o, l) -> Collections.emptyList(), () -> 1);
Assert.assertFalse(paginationWrapper.getLinks().getNext().isPresent());
Assert.assertFalse(paginationWrapper.getLinks().getPrev().isPresent());
}
use of org.zalando.nakadi.domain.PaginationWrapper in project nakadi by zalando.
the class PaginationServiceTest method testPaginationPrev3.
@Test
public void testPaginationPrev3() {
final PaginationService paginationService = new PaginationService();
final PaginationWrapper paginationWrapper = paginationService.paginate(2, 5, "/schemas", (o, l) -> Collections.emptyList(), () -> 2);
Assert.assertFalse(paginationWrapper.getLinks().getNext().isPresent());
Assert.assertFalse(paginationWrapper.getLinks().getPrev().isPresent());
}
use of org.zalando.nakadi.domain.PaginationWrapper in project nakadi by zalando.
the class PaginationServiceTest method testPaginationNext.
@Test
public void testPaginationNext() {
final PaginationService paginationService = new PaginationService();
final PaginationWrapper paginationWrapper = paginationService.paginate(0, 3, "/schemas", (o, l) -> Lists.newArrayList("One", "Two", "Three", "Four"), () -> 1);
Assert.assertEquals("/schemas?offset=3&limit=3", paginationWrapper.getLinks().getNext().get().getHref());
Assert.assertFalse(paginationWrapper.getLinks().getPrev().isPresent());
}
Aggregations