use of com.epam.pipeline.entity.issue.Attachment 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.Attachment 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