Search in sources :

Example 21 with Pipeline

use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.

the class PipelineRunDaoTest method runPipelineWithRunSids.

@Test
public void runPipelineWithRunSids() {
    List<RunSid> runSids = new ArrayList<>();
    RunSid runSid1 = new RunSid();
    runSid1.setName(TEST_USER);
    runSid1.setIsPrincipal(true);
    runSids.add(runSid1);
    RunSid runSid2 = new RunSid();
    runSid2.setName(GROUP_NAME);
    runSid2.setIsPrincipal(false);
    runSids.add(runSid2);
    Pipeline testPipeline = getPipeline();
    PipelineRun run = createRunWithRunSids(testPipeline.getId(), null, runSids);
    PipelineRun loadedRun = pipelineRunDao.loadPipelineRun(run.getId());
    assertTrue(runSids.equals(loadedRun.getRunSids()));
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) RunSid(com.epam.pipeline.entity.pipeline.run.parameter.RunSid) ArrayList(java.util.ArrayList) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 22 with Pipeline

use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.

the class PipelineRunDaoTest method searchGroupingRun.

@Test
public void searchGroupingRun() {
    Pipeline testPipeline = getPipeline();
    PipelineRun parent = createRun(testPipeline.getId(), null, TaskStatus.SUCCESS, null);
    PipelineRun child = createRun(testPipeline.getId(), null, TaskStatus.SUCCESS, parent.getId());
    PipelineRun lonely = createRun(testPipeline.getId(), null, TaskStatus.SUCCESS, null);
    PagingRunFilterVO filterVO = new PagingRunFilterVO();
    filterVO.setPage(1);
    filterVO.setPageSize(TEST_PAGE_SIZE);
    filterVO.setStatuses(Collections.singletonList(TaskStatus.SUCCESS));
    List<PipelineRun> runs = pipelineRunDao.searchPipelineGroups(filterVO, null);
    assertEquals(2, runs.size());
    assertEquals(lonely.getId(), runs.get(0).getId());
    assertEquals(parent.getId(), runs.get(1).getId());
    assertEquals(1, runs.get(1).getChildRuns().size());
    assertEquals(child.getId(), runs.get(1).getChildRuns().get(0).getId());
    assertEquals(2L, pipelineRunDao.countRootRuns(filterVO, null).longValue());
}
Also used : PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) PagingRunFilterVO(com.epam.pipeline.controller.vo.PagingRunFilterVO) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) EnvVarsBuilderTest(com.epam.pipeline.manager.execution.EnvVarsBuilderTest) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Test(org.junit.Test)

Example 23 with Pipeline

use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.

the class RunStatusDaoTest method setup.

@Before
public void setup() {
    testPipeline = new Pipeline();
    testPipeline.setName(TEST_NAME);
    testPipeline.setRepository(TEST_REPOSITORY);
    testPipeline.setOwner(TEST_NAME);
    pipelineDao.createPipeline(testPipeline);
    testRun = ObjectCreatorUtils.createPipelineRun(1L, testPipeline.getId(), null);
    pipelineRunDao.createPipelineRun(testRun);
}
Also used : Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Before(org.junit.Before)

Example 24 with Pipeline

use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.

the class PipelineDaoTest method assertPipelineWithParameters.

private void assertPipelineWithParameters(List<Pipeline> expected, Integer pageNum, Integer pageSize) {
    Set<Pipeline> loaded = pipelineDao.loadAllPipelinesWithParents(pageNum, pageSize);
    assertEquals(expected.size(), loaded.size());
    Map<Long, Pipeline> expectedMap = expected.stream().collect(Collectors.toMap(Pipeline::getId, Function.identity()));
    loaded.forEach(pipeline -> {
        Pipeline expectedPipeline = expectedMap.get(pipeline.getId());
        assertEquals(expectedPipeline.getName(), pipeline.getName());
        Folder expectedParent = expectedPipeline.getParent();
        Folder actualParent = pipeline.getParent();
        while (expectedParent != null) {
            assertEquals(expectedParent.getId(), actualParent.getId());
            expectedParent = expectedParent.getParent();
            actualParent = actualParent.getParent();
        }
    });
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

Example 25 with Pipeline

use of com.epam.pipeline.entity.pipeline.Pipeline in project cloud-pipeline by epam.

the class PipelineDaoTest method shouldLoadPipelineWithFolders.

@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldLoadPipelineWithFolders() {
    Folder root = buildFolder(null);
    root.setParentId(0L);
    Folder folder = buildFolder(root.getId());
    folder.setParent(root);
    Folder parent = buildFolder(folder.getId());
    parent.setParent(folder);
    Pipeline pipeline = getPipeline(TEST_NAME);
    pipeline.setParentFolderId(parent.getId());
    pipelineDao.createPipeline(pipeline);
    Pipeline loaded = pipelineDao.loadPipelineWithParents(pipeline.getId());
    verifyFolderTree(loaded.getParent(), parent);
}
Also used : Folder(com.epam.pipeline.entity.pipeline.Folder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Test(org.junit.Test) AbstractSpringTest(com.epam.pipeline.AbstractSpringTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)88 Test (org.junit.Test)41 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)25 Transactional (org.springframework.transaction.annotation.Transactional)18 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)16 GitCommitEntry (com.epam.pipeline.entity.git.GitCommitEntry)14 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)13 Revision (com.epam.pipeline.entity.pipeline.Revision)12 Folder (com.epam.pipeline.entity.pipeline.Folder)10 Before (org.junit.Before)9 GitFile (com.epam.pipeline.entity.git.GitFile)8 GitRepositoryEntry (com.epam.pipeline.entity.git.GitRepositoryEntry)7 EnvVarsBuilderTest (com.epam.pipeline.manager.execution.EnvVarsBuilderTest)7 Date (java.util.Date)7 List (java.util.List)7 GitTagEntry (com.epam.pipeline.entity.git.GitTagEntry)6 PipelineUser (com.epam.pipeline.entity.user.PipelineUser)6 IsEmptyString.isEmptyString (org.hamcrest.text.IsEmptyString.isEmptyString)6 Matchers.anyString (org.mockito.Matchers.anyString)6 EntityVO (com.epam.pipeline.controller.vo.EntityVO)5