use of com.epam.pipeline.entity.issue.IssueComment in project cloud-pipeline by epam.
the class IssueManagerTest method testUpdateComment.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testUpdateComment() {
Issue issue = registerIssue();
Long issueId = issue.getId();
IssueCommentVO commentVO = getCommentVO(COMMENT_TEXT);
IssueComment comment = issueManager.createComment(issueId, commentVO);
IssueCommentVO updated = new IssueCommentVO();
updated.setText(COMMENT_TEXT2);
Long commentId = comment.getId();
issueManager.updateComment(issueId, comment.getId(), updated);
assertEquals(COMMENT_TEXT2, issueManager.loadComment(issueId, commentId).getText());
}
use of com.epam.pipeline.entity.issue.IssueComment in project cloud-pipeline by epam.
the class IssueApiServiceTest method testIssueOwnerCRUD.
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
@WithMockUser(username = USER_OWNER)
@Test
public void testIssueOwnerCRUD() {
Issue issue = issueApiService.createIssue(getIssueVO(ISSUE_NAME, ISSUE_TEXT, entityVO));
Issue loaded = issueApiService.loadIssue(issue.getId());
Assert.assertNotNull(loaded);
List<Issue> loadedIssues = issueApiService.loadIssuesForEntity(entityVO);
Assert.assertNotNull(loadedIssues);
issueApiService.updateIssue(issue.getId(), getIssueVO(ISSUE_NAME, ISSUE_TEXT + "!", entityVO));
IssueCommentVO issueCommentVO = new IssueCommentVO();
issueCommentVO.setText(COMMENT_TEXT);
IssueComment comment = issueApiService.createComment(issue.getId(), issueCommentVO);
IssueComment loadedComment = issueApiService.loadComment(issue.getId(), comment.getId());
Assert.assertNotNull(loadedComment);
issueCommentVO.setText(COMMENT_TEXT + "!");
issueApiService.updateComment(issue.getId(), comment.getId(), issueCommentVO);
issueApiService.deleteComment(issue.getId(), comment.getId());
issueApiService.deleteIssue(issue.getId());
}
use of com.epam.pipeline.entity.issue.IssueComment in project cloud-pipeline by epam.
the class IssueApiServiceTest method testLoadCommentForNotOwner.
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
@WithMockUser(username = CAN_READ_USER)
@Test
public void testLoadCommentForNotOwner() {
IssueComment loadedComment = issueApiService.loadComment(createdIssue.getId(), createdIssueComment.getId());
Assert.assertNotNull(loadedComment);
}
use of com.epam.pipeline.entity.issue.IssueComment in project cloud-pipeline by epam.
the class IssueApiServiceTest method setUp.
@Before
public void setUp() {
Folder folder = new Folder();
folder.setName(TEST_FOLDER_NAME);
folder.setOwner(USER_OWNER);
folderDao.createFolder(folder);
// Mock ACL
AclTestDao.AclSid testUserSid = new AclTestDao.AclSid(true, USER_OWNER);
aclTestDao.createAclSid(testUserSid);
AclTestDao.AclClass folderAclClass = new AclTestDao.AclClass(Folder.class.getCanonicalName());
aclTestDao.createAclClassIfNotPresent(folderAclClass);
AclTestDao.AclObjectIdentity objectIdentity = new AclTestDao.AclObjectIdentity(testUserSid, folder.getId(), folderAclClass.getId(), null, true);
aclTestDao.createObjectIdentity(objectIdentity);
AclTestDao.AclEntry aclEntry = new AclTestDao.AclEntry(objectIdentity, 1, testUserSid, AclPermission.READ.getMask(), true);
aclTestDao.createAclEntry(aclEntry);
AclTestDao.AclSid noPermissionUserSid = new AclTestDao.AclSid(true, NO_PERMISSION_USER);
aclTestDao.createAclSid(noPermissionUserSid);
entityVO = new EntityVO(folder.getId(), AclClass.FOLDER);
createdIssue = new Issue();
createdIssue.setName(ISSUE_NAME);
createdIssue.setText(ISSUE_TEXT);
createdIssue.setAuthor(USER_OWNER);
createdIssue.setEntity(entityVO);
createdIssue.setStatus(IssueStatus.OPEN);
issueDao.createIssue(createdIssue);
createdIssueComment = new IssueComment();
createdIssueComment.setIssueId(createdIssue.getId());
createdIssueComment.setAuthor(USER_OWNER);
createdIssueComment.setText(COMMENT_TEXT);
issueCommentDao.createComment(createdIssueComment);
AclTestDao.AclSid canReadUserSid = new AclTestDao.AclSid(true, CAN_READ_USER);
aclTestDao.createAclSid(canReadUserSid);
aclEntry = new AclTestDao.AclEntry(objectIdentity, 2, canReadUserSid, AclPermission.READ.getMask(), true);
aclTestDao.createAclEntry(aclEntry);
verify(notificationManager, Mockito.never()).notifyIssue(any(), any(), any());
Mockito.doNothing().when(attachmentFileManager).deleteAttachments(Mockito.anyListOf(Attachment.class));
attachment = new Attachment();
attachment.setName("testAttachment");
attachment.setCreatedDate(new Date());
attachment.setPath("///");
attachment.setOwner(TEST_USER);
attachmentDao.createAttachment(attachment);
Mockito.doNothing().when(attachmentFileManager).deleteAttachments(Mockito.anyListOf(Attachment.class));
}
use of com.epam.pipeline.entity.issue.IssueComment 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