@Test public void testSendStructuredEventWhenRestParamIsEmptyMapThenParamsAreInvalid() { RestRequestDetails restRequestDetails = new RestRequestDetails(); RestResponseDetails restResponseDetails = new RestResponseDetails(); underTest.sendStructuredEvent(restRequestDetails, restResponseDetails, Collections.emptyMap(), 0L, null); verify(structuredEventClient, never()).sendStructuredEvent(any()); }
public void sendStructuredEvent(RestRequestDetails restRequest, RestResponseDetails restResponse, Map<String, String> restParams, Long requestTime, String responseBody) { boolean valid = checkRestParams(restParams); try { if (!valid) { LOGGER.debug("Cannot create structured event, because rest params are invalid."); return; } restResponse.setBody(responseBody); RestCallDetails restCall = new RestCallDetails(); restCall.setRestRequest(restRequest); restCall.setRestResponse(restResponse); restCall.setDuration(System.currentTimeMillis() - requestTime); Map<String, String> params = restCommonService.collectCrnAndNameIfPresent(restCall, null, restParams, RESOURCE_NAME, RESOURCE_CRN); dataCollector.fetchDataFromDbIfNeed(params); restParams.putAll(params); CDPOperationDetails cdpOperationDetails = restEventFilterRelatedObjectFactory.createCDPOperationDetails(restParams, requestTime); CDPStructuredRestCallEvent structuredEvent = new CDPStructuredRestCallEvent(cdpOperationDetails, restCall, null, null); structuredEventClient.sendStructuredEvent(structuredEvent); } catch (Exception ex) { LOGGER.warn("Failed to send structured event: " + ex.getMessage(), ex); } }
StructuredEventFilterUtil { public void sendStructuredEvent(RestRequestDetails restRequest, RestResponseDetails restResponse, Map<String, String> restParams, Long requestTime, String responseBody) { boolean valid = checkRestParams(restParams); try { if (!valid) { LOGGER.debug("Cannot create structured event, because rest params are invalid."); return; } restResponse.setBody(responseBody); RestCallDetails restCall = new RestCallDetails(); restCall.setRestRequest(restRequest); restCall.setRestResponse(restResponse); restCall.setDuration(System.currentTimeMillis() - requestTime); Map<String, String> params = restCommonService.collectCrnAndNameIfPresent(restCall, null, restParams, RESOURCE_NAME, RESOURCE_CRN); dataCollector.fetchDataFromDbIfNeed(params); restParams.putAll(params); CDPOperationDetails cdpOperationDetails = restEventFilterRelatedObjectFactory.createCDPOperationDetails(restParams, requestTime); CDPStructuredRestCallEvent structuredEvent = new CDPStructuredRestCallEvent(cdpOperationDetails, restCall, null, null); structuredEventClient.sendStructuredEvent(structuredEvent); } catch (Exception ex) { LOGGER.warn("Failed to send structured event: " + ex.getMessage(), ex); } } }
StructuredEventFilterUtil { public void sendStructuredEvent(RestRequestDetails restRequest, RestResponseDetails restResponse, Map<String, String> restParams, Long requestTime, String responseBody) { boolean valid = checkRestParams(restParams); try { if (!valid) { LOGGER.debug("Cannot create structured event, because rest params are invalid."); return; } restResponse.setBody(responseBody); RestCallDetails restCall = new RestCallDetails(); restCall.setRestRequest(restRequest); restCall.setRestResponse(restResponse); restCall.setDuration(System.currentTimeMillis() - requestTime); Map<String, String> params = restCommonService.collectCrnAndNameIfPresent(restCall, null, restParams, RESOURCE_NAME, RESOURCE_CRN); dataCollector.fetchDataFromDbIfNeed(params); restParams.putAll(params); CDPOperationDetails cdpOperationDetails = restEventFilterRelatedObjectFactory.createCDPOperationDetails(restParams, requestTime); CDPStructuredRestCallEvent structuredEvent = new CDPStructuredRestCallEvent(cdpOperationDetails, restCall, null, null); structuredEventClient.sendStructuredEvent(structuredEvent); } catch (Exception ex) { LOGGER.warn("Failed to send structured event: " + ex.getMessage(), ex); } }  }
StructuredEventFilterUtil { public void sendStructuredEvent(RestRequestDetails restRequest, RestResponseDetails restResponse, Map<String, String> restParams, Long requestTime, String responseBody) { boolean valid = checkRestParams(restParams); try { if (!valid) { LOGGER.debug("Cannot create structured event, because rest params are invalid."); return; } restResponse.setBody(responseBody); RestCallDetails restCall = new RestCallDetails(); restCall.setRestRequest(restRequest); restCall.setRestResponse(restResponse); restCall.setDuration(System.currentTimeMillis() - requestTime); Map<String, String> params = restCommonService.collectCrnAndNameIfPresent(restCall, null, restParams, RESOURCE_NAME, RESOURCE_CRN); dataCollector.fetchDataFromDbIfNeed(params); restParams.putAll(params); CDPOperationDetails cdpOperationDetails = restEventFilterRelatedObjectFactory.createCDPOperationDetails(restParams, requestTime); CDPStructuredRestCallEvent structuredEvent = new CDPStructuredRestCallEvent(cdpOperationDetails, restCall, null, null); structuredEventClient.sendStructuredEvent(structuredEvent); } catch (Exception ex) { LOGGER.warn("Failed to send structured event: " + ex.getMessage(), ex); } }  InputStream logInboundEntity(StringBuilder content, InputStream stream, Charset charset); void sendStructuredEvent(RestRequestDetails restRequest, RestResponseDetails restResponse, Map<String, String> restParams, Long requestTime,
            String responseBody); }
StructuredEventFilterUtil { public void sendStructuredEvent(RestRequestDetails restRequest, RestResponseDetails restResponse, Map<String, String> restParams, Long requestTime, String responseBody) { boolean valid = checkRestParams(restParams); try { if (!valid) { LOGGER.debug("Cannot create structured event, because rest params are invalid."); return; } restResponse.setBody(responseBody); RestCallDetails restCall = new RestCallDetails(); restCall.setRestRequest(restRequest); restCall.setRestResponse(restResponse); restCall.setDuration(System.currentTimeMillis() - requestTime); Map<String, String> params = restCommonService.collectCrnAndNameIfPresent(restCall, null, restParams, RESOURCE_NAME, RESOURCE_CRN); dataCollector.fetchDataFromDbIfNeed(params); restParams.putAll(params); CDPOperationDetails cdpOperationDetails = restEventFilterRelatedObjectFactory.createCDPOperationDetails(restParams, requestTime); CDPStructuredRestCallEvent structuredEvent = new CDPStructuredRestCallEvent(cdpOperationDetails, restCall, null, null); structuredEventClient.sendStructuredEvent(structuredEvent); } catch (Exception ex) { LOGGER.warn("Failed to send structured event: " + ex.getMessage(), ex); } }  InputStream logInboundEntity(StringBuilder content, InputStream stream, Charset charset); void sendStructuredEvent(RestRequestDetails restRequest, RestResponseDetails restResponse, Map<String, String> restParams, Long requestTime,
            String responseBody);  }