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());
}
Aggregations