use of io.gravitee.rest.api.model.log.extended.Response in project gravitee-management-rest-api by gravitee-io.
the class LogMapperTest method testConvertFull.
@Test
public void testConvertFull() {
// init
ApplicationRequest applicationRequest = new ApplicationRequest();
applicationRequest.setApi(LOG_API);
applicationRequest.setHost(LOG_HOST);
applicationRequest.setId(LOG_APPLICATION);
Map<String, Map<String, String>> metadata = new HashMap<String, Map<String, String>>();
HashMap<String, String> appMetadata = new HashMap<String, String>();
appMetadata.put(LOG_API, LOG_API);
metadata.put(LOG_APPLICATION, appMetadata);
applicationRequest.setMetadata(metadata);
applicationRequest.setMethod(HttpMethod.CONNECT);
applicationRequest.setPath(LOG_PATH);
applicationRequest.setPlan(LOG_PLAN);
Request request = new Request();
request.setBody(LOG_REQUEST_BODY);
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.add(HttpHeaders.ACCEPT, LOG_ID);
request.setHeaders(requestHeaders);
request.setMethod(HttpMethod.CONNECT);
request.setUri(LOG_REQUEST_URI);
applicationRequest.setRequest(request);
applicationRequest.setRequestContentLength(1L);
Response response = new Response();
response.setBody(LOG_RESPONSE_BODY);
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.add(HttpHeaders.ACCEPT_CHARSET, LOG_ID);
response.setHeaders(responseHeaders);
response.setStatus(1);
applicationRequest.setResponse(response);
applicationRequest.setResponseContentLength(1L);
applicationRequest.setResponseTime(1);
applicationRequest.setSecurityToken(LOG_SECURITY_TOKEN);
applicationRequest.setSecurityType(LOG_SECURITY_TYPE);
applicationRequest.setStatus(1);
applicationRequest.setTimestamp(1);
applicationRequest.setTransactionId(LOG_TRANSACTION);
applicationRequest.setUser(LOG_USER);
// Test
Log log = logMapper.convert(applicationRequest);
assertNotNull(log);
assertEquals(LOG_API, log.getApi());
assertEquals(LOG_HOST, log.getHost());
assertEquals(LOG_APPLICATION, log.getId());
assertEquals(metadata, log.getMetadata());
assertEquals(io.gravitee.rest.api.portal.rest.model.HttpMethod.CONNECT, log.getMethod());
assertEquals(LOG_PATH, log.getPath());
assertEquals(LOG_PLAN, log.getPlan());
final io.gravitee.rest.api.portal.rest.model.Request logRequest = log.getRequest();
assertNotNull(logRequest);
assertEquals(LOG_REQUEST_BODY, logRequest.getBody());
assertEquals(requestHeaders, logRequest.getHeaders());
assertEquals(io.gravitee.rest.api.portal.rest.model.HttpMethod.CONNECT, logRequest.getMethod());
assertEquals(LOG_REQUEST_URI, logRequest.getUri());
assertEquals(1L, log.getRequestContentLength().longValue());
final io.gravitee.rest.api.portal.rest.model.Response logResponse = log.getResponse();
assertNotNull(logResponse);
assertEquals(LOG_RESPONSE_BODY, logResponse.getBody());
assertEquals(responseHeaders, logResponse.getHeaders());
assertEquals(1, logResponse.getStatus().intValue());
assertEquals(1L, log.getResponseContentLength().longValue());
assertEquals(1L, log.getResponseTime().longValue());
assertEquals(LOG_SECURITY_TOKEN, log.getSecurityToken());
assertEquals(LOG_SECURITY_TYPE, log.getSecurityType());
assertEquals(1, log.getStatus().intValue());
assertEquals(1L, log.getTimestamp().longValue());
assertEquals(LOG_TRANSACTION, log.getTransactionId());
assertEquals(LOG_USER, log.getUser());
}
use of io.gravitee.rest.api.model.log.extended.Response in project gravitee-management-rest-api by gravitee-io.
the class LogsServiceImpl method createResponse.
private Response createResponse(io.gravitee.repository.log.model.Response repoResponse) {
if (repoResponse == null) {
return null;
}
Response response = new Response();
response.setStatus(repoResponse.getStatus());
response.setHeaders(repoResponse.getHeaders());
response.setBody(repoResponse.getBody());
return response;
}
Aggregations