use of com.epam.pipeline.entity.user.PipelineUser in project cloud-pipeline by epam.
the class PipelineRunMapperOld method getRequestForRun.
private Optional<DocWriteRequest> getRequestForRun(final String indexName, final PipelineEvent event, final Map<String, PipelineUser> users) {
try {
PipelineRunWithLog run = cloudPipelineAPIClient.loadPipelineRunWithLogs(event.getObjectId());
PipelineUser pipelineUser = users.get(run.getPipelineRun().getOwner());
run.setRunOwner(pipelineUser);
return Optional.of(new IndexRequest(indexName, INDEX_TYPE, String.valueOf(run.getPipelineRun().getId())).source(pipelineRunToDocument(run)));
} catch (PipelineResponseException e) {
log.error(e.getMessage(), e);
if (isRunMissingError(event, e)) {
return Optional.of(createDeleteRequest(event, indexName));
}
return Optional.empty();
}
}
use of com.epam.pipeline.entity.user.PipelineUser in project cloud-pipeline by epam.
the class ObjectCreationUtils method buildPipelineUser.
public static PipelineUser buildPipelineUser(final String name, final String prettyName, final List<String> groups) {
PipelineUser user = new PipelineUser();
user.setId(1L);
user.setUserName(name);
user.setGroups(groups);
if (StringUtils.isNotBlank(prettyName)) {
user.setAttributes(Collections.singletonMap(PRETTY_NAME_ATTRIBUTE, prettyName));
}
return user;
}
use of com.epam.pipeline.entity.user.PipelineUser in project cloud-pipeline by epam.
the class SMTPNotificationManagerTest method testEmailSendingWithParams.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testEmailSendingWithParams() {
PipelineUser user = new PipelineUser();
user.setUserName(USER_NAME);
user.setAdmin(true);
user.setAttributes(Collections.singletonMap(EMAIL_KEY, EMAIL));
userRepository.save(user);
NotificationMessage message = new NotificationMessage();
NotificationTemplate template = new NotificationTemplate();
template.setSubject(MESSAGE_SUBJECT);
template.setBody(MESSAGE_BODY_WITH_PARAM);
message.setTemplate(template);
message.setTemplateParameters(Collections.singletonMap("name", USER_NAME));
message.setToUserId(user.getId());
message.setCopyUserIds(Collections.singletonList(user.getId()));
smtpNotificationManager.notifySubscribers(message);
MimeMessage[] receivedMessages = greenMail.getReceivedMessages();
assertTrue(receivedMessages.length == 2);
String filledMessage = PARSED_MESSAGE_BODY_WITH_PARAM.replace("$templateParameters.get(\"name\")", USER_NAME);
assertTrue(GreenMailUtil.getBody(receivedMessages[0]).contains(filledMessage));
}
use of com.epam.pipeline.entity.user.PipelineUser in project cloud-pipeline by epam.
the class UserRepositoryTest method loadUserTest.
@Test
public void loadUserTest() {
PipelineUser user = new PipelineUser();
user.setUserName(USER_NAME);
user.setAdmin(true);
userRepository.save(user);
List<PipelineUser> users = userRepository.findByIdIn(Collections.singletonList(user.getId()));
Assert.assertTrue(users.size() == 1);
Assert.assertEquals(USER_NAME, users.get(0).getUserName());
}
Aggregations