Search in sources :

Example 1 with SystemMessageModel

use of com.synopsys.integration.alert.common.persistence.model.SystemMessageModel in project hub-alert by blackducksoftware.

the class SystemMessageAccessorTestIT method testFindCreatedBefore.

@Test
public void testFindCreatedBefore() {
    List<SystemMessageEntity> expectedMessages = createSystemMessageList();
    Collections.reverse(expectedMessages);
    List<SystemMessageEntity> savedMessages = new ArrayList<>(expectedMessages);
    OffsetDateTime currentDateTime = DateUtils.createCurrentDateTimestamp();
    savedMessages.add(new SystemMessageEntity(currentDateTime, SEVERITY, "content", TYPE));
    savedMessages.add(new SystemMessageEntity(currentDateTime.plusMinutes(5), SEVERITY, "content", TYPE));
    systemMessageRepository.saveAll(savedMessages);
    List<SystemMessageModel> actualMessageList = defaultSystemMessageUtility.getSystemMessagesBefore(currentDateTime);
    assertNotNull(actualMessageList);
    assertEquals(MESSAGE_COUNT, actualMessageList.size());
    assertEquals(expectedMessages.size(), actualMessageList.size());
}
Also used : OffsetDateTime(java.time.OffsetDateTime) SystemMessageModel(com.synopsys.integration.alert.common.persistence.model.SystemMessageModel) ArrayList(java.util.ArrayList) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with SystemMessageModel

use of com.synopsys.integration.alert.common.persistence.model.SystemMessageModel in project hub-alert by blackducksoftware.

the class SystemMessageAccessorTestIT method testGetSystemMessagesSince.

@Test
public void testGetSystemMessagesSince() {
    List<SystemMessageEntity> savedMessages = createSystemMessageList();
    OffsetDateTime currentDateTime = DateUtils.createCurrentDateTimestamp();
    savedMessages.add(new SystemMessageEntity(currentDateTime.plusNanos(1), SEVERITY, "content", TYPE));
    savedMessages.add(new SystemMessageEntity(currentDateTime.plusNanos(5), SEVERITY, "content", TYPE));
    systemMessageRepository.saveAll(savedMessages);
    List<SystemMessageModel> actualMessageList = defaultSystemMessageUtility.getSystemMessagesAfter(currentDateTime);
    assertNotNull(actualMessageList);
    assertEquals(2, actualMessageList.size());
}
Also used : OffsetDateTime(java.time.OffsetDateTime) SystemMessageModel(com.synopsys.integration.alert.common.persistence.model.SystemMessageModel) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with SystemMessageModel

use of com.synopsys.integration.alert.common.persistence.model.SystemMessageModel in project hub-alert by blackducksoftware.

the class SystemMessageAccessorTestIT method testFindBetweenDateRange.

@Test
public void testFindBetweenDateRange() {
    List<SystemMessageEntity> expectedMessages = createSystemMessageList();
    Collections.reverse(expectedMessages);
    OffsetDateTime currentDateTime = DateUtils.createCurrentDateTimestamp();
    OffsetDateTime startTime = currentDateTime.minusMinutes(10);
    List<SystemMessageEntity> savedMessages = new ArrayList<>(expectedMessages);
    savedMessages.add(new SystemMessageEntity(currentDateTime, SEVERITY, "content", TYPE));
    savedMessages.add(new SystemMessageEntity(startTime.minusMinutes(15), SEVERITY, "content", TYPE));
    savedMessages.add(new SystemMessageEntity(currentDateTime.plusMinutes(5), SEVERITY, "content", TYPE));
    systemMessageRepository.saveAll(savedMessages);
    DateRange dateRange = DateRange.of(startTime, currentDateTime);
    List<SystemMessageModel> actualMessageList = defaultSystemMessageUtility.findBetween(dateRange);
    assertNotNull(actualMessageList);
    assertEquals(MESSAGE_COUNT, actualMessageList.size());
    assertEquals(expectedMessages.size(), actualMessageList.size());
}
Also used : DateRange(com.synopsys.integration.alert.common.message.model.DateRange) OffsetDateTime(java.time.OffsetDateTime) SystemMessageModel(com.synopsys.integration.alert.common.persistence.model.SystemMessageModel) ArrayList(java.util.ArrayList) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 4 with SystemMessageModel

use of com.synopsys.integration.alert.common.persistence.model.SystemMessageModel in project hub-alert by blackducksoftware.

the class SystemActions method getSystemMessagesBetween.

private ActionResponse<MultiSystemMessageModel> getSystemMessagesBetween(String startDate, String endDate) throws ParseException {
    DateRange dateRange = DateRange.of(startDate, endDate);
    List<SystemMessageModel> messages = systemMessageAccessor.findBetween(dateRange);
    return new ActionResponse<>(HttpStatus.OK, new MultiSystemMessageModel(messages));
}
Also used : DateRange(com.synopsys.integration.alert.common.message.model.DateRange) SystemMessageModel(com.synopsys.integration.alert.common.persistence.model.SystemMessageModel) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse)

Example 5 with SystemMessageModel

use of com.synopsys.integration.alert.common.persistence.model.SystemMessageModel in project hub-alert by blackducksoftware.

the class SystemActionsTest method createSystemMessageList.

private List<SystemMessageModel> createSystemMessageList() {
    ZonedDateTime zonedDateTime = ZonedDateTime.now();
    zonedDateTime = zonedDateTime.minusMinutes(1);
    return List.of(new SystemMessageModel("1", RestConstants.formatDate(Date.from(zonedDateTime.toInstant())), "type", "content", "type"));
}
Also used : ZonedDateTime(java.time.ZonedDateTime) SystemMessageModel(com.synopsys.integration.alert.common.persistence.model.SystemMessageModel)

Aggregations

SystemMessageModel (com.synopsys.integration.alert.common.persistence.model.SystemMessageModel)10 OffsetDateTime (java.time.OffsetDateTime)6 Test (org.junit.jupiter.api.Test)5 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)4 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)3 DateRange (com.synopsys.integration.alert.common.message.model.DateRange)2 ArrayList (java.util.ArrayList)2 AlertWebServerUrlManager (com.synopsys.integration.alert.common.rest.AlertWebServerUrlManager)1 DefaultSystemStatusAccessor (com.synopsys.integration.alert.database.api.DefaultSystemStatusAccessor)1 DefaultSystemMessageAccessor (com.synopsys.integration.alert.database.system.DefaultSystemMessageAccessor)1 DescriptorMetadataActions (com.synopsys.integration.alert.web.api.metadata.DescriptorMetadataActions)1 DescriptorsResponseModel (com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel)1 ZonedDateTime (java.time.ZonedDateTime)1 Date (java.util.Date)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1