use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigInfo in project sechub by mercedes-benz.
the class ProductResultRepositoryDBTest method given_2_stored_results_find_for_given_executor_confing_with_uuid_returns_both_results.
@Test
public void given_2_stored_results_find_for_given_executor_confing_with_uuid_returns_both_results() throws Exception {
/* prepare */
UUID job1_project1 = UUID.randomUUID();
UUID uuid1 = UUID.randomUUID();
UUID uuid2 = UUID.randomUUID();
ProductExecutorConfigInfo configUUIDProvider1 = mock(ProductExecutorConfigInfo.class);
when(configUUIDProvider1.getUUID()).thenReturn(uuid1);
ProductExecutorConfigInfo configUUIDProvider2 = mock(ProductExecutorConfigInfo.class);
when(configUUIDProvider2.getUUID()).thenReturn(uuid2);
ProductResult result1 = new ProductResult(job1_project1, "project1", new DefaultProductExecutorConfigInfo(ProductIdentifier.PDS_CODESCAN, uuid1), "result1");
ProductResult result2 = new ProductResult(job1_project1, "project2", new DefaultProductExecutorConfigInfo(ProductIdentifier.PDS_CODESCAN, uuid2), "result2");
repositoryToTest.save(result1);
repositoryToTest.save(result2);
/* check preconditions */
assertEquals(2, repositoryToTest.count());
// just check its written...
assertNotNull(repositoryToTest.findById(job1_project1));
/* execute */
List<ProductResult> results1 = repositoryToTest.findProductResults(job1_project1, configUUIDProvider1);
List<ProductResult> results2 = repositoryToTest.findProductResults(job1_project1, configUUIDProvider2);
/* test */
assertEquals(1, results1.size());
assertTrue(results1.contains(result1));
assertEquals(1, results2.size());
assertTrue(results2.contains(result2));
}
use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigInfo in project sechub by mercedes-benz.
the class ReportTestHelper method transform.
private static ReportTransformationResult transform(String xml, ProductIdentifier productIdentifier, String sechubJobUUID, ProductResultImporter importer) throws IOException, SecHubExecutionException {
ProductExecutorConfigInfo info = mock(ProductExecutorConfigInfo.class);
when(info.getProductIdentifier()).thenReturn(productIdentifier);
// import from SARIF to SERECO format
SerecoMetaData serecoMetaData = importer.importResult(xml);
String serecoJSon = JSONConverter.get().toJSON(serecoMetaData);
// transform SERECO JSON to SecHub report transformation result
ProductResult productResult = new ProductResult(UUID.fromString(sechubJobUUID), "project-1", info, serecoJSon);
ReportTransformationResult result = transfomer.transform(productResult);
return result;
}
use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigInfo in project sechub by mercedes-benz.
the class IntegrationTestScanRestController method fetchScanResults.
@RequestMapping(path = APIConstants.API_ANONYMOUS + "integrationtest/project/{projectId}/scan/productresult/all-shrinked/{maxLength}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
public List<ProductResult> fetchScanResults(@PathVariable("projectId") String projectId, @PathVariable("maxLength") int maxLength) {
if (maxLength < 10) {
maxLength = 10;
}
List<ProductResult> originResults = productResultService.fetchAllResultsInProject(projectId);
List<ProductResult> shrinkedResults = new ArrayList<ProductResult>();
for (ProductResult originProductResult : originResults) {
String result = originProductResult.getResult();
if (result.length() > maxLength) {
result = result.substring(0, maxLength - 3) + "...";
}
ProductExecutorConfigInfo info = new DefaultProductExecutorConfigInfo(originProductResult.getProductIdentifier(), originProductResult.getProductExecutorConfigUUID());
ProductResult shrinked = new ProductResult(originProductResult.getSecHubJobUUID(), originProductResult.getProjectId(), info, result);
shrinkedResults.add(shrinked);
}
return shrinkedResults;
}
Aggregations