use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity in project hub-alert by blackducksoftware.
the class NotificationManagerTestIT method findByCreatedAtBetween.
@Test
public void findByCreatedAtBetween() {
final LocalDateTime time = LocalDateTime.now();
final Date startDate = createDate(time.minusHours(1));
final Date endDate = createDate(time.plusHours(1));
Date createdAt = createDate(time.minusHours(3));
NotificationEntity entity = createNotificationEntity(createdAt);
notificationManager.saveNotification(new NotificationModel(entity, Collections.emptyList()));
createdAt = createDate(time.plusMinutes(1));
final NotificationEntity entityToFind1 = createNotificationEntity(createdAt);
createdAt = createDate(time.plusMinutes(5));
final NotificationEntity entityToFind2 = createNotificationEntity(createdAt);
createdAt = createDate(time.plusHours(3));
entity = createNotificationEntity(createdAt);
notificationManager.saveNotification(new NotificationModel(entity, Collections.emptyList()));
notificationManager.saveNotification(new NotificationModel(entityToFind1, Collections.emptyList()));
notificationManager.saveNotification(new NotificationModel(entityToFind2, Collections.emptyList()));
final List<NotificationModel> foundList = notificationManager.findByCreatedAtBetween(startDate, endDate);
assertEquals(2, foundList.size());
assertNotificationModel(entityToFind1, foundList.get(0));
assertNotificationModel(entityToFind2, foundList.get(1));
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity in project hub-alert by blackducksoftware.
the class NotificationManagerTestIT method findByCreatedAtBetweenInvalidDate.
@Test
public void findByCreatedAtBetweenInvalidDate() {
final LocalDateTime time = LocalDateTime.now();
final Date startDate = createDate(time.minusHours(1));
final Date endDate = createDate(time.plusHours(1));
final Date createdAtEarlier = createDate(time.minusHours(5));
NotificationEntity entity = createNotificationEntity(createdAtEarlier);
notificationManager.saveNotification(new NotificationModel(entity, Collections.emptyList()));
final Date createdAtLater = createDate(time.plusHours(3));
entity = createNotificationEntity(createdAtLater);
notificationManager.saveNotification(new NotificationModel(entity, Collections.emptyList()));
final List<NotificationModel> foundList = notificationManager.findByCreatedAtBetween(startDate, endDate);
assertTrue(foundList.isEmpty());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity in project hub-alert by blackducksoftware.
the class NotificationManagerTestIT method testSave.
@Test
public void testSave() {
final NotificationEntity notificationEntity = createNotificationEntity();
final VulnerabilityEntity vulnerabilityEntity = new VulnerabilityEntity("id1", VulnerabilityOperationEnum.ADD, null);
final List<VulnerabilityEntity> vulnerabilityList = Arrays.asList(vulnerabilityEntity);
NotificationModel model = new NotificationModel(notificationEntity, vulnerabilityList);
NotificationModel savedModel = notificationManager.saveNotification(model);
assertNotNull(savedModel.getNotificationEntity().getId());
assertNotificationModel(notificationEntity, savedModel);
assertEquals(vulnerabilityList.size(), model.getVulnerabilityList().size());
model = new NotificationModel(notificationEntity, null);
savedModel = notificationManager.saveNotification(model);
assertNotNull(savedModel.getNotificationEntity().getId());
assertNotificationModel(notificationEntity, savedModel);
assertTrue(model.getVulnerabilityList().isEmpty());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity in project hub-alert by blackducksoftware.
the class NotificationManagerTestIT method testFindByIds.
@Test
public void testFindByIds() {
final NotificationEntity notificationEntity = createNotificationEntity();
final VulnerabilityEntity vulnerabilityEntity = new VulnerabilityEntity("id1", VulnerabilityOperationEnum.ADD, null);
final List<VulnerabilityEntity> vulnerabilityList = Arrays.asList(vulnerabilityEntity);
final NotificationModel model = new NotificationModel(notificationEntity, vulnerabilityList);
final NotificationModel savedModel = notificationManager.saveNotification(model);
final List<Long> notificationIds = Arrays.asList(savedModel.getNotificationEntity().getId());
final List<NotificationModel> notificationModelList = notificationManager.findByIds(notificationIds);
assertEquals(1, notificationModelList.size());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity in project hub-alert by blackducksoftware.
the class AuditEntryControllerTestIT method testPostConfig.
@Test
@WithMockUser(roles = "ADMIN")
public void testPostConfig() throws Exception {
CommonDistributionConfigEntity commonEntity = mockCommonDistributionEntity.createEntity();
final MockNotificationEntity mockNotifications = new MockNotificationEntity();
NotificationEntity notificationEntity = mockNotifications.createEntity();
notificationEntity = notificationRepository.save(notificationEntity);
commonEntity = commonDistributionRepository.save(commonEntity);
mockAuditEntity.setCommonConfigId(commonEntity.getId());
AuditEntryEntity auditEntity = mockAuditEntity.createEntity();
auditEntity = auditEntryRepository.save(auditEntity);
auditNotificationRepository.save(new AuditNotificationRelation(auditEntity.getId(), notificationEntity.getId()));
final String resendUrl = auditUrl + "/" + String.valueOf(auditEntity.getId()) + "/" + "/resend";
final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(resendUrl).with(SecurityMockMvcRequestPostProcessors.user("admin").roles("ADMIN"));
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
Aggregations