use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTestIT method testAlertNotificationModels.
private void testAlertNotificationModels(List<AlertNotificationModel> models) {
PageRequest pageRequest = defaultNotificationAccessor.getPageRequestForNotifications(0, models.size(), null, null);
List<AlertNotificationModel> alertNotificationModels = defaultNotificationAccessor.findAll(pageRequest, false).getContent();
assertModelsAreProcessed(alertNotificationModels);
assertEquals(0, defaultNotificationAccessor.getFirstPageOfNotificationsNotProcessed(pageSize).getModels().size());
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTestIT method createAlertNotificationModel.
private AlertNotificationModel createAlertNotificationModel(boolean processed) {
String bomEditContent = "{" + "\"type\":\"" + NotificationType.BOM_EDIT.name() + "\"," + "\"content\": {" + "\"projectVersion\": \"" + properties.getBlackDuckURL() + "/api/projects\"," + "\"bomComponent\": \"" + properties.getBlackDuckURL() + "\"," + "\"componentName\": \"test\"," + "\"componentVersionName\": \"test\"" + "}" + "}";
MockNotificationContent notificationMocker = new MockNotificationContent(DateUtils.createCurrentDateTimestamp(), blackDuckProviderKey.getUniversalKey(), DateUtils.createCurrentDateTimestamp(), NotificationType.BOM_EDIT.name(), bomEditContent, null, blackDuckGlobalConfigId);
NotificationEntity entity = notificationMocker.createEntity();
return new AlertNotificationModel(null, entity.getProviderConfigId(), entity.getProvider(), "providerConfigName", entity.getNotificationType(), entity.getContent(), entity.getCreatedAt(), entity.getProviderCreationTime(), processed);
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTestIT method testHandleEventNotProcessedNotifications.
@Test
void testHandleEventNotProcessedNotifications() {
List<AlertNotificationModel> notificationContent = new ArrayList<>();
notificationContent.add(createAlertNotificationModel(false));
notificationContent.add(createAlertNotificationModel(false));
List<AlertNotificationModel> savedModels = defaultNotificationAccessor.saveAllNotifications(notificationContent);
assertNotNull(savedModels);
NotificationProcessor notificationProcessor = createNotificationProcessor();
NotificationReceivedEventHandler notificationReceivedEventHandler = new NotificationReceivedEventHandler(defaultNotificationAccessor, notificationProcessor, eventManager);
notificationReceivedEventHandler.handle(new NotificationReceivedEvent());
testAlertNotificationModels(savedModels);
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessor method getFirstPageOfNotificationsNotProcessed.
@Override
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED)
public AlertPagedModel<AlertNotificationModel> getFirstPageOfNotificationsNotProcessed(int pageSize) {
int currentPage = 0;
Sort.Order sortingOrder = Sort.Order.asc(COLUMN_NAME_PROVIDER_CREATION_TIME);
PageRequest pageRequest = PageRequest.of(currentPage, pageSize, Sort.by(sortingOrder));
Page<AlertNotificationModel> pageOfNotifications = notificationContentRepository.findByProcessedFalseOrderByProviderCreationTimeAsc(pageRequest).map(this::toModel);
List<AlertNotificationModel> alertNotificationModels = pageOfNotifications.getContent();
return new AlertPagedModel<>(pageOfNotifications.getTotalPages(), currentPage, pageSize, alertNotificationModels);
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class DefaultNotificationAccessor method findByCreatedAtBetween.
@Override
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED)
public AlertPagedModel<AlertNotificationModel> findByCreatedAtBetween(OffsetDateTime startDate, OffsetDateTime endDate, int pageNumber, int pageSize) {
Sort.Order sortingOrder = Sort.Order.asc(COLUMN_NAME_PROVIDER_CREATION_TIME);
PageRequest pageRequest = PageRequest.of(pageNumber, pageSize, Sort.by(sortingOrder));
Page<AlertNotificationModel> pageOfNotifications = notificationContentRepository.findByCreatedAtBetween(startDate, endDate, pageRequest).map(this::toModel);
List<AlertNotificationModel> alertNotificationModels = pageOfNotifications.getContent();
return new AlertPagedModel<>(pageOfNotifications.getTotalPages(), pageNumber, pageSize, alertNotificationModels);
}
Aggregations