use of io.gravitee.rest.api.portal.rest.model.Links in project gravitee-management-rest-api by gravitee-io.
the class PaginationLinkTest method shouldHaveNoLinkWithTooBigPageNumber.
@Test
public void shouldHaveNoLinkWithTooBigPageNumber() {
Integer page = 20;
Integer size = 10;
Integer totalItems = 100;
Links links = paginatedResourceForTest.computePaginatedLinks(page, size, totalItems);
assertNull(links);
}
use of io.gravitee.rest.api.portal.rest.model.Links in project gravitee-management-rest-api by gravitee-io.
the class PaginationLinkTest method testGenericPaginatedLinks.
private void testGenericPaginatedLinks(Integer page, Integer size, Integer totalItems, String expectedSelf, String expectedFirst, String expectedPrev, String expectedNext, String expectedLast) {
Links links = paginatedResourceForTest.computePaginatedLinks(page, size, totalItems);
assertEquals(expectedSelf, links.getSelf());
assertEquals(expectedFirst, links.getFirst());
assertEquals(expectedPrev, links.getPrev());
assertEquals(expectedNext, links.getNext());
assertEquals(expectedLast, links.getLast());
}
use of io.gravitee.rest.api.portal.rest.model.Links in project gravitee-management-rest-api by gravitee-io.
the class ApplicationLogsResourceTest method shouldGetLogs.
@Test
public void shouldGetLogs() {
final Response response = target(APPLICATION).path("logs").queryParam("page", 1).queryParam("size", 10).queryParam("query", APPLICATION).queryParam("from", 0).queryParam("to", 100).queryParam("field", APPLICATION).queryParam("order", "ASC").request().get();
assertEquals(HttpStatusCode.OK_200, response.getStatus());
ArgumentCaptor<LogQuery> logQueryCaptor = ArgumentCaptor.forClass(LogQuery.class);
Mockito.verify(logsService).findByApplication(eq(APPLICATION), logQueryCaptor.capture());
final LogQuery logQuery = logQueryCaptor.getValue();
assertEquals(APPLICATION, logQuery.getField());
assertEquals(0, logQuery.getFrom());
assertEquals(1, logQuery.getPage());
assertEquals(APPLICATION, logQuery.getQuery());
assertEquals(10, logQuery.getSize());
assertEquals(100, logQuery.getTo());
assertTrue(logQuery.isOrder());
LogsResponse logsResponse = response.readEntity(LogsResponse.class);
assertEquals(2, logsResponse.getData().size());
Map<String, Map<String, Object>> logsMetadata = logsResponse.getMetadata();
assertEquals(2, logsMetadata.size());
assertEquals(APPLICATION, logsMetadata.get(APPLICATION).get(APPLICATION));
assertEquals(2, logsMetadata.get(AbstractResource.METADATA_DATA_KEY).get(AbstractResource.METADATA_DATA_TOTAL_KEY));
Links links = logsResponse.getLinks();
assertNotNull(links);
}
Aggregations