@Test public void getAllTripssMiddlePageTest() throws Exception { Page<Trip> users = SERVICE.getAllTrips(2, 5); assertTrue(users.hasContent()); assertEquals(5, users.getNumberOfElements()); PageInfo pi = users.getPageInfo(); assertEquals(2, pi.getPageNumber()); assertEquals(5, pi.getPageSize()); assertEquals(17, pi.getTotalElements()); assertEquals(4, pi.getTotalPages()); assertTrue(pi.hasNextPage()); assertTrue(pi.hasPreviousPage()); }
@Test public void getAllNonRemovedUsersFirstPageTest() throws Exception { Page<Trip> users = SERVICE.getAllNonRemovedTrips(1, 5); assertTrue(users.hasContent()); assertEquals(5, users.getNumberOfElements()); PageInfo pi = users.getPageInfo(); assertEquals(1, pi.getPageNumber()); assertEquals(5, pi.getPageSize()); assertEquals(13, pi.getTotalElements()); assertEquals(3, pi.getTotalPages()); assertTrue(pi.hasNextPage()); assertFalse(pi.hasPreviousPage()); }
@Test public void getAllTripsFirstPageTest() throws Exception { Page<Trip> users = SERVICE.getAllTrips(1, 5); assertTrue(users.hasContent()); assertEquals(5, users.getNumberOfElements()); PageInfo pi = users.getPageInfo(); assertEquals(1, pi.getPageNumber()); assertEquals(5, pi.getPageSize()); assertEquals(17, pi.getTotalElements()); assertEquals(4, pi.getTotalPages()); assertTrue(pi.hasNextPage()); assertFalse(pi.hasPreviousPage()); List<Trip> content = users.getContent(); assertEquals("Dunaj", content.get(0).getTitle()); assertEquals("Plezanje - Kotečnik", content.get(4).getTitle()); }
@Test public void getAllUsersLeadingTripsThatExistAndHaveNonActiveTest() throws Exception { Page<Trip> trips = SERVICE.getAllLeadingTrips("karlip", 1, 10); assertThat(trips.getContent().size()).isEqualTo(3); assertThat(trips.getPageInfo().getTotalElements()).isEqualTo(3); }
@Test public void getAllUsersLeadingTripsThatDontExistTest() throws Exception { Page<Trip> trips = SERVICE.getAllLeadingTrips("JohnnyC", 1, 10); assertThat(trips.getContent()).isEmpty(); assertThat(trips.getPageInfo().getTotalElements()).isEqualTo(0); }