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