use of io.gravitee.rest.api.portal.rest.model.LogsResponse in project gravitee-management-rest-api by gravitee-io.
the class ApplicationLogsResourceTest method shouldGetNoLogAndNoLink.
@Test
public void shouldGetNoLogAndNoLink() {
SearchLogResponse<ApplicationRequestItem> emptySearchResponse = new SearchLogResponse<>(0);
emptySearchResponse.setLogs(Collections.emptyList());
doReturn(emptySearchResponse).when(logsService).findByApplication(eq(APPLICATION), any());
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());
LogsResponse logsResponse = response.readEntity(LogsResponse.class);
assertEquals(0, logsResponse.getData().size());
Links links = logsResponse.getLinks();
assertNull(links);
}
use of io.gravitee.rest.api.portal.rest.model.LogsResponse 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