Search in sources :

Example 1 with DefaultProductExecutorConfigInfo

use of com.mercedesbenz.sechub.domain.scan.product.config.DefaultProductExecutorConfigInfo 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));
}
Also used : ProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigInfo) DefaultProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.DefaultProductExecutorConfigInfo) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) DefaultProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.DefaultProductExecutorConfigInfo) UUID(java.util.UUID) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 2 with DefaultProductExecutorConfigInfo

use of com.mercedesbenz.sechub.domain.scan.product.config.DefaultProductExecutorConfigInfo 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;
}
Also used : ProductResult(com.mercedesbenz.sechub.domain.scan.product.ProductResult) ArrayList(java.util.ArrayList) WithoutProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo) ProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigInfo) DefaultProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.DefaultProductExecutorConfigInfo) DefaultProductExecutorConfigInfo(com.mercedesbenz.sechub.domain.scan.product.config.DefaultProductExecutorConfigInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DefaultProductExecutorConfigInfo (com.mercedesbenz.sechub.domain.scan.product.config.DefaultProductExecutorConfigInfo)2 ProductExecutorConfigInfo (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutorConfigInfo)2 WithoutProductExecutorConfigInfo (com.mercedesbenz.sechub.domain.scan.product.config.WithoutProductExecutorConfigInfo)2 ProductResult (com.mercedesbenz.sechub.domain.scan.product.ProductResult)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 Test (org.junit.Test)1 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1