@Test public void client_reads_scan_code_red_product_error() throws Exception { File file = new File("src/test/resources/scan_code_red_product_error.json"); SecHubReport report = SecHubClient.importSecHubJsonReport(file); assertReport(report). hasJobUUID("94bcffcc-b995-4bb5-b3ad-9130cf743f35"). hasFindings(1). hasTrafficLight(TrafficLight.RED). finding(0). hasId(1). hasSeverity(Severity.CRITICAL). hasNoHostnames(). hasNoReferences(). hasName("SecHub failure"). hasDescription("Security product 'XYZ' failed, so cannot give a correct answer."); }
public static SecHubReport importSecHubJsonReport(File file) throws SecHubReportException { SecHubReport report = null; ObjectMapper mapper = new ObjectMapper(); try { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); report = mapper.readValue(file, SecHubReport.class); } catch (JsonParseException | JsonMappingException e) { throw new SecHubReportException("Content is not valid JSON", e); } catch (IOException e) { throw new SecHubReportException("Wasn't able to read report file", e); } return report; }
SecHubClient { public static SecHubReport importSecHubJsonReport(File file) throws SecHubReportException { SecHubReport report = null; ObjectMapper mapper = new ObjectMapper(); try { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); report = mapper.readValue(file, SecHubReport.class); } catch (JsonParseException | JsonMappingException e) { throw new SecHubReportException("Content is not valid JSON", e); } catch (IOException e) { throw new SecHubReportException("Wasn't able to read report file", e); } return report; } }
SecHubClient { public static SecHubReport importSecHubJsonReport(File file) throws SecHubReportException { SecHubReport report = null; ObjectMapper mapper = new ObjectMapper(); try { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); report = mapper.readValue(file, SecHubReport.class); } catch (JsonParseException | JsonMappingException e) { throw new SecHubReportException("Content is not valid JSON", e); } catch (IOException e) { throw new SecHubReportException("Wasn't able to read report file", e); } return report; } private  SecHubClient(String username, String apiToken, URI hostUri, int hostPort, boolean trustAll); }
SecHubClient { public static SecHubReport importSecHubJsonReport(File file) throws SecHubReportException { SecHubReport report = null; ObjectMapper mapper = new ObjectMapper(); try { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); report = mapper.readValue(file, SecHubReport.class); } catch (JsonParseException | JsonMappingException e) { throw new SecHubReportException("Content is not valid JSON", e); } catch (IOException e) { throw new SecHubReportException("Wasn't able to read report file", e); } return report; } private  SecHubClient(String username, String apiToken, URI hostUri, int hostPort, boolean trustAll); static SecHubClient create(String username, String apiToken, String hostUri, int hostPort); static SecHubClient create(String username, String apiToken, String hostUri, int hostPort, boolean trustAll); String getUsername(); String getSealedApiToken(); URI getHostUri(); int getHostPort(); boolean isTrustAll(); static SecHubReport importSecHubJsonReport(File file); }
SecHubClient { public static SecHubReport importSecHubJsonReport(File file) throws SecHubReportException { SecHubReport report = null; ObjectMapper mapper = new ObjectMapper(); try { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); report = mapper.readValue(file, SecHubReport.class); } catch (JsonParseException | JsonMappingException e) { throw new SecHubReportException("Content is not valid JSON", e); } catch (IOException e) { throw new SecHubReportException("Wasn't able to read report file", e); } return report; } private  SecHubClient(String username, String apiToken, URI hostUri, int hostPort, boolean trustAll); static SecHubClient create(String username, String apiToken, String hostUri, int hostPort); static SecHubClient create(String username, String apiToken, String hostUri, int hostPort, boolean trustAll); String getUsername(); String getSealedApiToken(); URI getHostUri(); int getHostPort(); boolean isTrustAll(); static SecHubReport importSecHubJsonReport(File file);  }