use of com.epam.pipeline.entity.user.PipelineUser in project cloud-pipeline by epam.
the class PipelineRunDaoTest method testLoadActiveServicesByOwner.
@Test
public void testLoadActiveServicesByOwner() {
PipelineRun run = createTestPipelineRun();
PagingRunFilterVO filterVO = new PagingRunFilterVO();
filterVO.setPage(1);
filterVO.setPageSize(TEST_PAGE_SIZE);
PipelineUser user = new PipelineUser();
user.setUserName(USER);
List<PipelineRun> runs = pipelineRunDao.loadActiveServices(filterVO, user);
assertEquals(1, runs.size());
assertEquals(run.getId(), runs.get(0).getId());
assertEquals(1, runs.size());
}
use of com.epam.pipeline.entity.user.PipelineUser in project cloud-pipeline by epam.
the class MonitoringNotificationDaoTest method testCreateMonitoringNotifications.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testCreateMonitoringNotifications() {
NotificationTemplate notificationTemplate = notificationTemplateDao.createNotificationTemplate(template);
PipelineUser pipelineUser = userDao.loadUserByName(TEST_USER1);
List<NotificationMessage> messages = IntStream.range(0, 5).mapToObj(i -> {
NotificationMessage notificationMessage = new NotificationMessage();
notificationMessage.setTemplate(notificationTemplate);
notificationMessage.setToUserId(pipelineUser.getId());
notificationMessage.setCopyUserIds(Collections.singletonList(pipelineUser.getId()));
notificationMessage.setTemplateParameters(Collections.singletonMap("test", i));
return notificationMessage;
}).collect(Collectors.toList());
monitoringNotificationDao.createMonitoringNotifications(messages);
List<NotificationMessage> loaded = monitoringNotificationDao.loadAllNotifications();
assertTrue(messages.size() <= loaded.size());
assertTrue(loaded.stream().allMatch(l -> messages.stream().anyMatch(m -> m.getTemplateParameters().equals(l.getTemplateParameters()))));
}
use of com.epam.pipeline.entity.user.PipelineUser in project cloud-pipeline by epam.
the class MonitoringNotificationDaoTest method testLoadMonitoringNotification.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testLoadMonitoringNotification() {
PipelineRun run1 = createTestPipelineRun();
List<PipelineRun> pipelineRuns = pipelineRunDao.loadPipelineRuns(Collections.singletonList(run1.getId()));
NotificationTemplate notificationTemplate = notificationTemplateDao.createNotificationTemplate(template);
notificationMessage = new NotificationMessage();
notificationMessage.setTemplate(notificationTemplate);
PipelineUser pipelineUser = userDao.loadUserByName(TEST_USER1);
notificationMessage.setToUserId(pipelineUser.getId());
notificationMessage.setCopyUserIds(Collections.singletonList(pipelineUser.getId()));
notificationMessage.setTemplateParameters(PipelineRunMapper.map(pipelineRuns.get(0), TEST_THRESHOLD));
monitoringNotificationDao.createMonitoringNotification(notificationMessage);
NotificationMessage actualMessage = monitoringNotificationDao.loadMonitoringNotification(notificationMessage.getId());
assertEquals(notificationMessage.getId(), actualMessage.getId());
assertEquals(notificationMessage.getTemplate().getId(), actualMessage.getTemplate().getId());
assertEquals(user.getId(), notificationMessage.getToUserId());
assertFalse(notificationMessage.getCopyUserIds().isEmpty());
notificationMessage.getTemplateParameters().values().removeIf(Objects::isNull);
notificationMessage.getTemplateParameters().forEach((k, v) -> {
assertTrue(actualMessage.getTemplateParameters().containsKey(k));
assertEquals(v.toString(), actualMessage.getTemplateParameters().get(k).toString());
});
}
use of com.epam.pipeline.entity.user.PipelineUser in project cloud-pipeline by epam.
the class MonitoringNotificationDaoTest method setUp.
@Before
public void setUp() {
user = new PipelineUser();
user.setUserName(TEST_USER1);
userDao.createUser(user, Arrays.asList(DefaultRoles.ROLE_ADMIN.getId(), DefaultRoles.ROLE_USER.getId()));
testPipeline = new Pipeline();
testPipeline.setName("Test");
testPipeline.setRepository("///");
testPipeline.setOwner(TEST_USER1);
pipelineDao.createPipeline(testPipeline);
template = new NotificationTemplate();
template.setId(1L);
template.setSubject(SUBJECT_STRING);
template.setBody(BODY_STRING);
}
use of com.epam.pipeline.entity.user.PipelineUser in project cloud-pipeline by epam.
the class MonitoringNotificationDaoTest method testCreateAndLoadCustomMonitoringNotifications.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testCreateAndLoadCustomMonitoringNotifications() {
PipelineUser pipelineUser = userDao.loadUserByName(TEST_USER1);
NotificationMessage message = new NotificationMessage();
message.setBody(BODY_STRING);
message.setSubject(SUBJECT_STRING);
message.setToUserId(pipelineUser.getId());
message.setCopyUserIds(Collections.emptyList());
message.setTemplateParameters(Collections.singletonMap(TEMPLATE_PARAMETER, TEMPLATE_PARAMETER_VALUE));
monitoringNotificationDao.createMonitoringNotification(message);
NotificationMessage singleLoadedMessage = monitoringNotificationDao.loadMonitoringNotification(message.getId());
assertEquals(singleLoadedMessage.getBody(), BODY_STRING);
assertEquals(singleLoadedMessage.getSubject(), SUBJECT_STRING);
assertEquals(singleLoadedMessage.getToUserId(), pipelineUser.getId());
assertEquals(singleLoadedMessage.getCopyUserIds(), Collections.emptyList());
assertNull(singleLoadedMessage.getTemplate());
NotificationMessage batchLoadedMessage = monitoringNotificationDao.loadAllNotifications().stream().filter(m -> m.getId().equals(message.getId())).findFirst().get();
assertEquals(singleLoadedMessage, batchLoadedMessage);
}
Aggregations