Search in sources :

Example 11 with ProjectVersionView

use of com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView in project hub-fortify-ssc-integration-service by blackducksoftware.

the class HubServicesTest method getProjectVersionWithInvalidVersionName.

@Test
public void getProjectVersionWithInvalidVersionName() {
    System.out.println("Executing getProjectVersionWithInvalidVersionName");
    ProjectVersionView projectVersionItem = null;
    try {
        projectVersionItem = hubServices.getProjectVersion(PROJECT_NAME, "3.10");
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IntegrationException e) {
        // e.printStackTrace();
        System.out.println("Error message::" + e.getMessage());
        assertTrue(e.getMessage().contains("Could not find the version"));
    }
    assertNull(projectVersionItem);
}
Also used : IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) ProjectVersionView(com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with ProjectVersionView

use of com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView in project hub-fortify-ssc-integration-service by blackducksoftware.

the class VulnerabilityUtilTest method testRemoveDuplicates.

@Test
public void testRemoveDuplicates() {
    System.out.println("Executing testRemoveDuplicates");
    List<Vulnerability> vulnerabilities = new ArrayList<>();
    try {
        try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(propertyConstants.getBatchJobStatusFilePath()), "utf-8"))) {
            writer.write("");
        } catch (UnsupportedEncodingException e) {
        // do nothing
        } catch (FileNotFoundException e) {
        // do nothing
        } catch (IOException e) {
        // do nothing
        }
        ProjectVersionView projectVersionItem1 = hubServices.getProjectVersion(HUB_PROJECT_NAME_1, HUB_PROJECT_VERSION_NAME_1);
        ProjectVersionView projectVersionItem2 = hubServices.getProjectVersion(HUB_PROJECT_NAME_2, HUB_PROJECT_VERSION_NAME_2);
        vulnerabilities.addAll(VulnerabilityUtil.transformMapping(hubServices.getVulnerabilityComponentViews(projectVersionItem1), HUB_PROJECT_NAME_1, HUB_PROJECT_VERSION_NAME_1, new Date(), propertyConstants));
        vulnerabilities.addAll(VulnerabilityUtil.transformMapping(hubServices.getVulnerabilityComponentViews(projectVersionItem2), HUB_PROJECT_NAME_2, HUB_PROJECT_VERSION_NAME_2, new Date(), propertyConstants));
        vulnerabilities = VulnerabilityUtil.removeDuplicates(vulnerabilities);
        assertNotNull(vulnerabilities);
        System.out.println("vulnerabilities count::" + vulnerabilities.size() + ", vulnerabilities::" + vulnerabilities);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IntegrationException e) {
        e.printStackTrace();
    }
}
Also used : IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Vulnerability(com.blackducksoftware.integration.fortify.batch.model.Vulnerability) IOException(java.io.IOException) JsonIOException(com.google.gson.JsonIOException) Date(java.util.Date) BufferedWriter(java.io.BufferedWriter) FileOutputStream(java.io.FileOutputStream) ProjectVersionView(com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView) OutputStreamWriter(java.io.OutputStreamWriter) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter) Writer(java.io.Writer) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ProjectVersionView (com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView)12 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)9 Test (org.junit.Test)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)7 Date (java.util.Date)4 Vulnerability (com.blackducksoftware.integration.fortify.batch.model.Vulnerability)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HubProjectVersion (com.blackducksoftware.integration.fortify.batch.model.HubProjectVersion)2 VulnerableComponentView (com.blackducksoftware.integration.hub.api.generated.view.VulnerableComponentView)2 JsonIOException (com.google.gson.JsonIOException)2 File (java.io.File)2 ProjectRequest (com.blackducksoftware.integration.hub.api.generated.component.ProjectRequest)1 HubScanConfig (com.blackducksoftware.integration.hub.configuration.HubScanConfig)1 HubScanConfigBuilder (com.blackducksoftware.integration.hub.configuration.HubScanConfigBuilder)1 HubServerConfig (com.blackducksoftware.integration.hub.configuration.HubServerConfig)1 DetectUserFriendlyException (com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException)1 ExitCodeReporter (com.blackducksoftware.integration.hub.detect.exitcode.ExitCodeReporter)1 DetectOption (com.blackducksoftware.integration.hub.detect.help.DetectOption)1 DetectConfigurationPrinter (com.blackducksoftware.integration.hub.detect.help.print.DetectConfigurationPrinter)1