Search in sources :

Example 11 with DateRange

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);
}
Also used : DateRange(com.synopsys.integration.alert.common.message.model.DateRange) OffsetDateTime(java.time.OffsetDateTime) ProviderTaskPropertiesAccessor(com.synopsys.integration.alert.common.persistence.accessor.ProviderTaskPropertiesAccessor) Test(org.junit.jupiter.api.Test)

Example 12 with DateRange

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());
}
Also used : DateRange(com.synopsys.integration.alert.common.message.model.DateRange) Test(org.junit.jupiter.api.Test)

Example 13 with DateRange

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);
}
Also used : DateRange(com.synopsys.integration.alert.common.message.model.DateRange) ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.jupiter.api.Test)

Aggregations

DateRange (com.synopsys.integration.alert.common.message.model.DateRange)13 Test (org.junit.jupiter.api.Test)10 TaskManager (com.synopsys.integration.alert.api.task.TaskManager)4 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)4 DefaultNotificationAccessor (com.synopsys.integration.alert.database.api.DefaultNotificationAccessor)4 StaticJobAccessor (com.synopsys.integration.alert.database.api.StaticJobAccessor)4 NotificationProcessor (com.synopsys.integration.alert.processor.api.NotificationProcessor)4 NotificationDetailExtractionDelegator (com.synopsys.integration.alert.processor.api.detail.NotificationDetailExtractionDelegator)4 OffsetDateTime (java.time.OffsetDateTime)4 TaskScheduler (org.springframework.scheduling.TaskScheduler)4 NotificationAccessor (com.synopsys.integration.alert.common.persistence.accessor.NotificationAccessor)3 SystemMessageModel (com.synopsys.integration.alert.common.persistence.model.SystemMessageModel)2 ZonedDateTime (java.time.ZonedDateTime)2 ArrayList (java.util.ArrayList)2 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)1 ProviderTaskPropertiesAccessor (com.synopsys.integration.alert.common.persistence.accessor.ProviderTaskPropertiesAccessor)1 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)1