use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.
the class SecuredEntityDeletionAspect method deleteSecuredEntity.
@AfterReturning(pointcut = "@within(com.epam.pipeline.manager.security.acl.AclSync) && " + "execution(* *.delete(..))", returning = RETURN_OBJECT)
@Transactional(propagation = Propagation.REQUIRED)
public void deleteSecuredEntity(JoinPoint joinPoint, AbstractSecuredEntity entity) {
EntityVO entityVO = new EntityVO(entity.getId(), entity.getAclClass());
LOGGER.debug("Deleting issues for Object {} {}", entity.getName(), entity.getClass());
issueManager.deleteIssuesForEntity(entityVO);
LOGGER.debug("Deleting metadata for Object {} {}", entity.getName(), entity.getClass());
metadataManager.deleteMetadata(entityVO);
}
use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.
the class SecuredEntityDeletionAspect method deleteRole.
@AfterReturning(pointcut = "execution(* *.deleteRole(..))", returning = ROLE)
@Transactional(propagation = Propagation.REQUIRED)
public void deleteRole(JoinPoint joinPoint, Role role) {
LOGGER.debug("Deleting metadata for Object {} {}", role.getName(), AclClass.ROLE);
metadataManager.deleteMetadata(new EntityVO(role.getId(), AclClass.ROLE));
}
use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.
the class AttachmentDaoTest method setUp.
@Before
public void setUp() throws Exception {
EntityVO entity = new EntityVO(1L, AclClass.PIPELINE);
issue = IssueDaoTest.getIssue("test", entity);
issueDao.createIssue(issue);
comment = IssueCommentDaoTest.getComment(issue, "test");
issueCommentDao.createComment(comment);
}
use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.
the class IssueDaoTest method testCRUD.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testCRUD() {
EntityVO entity = new EntityVO(ENTITY_ID, ENTITY_CLASS);
Issue issue = getIssue(NAME, entity);
// create
issueDao.createIssue(issue);
Long id = issue.getId();
// load
Optional<Issue> loaded = issueDao.loadIssue(id);
assertTrue(loaded.isPresent());
verifyIssue(issue, loaded.get());
Issue issue2 = getIssue(NAME2, entity);
issueDao.createIssue(issue2);
List<Issue> issues = issueDao.loadIssuesForEntity(entity);
assertEquals(2, issues.size());
// update
issue.setName(NAME3);
issue.setText(TEXT2);
issue.setStatus(STATUS);
issueDao.updateIssue(issue);
Optional<Issue> updated = issueDao.loadIssue(id);
assertTrue(updated.isPresent());
assertEquals(NAME3, updated.get().getName());
assertEquals(STATUS, updated.get().getStatus());
// delete
issueDao.deleteIssue(issue.getId());
Optional<Issue> deleted = issueDao.loadIssue(id);
assertFalse(deleted.isPresent());
}
use of com.epam.pipeline.controller.vo.EntityVO in project cloud-pipeline by epam.
the class IssueDaoTest method testLoadPagedByAuthor.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class)
public void testLoadPagedByAuthor() {
for (int i = 0; i < TEST_ISSUES_COUNT; i++) {
EntityVO entity = new EntityVO(ENTITY_ID, ENTITY_CLASS);
Issue issue = getIssue(NAME + i, entity);
issueDao.createIssue(issue);
}
int maxPage = (int) Math.ceil((float) TEST_ISSUES_COUNT / TEST_PAGE_SIZE);
Set<Long> seenIssueIds = new HashSet<>();
for (int i = 1; i < maxPage + 1; i++) {
List<Issue> issues = issueDao.loadIssuesByAuthor(AUTHOR, (long) i, TEST_PAGE_SIZE);
assertFalse(issues.isEmpty());
if (i < maxPage) {
assertEquals(TEST_PAGE_SIZE, issues.size());
}
assertTrue(issues.stream().noneMatch(issue -> seenIssueIds.contains(issue.getId())));
seenIssueIds.addAll(issues.stream().map(Issue::getId).collect(Collectors.toSet()));
}
assertEquals(TEST_ISSUES_COUNT, seenIssueIds.size());
assertEquals(TEST_ISSUES_COUNT, issueDao.countIssuesByAuthor(AUTHOR));
}
Aggregations