use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.
the class NotificationManagerTest method createIssue.
private Issue createIssue(PipelineUser author, AbstractSecuredEntity entity) {
Issue issue = new Issue();
issue.setName("testIssue");
issue.setText("Notifying @TestUser1, @TestUser2, also add @admin here");
issue.setAuthor(author.getUserName());
issue.setEntity(new EntityVO(entity.getId(), entity.getAclClass()));
return issue;
}
use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.
the class NotificationManagerTest method testNotifyIssue.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testNotifyIssue() {
Pipeline pipeline = createPipeline(testOwner);
Issue issue = createIssue(testUser2, pipeline);
notificationManager.notifyIssue(issue, pipeline, issue.getText());
List<NotificationMessage> messages = monitoringNotificationDao.loadAllNotifications();
Assert.assertEquals(1, messages.size());
NotificationMessage message = messages.get(0);
Assert.assertEquals(testOwner.getId(), message.getToUserId());
Assert.assertTrue(message.getCopyUserIds().stream().anyMatch(id -> id.equals(testUser1.getId())));
Assert.assertTrue(message.getCopyUserIds().stream().anyMatch(id -> id.equals(testUser2.getId())));
Assert.assertTrue(message.getCopyUserIds().stream().anyMatch(id -> id.equals(admin.getId())));
updateKeepInformedOwner(issueSettings, false);
notificationManager.notifyIssue(issue, pipeline, issue.getText());
messages = monitoringNotificationDao.loadAllNotifications();
Assert.assertEquals(2, messages.size());
Assert.assertNull(messages.get(1).getToUserId());
}
use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.
the class IssueMapper method map.
@Override
public XContentBuilder map(final EntityContainer<Issue> container) {
Issue issue = container.getEntity();
try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
jsonBuilder.startObject();
jsonBuilder.field(DOC_TYPE_FIELD, SearchDocumentType.ISSUE.name()).field("id", issue.getId()).field("name", issue.getName()).field("text", issue.getText()).field("status", issue.getStatus()).field("createdDate", parseDataToString(issue.getCreatedDate())).field("updatedDate", parseDataToString(issue.getUpdatedDate()));
buildLabels(issue.getLabels(), jsonBuilder);
buildAttachments(issue.getAttachments(), jsonBuilder);
buildEntityVO(issue.getEntity(), jsonBuilder);
buildComments(issue.getComments(), jsonBuilder);
buildPermissions(container.getPermissions(), jsonBuilder);
buildUserContent(container.getOwner(), jsonBuilder);
jsonBuilder.endObject();
return jsonBuilder;
} catch (IOException e) {
throw new IllegalArgumentException("Failed to create elasticsearch document for issue: ", e);
}
}
use of com.epam.pipeline.entity.issue.Issue in project cloud-pipeline by epam.
the class IssueMapperTest method shouldMapIssue.
@Test
void shouldMapIssue() throws IOException {
IssueMapper mapper = new IssueMapper();
Attachment attachment = new Attachment();
attachment.setPath(TEST_PATH);
attachment.setOwner(USER_NAME);
IssueComment comment = IssueComment.builder().author(USER_NAME).text(TEST_DESCRIPTION).build();
EntityVO entity = new EntityVO(1L, AclClass.TOOL);
Issue issue = Issue.builder().id(1L).name(TEST_NAME).text(TEST_DESCRIPTION).status(IssueStatus.OPEN).labels(Collections.singletonList(TEST_LABEL)).attachments(Collections.singletonList(attachment)).comments(Collections.singletonList(comment)).entity(entity).build();
EntityContainer<Issue> container = EntityContainer.<Issue>builder().entity(issue).owner(USER).permissions(PERMISSIONS_CONTAINER).build();
XContentBuilder contentBuilder = mapper.map(container);
verifyIssue(issue, contentBuilder);
verifyAttachments(Collections.singletonList(attachment.getPath()), contentBuilder);
verifyComments(Collections.singletonList(comment.getAuthor() + " : " + comment.getText()), contentBuilder);
verifyPipelineUser(USER, contentBuilder);
verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder);
}
Aggregations