Search in sources :

Example 41 with IntegrationException

use of com.blackducksoftware.integration.exception.IntegrationException in project hub-fortify-ssc-integration-service by blackducksoftware.

the class HubServices method getProjectVersion.

/**
 * Get the Hub project version information
 *
 * @param projectName
 * @param versionName
 * @return
 * @throws IllegalArgumentException
 * @throws IntegrationException
 */
public ProjectVersionView getProjectVersion(final String projectName, final String projectVersionName) throws IllegalArgumentException, IntegrationException {
    logger.info("Getting Hub project and project version info for::" + projectName + ", " + projectVersionName);
    final ProjectService projectVersionRequestService = hubServicesFactory.createProjectService();
    final ProjectVersionWrapper projectVersionWrapper = projectVersionRequestService.getProjectVersion(projectName, projectVersionName);
    if (projectVersionWrapper != null && projectVersionWrapper.getProjectVersionView() != null) {
        logger.debug("ProjectVersionView::" + projectVersionWrapper.getProjectVersionView().json);
        return projectVersionWrapper.getProjectVersionView();
    } else {
        throw new IntegrationException("Project Version does not Exists!");
    }
}
Also used : HubIntegrationException(com.blackducksoftware.integration.hub.exception.HubIntegrationException) IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) ProjectService(com.blackducksoftware.integration.hub.service.ProjectService) ProjectVersionWrapper(com.blackducksoftware.integration.hub.service.model.ProjectVersionWrapper)

Example 42 with IntegrationException

use of com.blackducksoftware.integration.exception.IntegrationException in project hub-fortify-ssc-integration-service by blackducksoftware.

the class MappingParser method createApplicationVersion.

/**
 * Creates a new Application Version, updates the attributes and commits the application to mark it complete on the
 * UI
 *
 * @param createRequest
 * @return int - Application ID
 * @throws IOException
 * @throws IntegrationException
 */
private int createApplicationVersion(CreateApplicationRequest createRequest) throws IOException, IntegrationException {
    int applicationId = 0;
    applicationId = fortifyApplicationVersionApi.createApplicationVersion(createRequest);
    try {
        final List<UpdateFortifyApplicationAttributesRequest> updateAttributerequest = addCustomAttributes();
        logger.info("updateAttributerequest::" + updateAttributerequest);
        fortifyApplicationVersionApi.updateApplicationAttributes(applicationId, updateAttributerequest);
        CommitFortifyApplicationRequest commitRequest = new CommitFortifyApplicationRequest(true);
        fortifyApplicationVersionApi.commitApplicationVersion(applicationId, commitRequest);
    } catch (IOException e) {
        fortifyApplicationVersionApi.deleteApplicationVersion(applicationId);
        throw new IOException(e);
    } catch (IntegrationException e) {
        fortifyApplicationVersionApi.deleteApplicationVersion(applicationId);
        throw new IntegrationException(e);
    }
    return applicationId;
}
Also used : IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) UpdateFortifyApplicationAttributesRequest(com.blackducksoftware.integration.fortify.model.UpdateFortifyApplicationAttributesRequest) CommitFortifyApplicationRequest(com.blackducksoftware.integration.fortify.model.CommitFortifyApplicationRequest) IOException(java.io.IOException) JsonIOException(com.google.gson.JsonIOException)

Example 43 with IntegrationException

use of com.blackducksoftware.integration.exception.IntegrationException in project hub-fortify-ssc-integration-service by blackducksoftware.

the class HubServicesTest method getBomLastUpdatedAt.

@Test
public void getBomLastUpdatedAt() throws IllegalArgumentException, IntegrationException {
    System.out.println("Executing getBomLastUpdatedAt");
    ProjectVersionView projectVersionItem = null;
    try {
        projectVersionItem = hubServices.getProjectVersion(PROJECT_NAME, VERSION_NAME);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IntegrationException e) {
        e.printStackTrace();
    }
    Date bomLastUpdatedAt = hubServices.getBomLastUpdatedAt(projectVersionItem);
    System.out.println("bomLastUpdatedAt::" + bomLastUpdatedAt);
    assertNotNull(bomLastUpdatedAt);
}
Also used : IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) ProjectVersionView(com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView) Date(java.util.Date) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 44 with IntegrationException

use of com.blackducksoftware.integration.exception.IntegrationException in project hub-fortify-ssc-integration-service by blackducksoftware.

the class HubServicesTest method getProjectVersionWithInvalidProjectName.

@Test
public void getProjectVersionWithInvalidProjectName() {
    System.out.println("Executing getProjectVersionWithInvalidProjectName");
    ProjectVersionView projectVersionItem = null;
    try {
        projectVersionItem = hubServices.getProjectVersion("Solr1", VERSION_NAME);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IntegrationException e) {
        // e.printStackTrace();
        System.out.println("Error message::" + e.getMessage());
        assertTrue(e.getMessage().contains("This Project does not exist"));
    }
    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 45 with IntegrationException

use of com.blackducksoftware.integration.exception.IntegrationException 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)

Aggregations

IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)49 Test (org.junit.Test)21 IOException (java.io.IOException)14 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 ProjectVersionView (com.blackducksoftware.integration.hub.api.generated.view.ProjectVersionView)8 RestConnection (com.blackducksoftware.integration.hub.rest.RestConnection)8 ChannelTest (com.blackducksoftware.integration.hub.alert.channel.ChannelTest)5 HubIntegrationException (com.blackducksoftware.integration.hub.exception.HubIntegrationException)5 ArrayList (java.util.ArrayList)5 Request (com.blackducksoftware.integration.hub.request.Request)4 HubServicesFactory (com.blackducksoftware.integration.hub.service.HubServicesFactory)4 UpdateFortifyApplicationAttributesRequest (com.blackducksoftware.integration.fortify.model.UpdateFortifyApplicationAttributesRequest)3 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)3 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)3 AlertException (com.blackducksoftware.integration.hub.alert.exception.AlertException)3 ProjectService (com.blackducksoftware.integration.hub.service.ProjectService)3 UserGroupService (com.blackducksoftware.integration.hub.service.UserGroupService)3 ExternalConnectionTest (com.blackducksoftware.integration.test.annotation.ExternalConnectionTest)3 File (java.io.File)3 Date (java.util.Date)3