Search in sources :

Example 1 with LogsResponse

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);
}
Also used : LogsResponse(io.gravitee.rest.api.portal.rest.model.LogsResponse) Response(javax.ws.rs.core.Response) SearchLogResponse(io.gravitee.rest.api.model.log.SearchLogResponse) LogsResponse(io.gravitee.rest.api.portal.rest.model.LogsResponse) ApplicationRequestItem(io.gravitee.rest.api.model.log.ApplicationRequestItem) SearchLogResponse(io.gravitee.rest.api.model.log.SearchLogResponse) Links(io.gravitee.rest.api.portal.rest.model.Links) Test(org.junit.Test)

Example 2 with LogsResponse

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);
}
Also used : LogsResponse(io.gravitee.rest.api.portal.rest.model.LogsResponse) Response(javax.ws.rs.core.Response) SearchLogResponse(io.gravitee.rest.api.model.log.SearchLogResponse) LogsResponse(io.gravitee.rest.api.portal.rest.model.LogsResponse) LogQuery(io.gravitee.rest.api.model.analytics.query.LogQuery) Links(io.gravitee.rest.api.portal.rest.model.Links) HashMap(java.util.HashMap) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

SearchLogResponse (io.gravitee.rest.api.model.log.SearchLogResponse)2 Links (io.gravitee.rest.api.portal.rest.model.Links)2 LogsResponse (io.gravitee.rest.api.portal.rest.model.LogsResponse)2 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2 LogQuery (io.gravitee.rest.api.model.analytics.query.LogQuery)1 ApplicationRequestItem (io.gravitee.rest.api.model.log.ApplicationRequestItem)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)1