Search in sources :

Example 1 with CodeLocationWaitJobCondition

use of com.synopsys.integration.blackduck.codelocation.CodeLocationWaitJobCondition in project blackduck-common by blackducksoftware.

the class CodeLocationWaitJobConditionTest method testMultipleNotificationsExpected.

@Test
public void testMultipleNotificationsExpected() throws ParseException, IntegrationException {
    BlackDuckApiClient mockBlackDuckApiClient = Mockito.mock(BlackDuckApiClient.class);
    ProjectService mockProjectService = Mockito.mock(ProjectService.class);
    NotificationService mockNotificationService = Mockito.mock(NotificationService.class);
    UserView userView = new UserView();
    userView.setUserName("squiggles");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date alanTuringBirth = sdf.parse("1912-06-23");
    Date alanTuringUntimelyDeath = sdf.parse("1954-06-07");
    NotificationTaskRange notificationTaskRange = new NotificationTaskRange(System.currentTimeMillis(), alanTuringBirth, alanTuringUntimelyDeath);
    IntLogger logger = new BufferedIntLogger();
    NameVersion projectAndVersion = new NameVersion("BigSpoon", "LittleSpoon");
    String codeLocationName = "GraceIsButGloryBegunAndGloryIsButGracePerfected";
    Set<String> codeLocationNames = new HashSet<>(Arrays.asList(codeLocationName));
    CodeLocationWaitJobCondition codeLocationWaitJobCondition = new CodeLocationWaitJobCondition(logger, mockBlackDuckApiClient, mockProjectService, mockNotificationService, userView, notificationTaskRange, projectAndVersion, codeLocationNames, 2);
    ProjectView projectView = new ProjectView();
    ResourceLink resourceLink = new ResourceLink();
    resourceLink.setRel(ProjectVersionView.CODELOCATIONS_LINK);
    resourceLink.setHref(codeLocationsUrl);
    ResourceMetadata projectVersionViewMeta = new ResourceMetadata();
    projectVersionViewMeta.setLinks(Arrays.asList(resourceLink));
    ProjectVersionView projectVersionView = new ProjectVersionView();
    projectVersionView.setMeta(projectVersionViewMeta);
    ProjectVersionWrapper projectVersionWrapper = new ProjectVersionWrapper(projectView, projectVersionView);
    Mockito.when(mockProjectService.getProjectVersion(projectAndVersion)).thenReturn(Optional.of(projectVersionWrapper));
    ResourceMetadata resourceMetadata = new ResourceMetadata();
    resourceMetadata.setHref(codeLocationUrl);
    CodeLocationView foundCodeLocationView = new CodeLocationView();
    foundCodeLocationView.setName(codeLocationName);
    foundCodeLocationView.setMeta(resourceMetadata);
    Mockito.when(mockBlackDuckApiClient.getAllResponses(Mockito.eq(codeLocationResponses))).thenReturn(Arrays.asList(foundCodeLocationView));
    NotificationEditor notificationEditor = new NotificationEditor(notificationTaskRange.getStartDate(), notificationTaskRange.getEndDate(), Arrays.asList(NotificationType.VERSION_BOM_CODE_LOCATION_BOM_COMPUTED.name()));
    Mockito.when(mockNotificationService.getAllUserNotifications(userView, notificationEditor)).thenReturn(getExpectedNotifications());
    assertTrue(codeLocationWaitJobCondition.isComplete());
}
Also used : NameVersion(com.synopsys.integration.util.NameVersion) CodeLocationWaitJobCondition(com.synopsys.integration.blackduck.codelocation.CodeLocationWaitJobCondition) NotificationTaskRange(com.synopsys.integration.blackduck.service.model.NotificationTaskRange) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) ProjectService(com.synopsys.integration.blackduck.service.dataservice.ProjectService) UserView(com.synopsys.integration.blackduck.api.generated.view.UserView) VersionBomCodeLocationBomComputedNotificationUserView(com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationUserView) NotificationUserView(com.synopsys.integration.blackduck.api.manual.view.NotificationUserView) NotificationService(com.synopsys.integration.blackduck.service.dataservice.NotificationService) IntLogger(com.synopsys.integration.log.IntLogger) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) ResourceMetadata(com.synopsys.integration.blackduck.api.core.ResourceMetadata) Date(java.util.Date) CodeLocationView(com.synopsys.integration.blackduck.api.generated.view.CodeLocationView) ResourceLink(com.synopsys.integration.blackduck.api.core.ResourceLink) ProjectVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView) NotificationEditor(com.synopsys.integration.blackduck.service.request.NotificationEditor) ProjectView(com.synopsys.integration.blackduck.api.generated.view.ProjectView) SimpleDateFormat(java.text.SimpleDateFormat) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

ResourceLink (com.synopsys.integration.blackduck.api.core.ResourceLink)1 ResourceMetadata (com.synopsys.integration.blackduck.api.core.ResourceMetadata)1 CodeLocationView (com.synopsys.integration.blackduck.api.generated.view.CodeLocationView)1 ProjectVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView)1 ProjectView (com.synopsys.integration.blackduck.api.generated.view.ProjectView)1 UserView (com.synopsys.integration.blackduck.api.generated.view.UserView)1 NotificationUserView (com.synopsys.integration.blackduck.api.manual.view.NotificationUserView)1 VersionBomCodeLocationBomComputedNotificationUserView (com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationUserView)1 CodeLocationWaitJobCondition (com.synopsys.integration.blackduck.codelocation.CodeLocationWaitJobCondition)1 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)1 NotificationService (com.synopsys.integration.blackduck.service.dataservice.NotificationService)1 ProjectService (com.synopsys.integration.blackduck.service.dataservice.ProjectService)1 NotificationTaskRange (com.synopsys.integration.blackduck.service.model.NotificationTaskRange)1 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)1 NotificationEditor (com.synopsys.integration.blackduck.service.request.NotificationEditor)1 BufferedIntLogger (com.synopsys.integration.log.BufferedIntLogger)1 IntLogger (com.synopsys.integration.log.IntLogger)1 NameVersion (com.synopsys.integration.util.NameVersion)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1