use of com.synopsys.integration.alert.common.persistence.accessor.ProviderTaskPropertiesAccessor in project hub-alert by blackducksoftware.
the class BlackDuckNotificationRetrieverTest method createDateRangeCreator.
private BlackDuckAccumulatorSearchDateManager createDateRangeCreator() {
ProviderTaskPropertiesAccessor taskPropertiesAccessor = Mockito.mock(ProviderTaskPropertiesAccessor.class);
Mockito.when(taskPropertiesAccessor.getTaskProperty(Mockito.anyString(), Mockito.anyString())).thenReturn(Optional.empty());
return new BlackDuckAccumulatorSearchDateManager(taskPropertiesAccessor, 0L, "Task");
}
use of com.synopsys.integration.alert.common.persistence.accessor.ProviderTaskPropertiesAccessor in project hub-alert by blackducksoftware.
the class BlackDuckAccumulatorTest method runCreateNotificationRetrieverEmptyTest.
@Test
public void runCreateNotificationRetrieverEmptyTest() {
ProviderTaskPropertiesAccessor taskPropertiesAccessor = Mockito.mock(ProviderTaskPropertiesAccessor.class);
BlackDuckProperties blackDuckProperties = createBlackDuckProperties();
BlackDuckSystemValidator validator = createBlackDuckValidator(blackDuckProperties, true);
BlackDuckNotificationRetrieverFactory notificationRetrieverFactory = createBlackDuckNotificationRetrieverFactory(blackDuckProperties, null);
BlackDuckAccumulator accumulator = new BlackDuckAccumulator(BLACK_DUCK_PROVIDER_KEY, null, null, taskPropertiesAccessor, blackDuckProperties, validator, null, notificationRetrieverFactory);
accumulator.run();
Mockito.verify(taskPropertiesAccessor, Mockito.times(0)).getTaskProperty(Mockito.anyString(), Mockito.anyString());
}
use of com.synopsys.integration.alert.common.persistence.accessor.ProviderTaskPropertiesAccessor in project hub-alert by blackducksoftware.
the class BlackDuckAccumulatorSearchDateManagerTest method formatDateTest.
@Test
public void formatDateTest() throws ParseException {
ProviderTaskPropertiesAccessor mockTaskPropsAccessor = createMockTaskPropertiesAccessor();
BlackDuckAccumulatorSearchDateManager dateManager = new BlackDuckAccumulatorSearchDateManager(mockTaskPropsAccessor, 0L, "Task");
OffsetDateTime currentDate = DateUtils.createCurrentDateTimestamp();
dateManager.saveNextSearchStart(currentDate);
String currentDateString = DateUtils.formatDateAsJsonString(currentDate);
OffsetDateTime currentDateDeserialized = DateUtils.parseDateFromJsonString(currentDateString);
DateRange dateRange = dateManager.retrieveNextSearchDateRange();
OffsetDateTime nextSearchStart = dateRange.getStart();
assertEquals(currentDateDeserialized, nextSearchStart);
}
use of com.synopsys.integration.alert.common.persistence.accessor.ProviderTaskPropertiesAccessor in project hub-alert by blackducksoftware.
the class BlackDuckAccumulatorSearchDateManagerTest method createDateManager.
private BlackDuckAccumulatorSearchDateManager createDateManager(String expectedDate) {
ProviderTaskPropertiesAccessor mockTaskPropsAccessor = Mockito.mock(ProviderTaskPropertiesAccessor.class);
Mockito.when(mockTaskPropsAccessor.getTaskProperty(Mockito.anyString(), Mockito.anyString())).thenReturn(Optional.ofNullable(expectedDate));
return new BlackDuckAccumulatorSearchDateManager(mockTaskPropsAccessor, 0L, "Task");
}
use of com.synopsys.integration.alert.common.persistence.accessor.ProviderTaskPropertiesAccessor in project hub-alert by blackducksoftware.
the class BlackDuckAccumulatorTest method runTest.
/**
* This test should simulate a normal run of the accumulator with notifications present.
*/
@Test
public void runTest() throws Exception {
ProviderTaskPropertiesAccessor taskPropertiesAccessor = Mockito.mock(ProviderTaskPropertiesAccessor.class);
BlackDuckProperties blackDuckProperties = createBlackDuckProperties();
BlackDuckSystemValidator validator = createBlackDuckValidator(blackDuckProperties, true);
PageRetriever pageRetriever = Mockito.mock(PageRetriever.class);
StatefulAlertPage<NotificationUserView, IntegrationException> notificationPage = createMockNotificationPage(pageRetriever);
BlackDuckNotificationRetriever notificationRetriever = Mockito.mock(BlackDuckNotificationRetriever.class);
Mockito.when(notificationRetriever.retrievePageOfFilteredNotifications(Mockito.any(), Mockito.anyList())).thenReturn(notificationPage);
Mockito.when(pageRetriever.retrieveNextPage(Mockito.anyInt(), Mockito.anyInt())).thenReturn(AlertPagedDetails.emptyPage());
BlackDuckNotificationRetrieverFactory notificationRetrieverFactory = createBlackDuckNotificationRetrieverFactory(blackDuckProperties, notificationRetriever);
NotificationAccessor notificationAccessor = Mockito.mock(NotificationAccessor.class);
Mockito.when(notificationAccessor.saveAllNotifications(Mockito.anyList())).thenAnswer(invocation -> invocation.getArgument(0));
EventManager eventManager = Mockito.mock(EventManager.class);
Mockito.doNothing().when(eventManager).sendEvent(Mockito.any(NotificationReceivedEvent.class));
BlackDuckAccumulator accumulator = new BlackDuckAccumulator(BLACK_DUCK_PROVIDER_KEY, null, notificationAccessor, taskPropertiesAccessor, blackDuckProperties, validator, eventManager, notificationRetrieverFactory);
accumulator.run();
Mockito.verify(notificationAccessor, Mockito.times(1)).saveAllNotifications(Mockito.anyList());
}
Aggregations