use of com.synopsys.integration.alert.common.message.model.DateRange 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.message.model.DateRange in project hub-alert by blackducksoftware.
the class BlackDuckAccumulatorSearchDateManagerTest method retrieveDateRangeParseExceptionTest.
@Test
public void retrieveDateRangeParseExceptionTest() {
BlackDuckAccumulatorSearchDateManager dateRangeCreator = createDateManager("Not a date");
DateRange dateRange = dateRangeCreator.retrieveNextSearchDateRange();
assertNotNull(dateRange);
assertEquals(dateRange.getStart(), dateRange.getEnd());
}
use of com.synopsys.integration.alert.common.message.model.DateRange in project hub-alert by blackducksoftware.
the class BlackDuckAccumulatorSearchDateManagerTest method retrieveDateRangeTest.
@Test
public void retrieveDateRangeTest() {
BlackDuckAccumulatorSearchDateManager dateManager = createDateManager(null);
DateRange dateRange = dateManager.retrieveNextSearchDateRange();
assertNotNull(dateRange);
ZonedDateTime startTime = ZonedDateTime.ofInstant(dateRange.getStart().toInstant(), ZoneOffset.UTC);
ZonedDateTime endTime = ZonedDateTime.ofInstant(dateRange.getEnd().toInstant(), ZoneOffset.UTC);
assertNotEquals(dateRange.getStart(), dateRange.getEnd());
ZonedDateTime expectedStartTime = endTime.minusMinutes(1);
assertEquals(expectedStartTime, startTime);
}
Aggregations