### Question:
SecHubResultService { public SecHubResult createResult(SecHubExecutionContext context) throws SecHubExecutionException { notNull(context, "Context may not be null!"); UUID secHubJobUUID = context.getSechubJobUUID(); return createResult(secHubJobUUID); }  SecHubResult createResult(SecHubExecutionContext context); SecHubResult createResult(UUID secHubJobUUID);  }### Answer:
@Test public void when_product_result_repository_returns_empty_list__sechub_execution_is_thrown_with_message() throws Exception { when(productResultRepository.findProductResults(eq(secHubJobUUID), any())).thenReturn(new ArrayList<>()); expected.expect(SecHubExecutionException.class); expected.expectMessage("No report result found for:" + secHubJobUUID); serviceToTest.createResult(context); }
@Test public void when_product_result_repository_returns_only_netsparker_result__sechub_execution_is_thrown_with_message() throws Exception { ProductResult scanResult = new ProductResult(secHubJobUUID, "project1", ProductIdentifier.NETSPARKER, "scan-result"); when(productResultRepository.findProductResults(eq(secHubJobUUID), any())) .thenReturn(Arrays.asList(scanResult)); expected.expect(SecHubExecutionException.class); serviceToTest.createResult(context); }
@Test public void when_product_result_repository_returns_only_sereco_report_result__sechubResultFromTransformer_is_returned() throws Exception { SecHubResult secHubResult = new SecHubResult(); ProductResult scanResult = new ProductResult(secHubJobUUID, "project1", ProductIdentifier.SERECO, "scan-result"); when(reportTransformer.canTransform(ProductIdentifier.SERECO)).thenReturn(true); when(reportTransformer.transform(scanResult)).thenReturn(secHubResult); when(productResultRepository.findProductResults(eq(secHubJobUUID), any())) .thenReturn(Arrays.asList(scanResult)); when(resultMerger.merge(null,secHubResult)).thenReturn(secHubResult); SecHubResult result = serviceToTest.createResult(context); assertEquals(secHubResult, result); }