Search in sources :

Example 21 with EntityVO

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);
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) AfterReturning(org.aspectj.lang.annotation.AfterReturning) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with 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));
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) AfterReturning(org.aspectj.lang.annotation.AfterReturning) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with EntityVO

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);
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Before(org.junit.Before)

Example 24 with EntityVO

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());
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Issue(com.epam.pipeline.entity.issue.Issue) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 25 with EntityVO

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));
}
Also used : Arrays(java.util.Arrays) Assert.assertTrue(org.junit.Assert.assertTrue) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) IssueStatus(com.epam.pipeline.entity.issue.IssueStatus) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) HashSet(java.util.HashSet) List(java.util.List) Stream(java.util.stream.Stream) Propagation(org.springframework.transaction.annotation.Propagation) Assert.assertFalse(org.junit.Assert.assertFalse) Map(java.util.Map) Optional(java.util.Optional) AclClass(com.epam.pipeline.entity.security.acl.AclClass) Issue(com.epam.pipeline.entity.issue.Issue) Assert.assertEquals(org.junit.Assert.assertEquals) EntityVO(com.epam.pipeline.controller.vo.EntityVO) Transactional(org.springframework.transaction.annotation.Transactional) EntityVO(com.epam.pipeline.controller.vo.EntityVO) Issue(com.epam.pipeline.entity.issue.Issue) HashSet(java.util.HashSet) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

EntityVO (com.epam.pipeline.controller.vo.EntityVO)40 Transactional (org.springframework.transaction.annotation.Transactional)22 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)14 Test (org.junit.Test)14 Folder (com.epam.pipeline.entity.pipeline.Folder)13 MetadataEntry (com.epam.pipeline.entity.metadata.MetadataEntry)12 Issue (com.epam.pipeline.entity.issue.Issue)11 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)8 HashMap (java.util.HashMap)5 IssueVO (com.epam.pipeline.controller.vo.IssueVO)4 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)4 Before (org.junit.Before)4 Attachment (com.epam.pipeline.entity.issue.Attachment)3 AclClass (com.epam.pipeline.entity.security.acl.AclClass)3 Date (java.util.Date)3 Map (java.util.Map)3 AfterReturning (org.aspectj.lang.annotation.AfterReturning)3 MetadataVO (com.epam.pipeline.controller.vo.MetadataVO)2 MetadataEntityVO (com.epam.pipeline.controller.vo.metadata.MetadataEntityVO)2 IssueComment (com.epam.pipeline.entity.issue.IssueComment)2