@Test public void testConvertListItem() { ApplicationRequestItem applicationRequestItem = new ApplicationRequestItem(); applicationRequestItem.setApi(LOG_API); applicationRequestItem.setId(LOG_ID); applicationRequestItem.setMethod(HttpMethod.CONNECT); applicationRequestItem.setPath(LOG_PATH); applicationRequestItem.setPlan(LOG_PLAN); applicationRequestItem.setResponseTime(1); applicationRequestItem.setStatus(1); applicationRequestItem.setTimestamp(1); applicationRequestItem.setTransactionId(LOG_TRANSACTION); applicationRequestItem.setUser(LOG_USER); Log log = logMapper.convert(applicationRequestItem); assertNotNull(log); assertEquals(LOG_API, log.getApi()); assertNull(log.getHost()); assertEquals(LOG_ID, log.getId()); assertNull(log.getMetadata()); assertEquals(io.gravitee.rest.api.portal.rest.model.HttpMethod.CONNECT, log.getMethod()); assertEquals(LOG_PATH, log.getPath()); assertEquals(LOG_PLAN, log.getPlan()); assertNull(log.getRequest()); assertNull(log.getRequestContentLength()); assertNull(log.getResponse()); assertNull(log.getResponseContentLength()); assertEquals(1L, log.getResponseTime().longValue()); assertNull(log.getSecurityToken()); assertNull(log.getSecurityType()); assertEquals(1, log.getStatus().intValue()); assertEquals(1L, log.getTimestamp().longValue()); assertEquals(LOG_TRANSACTION, log.getTransactionId()); assertEquals(LOG_USER, log.getUser()); }
public Log convert(ApplicationRequest applicationRequest) { final Log logItem = new Log(); logItem.setApi(applicationRequest.getApi()); logItem.setHost(applicationRequest.getHost()); logItem.setId(applicationRequest.getId()); logItem.setMetadata(applicationRequest.getMetadata() == null ? null : new HashMap(applicationRequest.getMetadata())); logItem.setMethod(HttpMethod.fromValue(applicationRequest.getMethod().name())); logItem.setPath(applicationRequest.getPath()); logItem.setPlan(applicationRequest.getPlan()); if (applicationRequest.getRequest() != null) { logItem.setRequest(new Request() .body(applicationRequest.getRequest().getBody()) .headers(applicationRequest.getRequest().getHeaders()) .method(HttpMethod.fromValue(applicationRequest.getRequest().getMethod().name())) .uri(applicationRequest.getRequest().getUri()) ); } logItem.setRequestContentLength(applicationRequest.getRequestContentLength()); if (applicationRequest.getResponse() != null) { logItem.setResponse(new Response() .body(applicationRequest.getResponse().getBody()) .status(applicationRequest.getResponse().getStatus()) .headers(applicationRequest.getResponse().getHeaders()) ); } logItem.setResponseContentLength(applicationRequest.getResponseContentLength()); logItem.setResponseTime(applicationRequest.getResponseTime()); logItem.setSecurityToken(applicationRequest.getSecurityToken()); logItem.setSecurityType(applicationRequest.getSecurityType()); logItem.setStatus(applicationRequest.getStatus()); logItem.setTimestamp(applicationRequest.getTimestamp()); logItem.setTransactionId(applicationRequest.getTransactionId()); logItem.setUser(applicationRequest.getUser()); return logItem; }
LogMapper { public Log convert(ApplicationRequest applicationRequest) { final Log logItem = new Log(); logItem.setApi(applicationRequest.getApi()); logItem.setHost(applicationRequest.getHost()); logItem.setId(applicationRequest.getId()); logItem.setMetadata(applicationRequest.getMetadata() == null ? null : new HashMap(applicationRequest.getMetadata())); logItem.setMethod(HttpMethod.fromValue(applicationRequest.getMethod().name())); logItem.setPath(applicationRequest.getPath()); logItem.setPlan(applicationRequest.getPlan()); if (applicationRequest.getRequest() != null) { logItem.setRequest(new Request() .body(applicationRequest.getRequest().getBody()) .headers(applicationRequest.getRequest().getHeaders()) .method(HttpMethod.fromValue(applicationRequest.getRequest().getMethod().name())) .uri(applicationRequest.getRequest().getUri()) ); } logItem.setRequestContentLength(applicationRequest.getRequestContentLength()); if (applicationRequest.getResponse() != null) { logItem.setResponse(new Response() .body(applicationRequest.getResponse().getBody()) .status(applicationRequest.getResponse().getStatus()) .headers(applicationRequest.getResponse().getHeaders()) ); } logItem.setResponseContentLength(applicationRequest.getResponseContentLength()); logItem.setResponseTime(applicationRequest.getResponseTime()); logItem.setSecurityToken(applicationRequest.getSecurityToken()); logItem.setSecurityType(applicationRequest.getSecurityType()); logItem.setStatus(applicationRequest.getStatus()); logItem.setTimestamp(applicationRequest.getTimestamp()); logItem.setTransactionId(applicationRequest.getTransactionId()); logItem.setUser(applicationRequest.getUser()); return logItem; } }
LogMapper { public Log convert(ApplicationRequest applicationRequest) { final Log logItem = new Log(); logItem.setApi(applicationRequest.getApi()); logItem.setHost(applicationRequest.getHost()); logItem.setId(applicationRequest.getId()); logItem.setMetadata(applicationRequest.getMetadata() == null ? null : new HashMap(applicationRequest.getMetadata())); logItem.setMethod(HttpMethod.fromValue(applicationRequest.getMethod().name())); logItem.setPath(applicationRequest.getPath()); logItem.setPlan(applicationRequest.getPlan()); if (applicationRequest.getRequest() != null) { logItem.setRequest(new Request() .body(applicationRequest.getRequest().getBody()) .headers(applicationRequest.getRequest().getHeaders()) .method(HttpMethod.fromValue(applicationRequest.getRequest().getMethod().name())) .uri(applicationRequest.getRequest().getUri()) ); } logItem.setRequestContentLength(applicationRequest.getRequestContentLength()); if (applicationRequest.getResponse() != null) { logItem.setResponse(new Response() .body(applicationRequest.getResponse().getBody()) .status(applicationRequest.getResponse().getStatus()) .headers(applicationRequest.getResponse().getHeaders()) ); } logItem.setResponseContentLength(applicationRequest.getResponseContentLength()); logItem.setResponseTime(applicationRequest.getResponseTime()); logItem.setSecurityToken(applicationRequest.getSecurityToken()); logItem.setSecurityType(applicationRequest.getSecurityType()); logItem.setStatus(applicationRequest.getStatus()); logItem.setTimestamp(applicationRequest.getTimestamp()); logItem.setTransactionId(applicationRequest.getTransactionId()); logItem.setUser(applicationRequest.getUser()); return logItem; }  }
LogMapper { public Log convert(ApplicationRequest applicationRequest) { final Log logItem = new Log(); logItem.setApi(applicationRequest.getApi()); logItem.setHost(applicationRequest.getHost()); logItem.setId(applicationRequest.getId()); logItem.setMetadata(applicationRequest.getMetadata() == null ? null : new HashMap(applicationRequest.getMetadata())); logItem.setMethod(HttpMethod.fromValue(applicationRequest.getMethod().name())); logItem.setPath(applicationRequest.getPath()); logItem.setPlan(applicationRequest.getPlan()); if (applicationRequest.getRequest() != null) { logItem.setRequest(new Request() .body(applicationRequest.getRequest().getBody()) .headers(applicationRequest.getRequest().getHeaders()) .method(HttpMethod.fromValue(applicationRequest.getRequest().getMethod().name())) .uri(applicationRequest.getRequest().getUri()) ); } logItem.setRequestContentLength(applicationRequest.getRequestContentLength()); if (applicationRequest.getResponse() != null) { logItem.setResponse(new Response() .body(applicationRequest.getResponse().getBody()) .status(applicationRequest.getResponse().getStatus()) .headers(applicationRequest.getResponse().getHeaders()) ); } logItem.setResponseContentLength(applicationRequest.getResponseContentLength()); logItem.setResponseTime(applicationRequest.getResponseTime()); logItem.setSecurityToken(applicationRequest.getSecurityToken()); logItem.setSecurityType(applicationRequest.getSecurityType()); logItem.setStatus(applicationRequest.getStatus()); logItem.setTimestamp(applicationRequest.getTimestamp()); logItem.setTransactionId(applicationRequest.getTransactionId()); logItem.setUser(applicationRequest.getUser()); return logItem; }  Log convert(ApplicationRequest applicationRequest); Log convert(ApplicationRequestItem applicationRequestItem); }
LogMapper { public Log convert(ApplicationRequest applicationRequest) { final Log logItem = new Log(); logItem.setApi(applicationRequest.getApi()); logItem.setHost(applicationRequest.getHost()); logItem.setId(applicationRequest.getId()); logItem.setMetadata(applicationRequest.getMetadata() == null ? null : new HashMap(applicationRequest.getMetadata())); logItem.setMethod(HttpMethod.fromValue(applicationRequest.getMethod().name())); logItem.setPath(applicationRequest.getPath()); logItem.setPlan(applicationRequest.getPlan()); if (applicationRequest.getRequest() != null) { logItem.setRequest(new Request() .body(applicationRequest.getRequest().getBody()) .headers(applicationRequest.getRequest().getHeaders()) .method(HttpMethod.fromValue(applicationRequest.getRequest().getMethod().name())) .uri(applicationRequest.getRequest().getUri()) ); } logItem.setRequestContentLength(applicationRequest.getRequestContentLength()); if (applicationRequest.getResponse() != null) { logItem.setResponse(new Response() .body(applicationRequest.getResponse().getBody()) .status(applicationRequest.getResponse().getStatus()) .headers(applicationRequest.getResponse().getHeaders()) ); } logItem.setResponseContentLength(applicationRequest.getResponseContentLength()); logItem.setResponseTime(applicationRequest.getResponseTime()); logItem.setSecurityToken(applicationRequest.getSecurityToken()); logItem.setSecurityType(applicationRequest.getSecurityType()); logItem.setStatus(applicationRequest.getStatus()); logItem.setTimestamp(applicationRequest.getTimestamp()); logItem.setTransactionId(applicationRequest.getTransactionId()); logItem.setUser(applicationRequest.getUser()); return logItem; }  Log convert(ApplicationRequest applicationRequest); Log convert(ApplicationRequestItem applicationRequestItem);  }