@Test public void a_fetch_report__triggers_rest_tempate_with_correct_params() { @SuppressWarnings("unchecked") ResponseEntity<String> response = mock(ResponseEntity.class); when(template.getForEntity(eq("baseURL/api/1.0/scans/report/netsparkerId?Type=Vulnerabilities&Format=Xml"), eq(String.class))).thenReturn(response); when(response.getStatusCode()).thenReturn(HttpStatus.OK); adapterToTest.fetchReport(context); verify(template).getForEntity("baseURL/api/1.0/scans/report/netsparkerId?Type=Vulnerabilities&Format=Xml", String.class); }
void fetchReport(NetsparkerAdapterContext context) { String traceID = context.getConfig().getTraceID(); LOG.debug("{} try to fetch report", context.getConfig().getTraceID()); String apiUrl = createAPIURL( APICALL_GET_SCAN_REPORT + context.getProductContextId() + "?Type=Vulnerabilities&Format=Xml", context.getConfig()); ResponseEntity<String> response = context.getRestOperations().getForEntity(apiUrl, String.class); if (!OK.equals(response.getStatusCode())) { throw new NetsparkerRESTFailureException(response.getStatusCode(), response.getBody()); } String body = response.getBody(); context.setResult(body); LOG.debug("{} calling fetch report with '{}'", traceID, apiUrl); }
NetsparkerAdapterV1 extends AbstractAdapter<NetsparkerAdapterContext, NetsparkerAdapterConfig> implements NetsparkerAdapter { void fetchReport(NetsparkerAdapterContext context) { String traceID = context.getConfig().getTraceID(); LOG.debug("{} try to fetch report", context.getConfig().getTraceID()); String apiUrl = createAPIURL( APICALL_GET_SCAN_REPORT + context.getProductContextId() + "?Type=Vulnerabilities&Format=Xml", context.getConfig()); ResponseEntity<String> response = context.getRestOperations().getForEntity(apiUrl, String.class); if (!OK.equals(response.getStatusCode())) { throw new NetsparkerRESTFailureException(response.getStatusCode(), response.getBody()); } String body = response.getBody(); context.setResult(body); LOG.debug("{} calling fetch report with '{}'", traceID, apiUrl); } }
NetsparkerAdapterV1 extends AbstractAdapter<NetsparkerAdapterContext, NetsparkerAdapterConfig> implements NetsparkerAdapter { void fetchReport(NetsparkerAdapterContext context) { String traceID = context.getConfig().getTraceID(); LOG.debug("{} try to fetch report", context.getConfig().getTraceID()); String apiUrl = createAPIURL( APICALL_GET_SCAN_REPORT + context.getProductContextId() + "?Type=Vulnerabilities&Format=Xml", context.getConfig()); ResponseEntity<String> response = context.getRestOperations().getForEntity(apiUrl, String.class); if (!OK.equals(response.getStatusCode())) { throw new NetsparkerRESTFailureException(response.getStatusCode(), response.getBody()); } String body = response.getBody(); context.setResult(body); LOG.debug("{} calling fetch report with '{}'", traceID, apiUrl); }  }
NetsparkerAdapterV1 extends AbstractAdapter<NetsparkerAdapterContext, NetsparkerAdapterConfig> implements NetsparkerAdapter { void fetchReport(NetsparkerAdapterContext context) { String traceID = context.getConfig().getTraceID(); LOG.debug("{} try to fetch report", context.getConfig().getTraceID()); String apiUrl = createAPIURL( APICALL_GET_SCAN_REPORT + context.getProductContextId() + "?Type=Vulnerabilities&Format=Xml", context.getConfig()); ResponseEntity<String> response = context.getRestOperations().getForEntity(apiUrl, String.class); if (!OK.equals(response.getStatusCode())) { throw new NetsparkerRESTFailureException(response.getStatusCode(), response.getBody()); } String body = response.getBody(); context.setResult(body); LOG.debug("{} calling fetch report with '{}'", traceID, apiUrl); }  @Override String execute(NetsparkerAdapterConfig config, AdapterRuntimeContext runtimeContext); @Override int getAdapterVersion(); }
NetsparkerAdapterV1 extends AbstractAdapter<NetsparkerAdapterContext, NetsparkerAdapterConfig> implements NetsparkerAdapter { void fetchReport(NetsparkerAdapterContext context) { String traceID = context.getConfig().getTraceID(); LOG.debug("{} try to fetch report", context.getConfig().getTraceID()); String apiUrl = createAPIURL( APICALL_GET_SCAN_REPORT + context.getProductContextId() + "?Type=Vulnerabilities&Format=Xml", context.getConfig()); ResponseEntity<String> response = context.getRestOperations().getForEntity(apiUrl, String.class); if (!OK.equals(response.getStatusCode())) { throw new NetsparkerRESTFailureException(response.getStatusCode(), response.getBody()); } String body = response.getBody(); context.setResult(body); LOG.debug("{} calling fetch report with '{}'", traceID, apiUrl); }  @Override String execute(NetsparkerAdapterConfig config, AdapterRuntimeContext runtimeContext); @Override int getAdapterVersion();  }