Search in sources :

Example 86 with Pipeline

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

the class PipelineCodeMapperTest method shouldMapPipelineCode.

@Test
void shouldMapPipelineCode() throws IOException {
    PipelineCodeMapper mapper = new PipelineCodeMapper();
    Pipeline pipeline = new Pipeline();
    pipeline.setId(1L);
    pipeline.setName(TEST_NAME);
    XContentBuilder contentBuilder = mapper.pipelineCodeToDocument(pipeline, TEST_VERSION, TEST_PATH, TEST_VALUE, PERMISSIONS_CONTAINER);
    verifyPipelineCode(pipeline, TEST_VERSION, TEST_PATH, TEST_VALUE, contentBuilder);
    verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder);
}
Also used : XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Test(org.junit.jupiter.api.Test)

Example 87 with Pipeline

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

the class PipelineLoaderTest method shouldLoadPipeline.

@Test
void shouldLoadPipeline() throws EntityNotFoundException {
    Pipeline expectedPipeline = new Pipeline(1L);
    expectedPipeline.setName(TEST_NAME);
    expectedPipeline.setCreatedDate(DateUtils.now());
    expectedPipeline.setParentFolderId(2L);
    expectedPipeline.setDescription(TEST_DESCRIPTION);
    expectedPipeline.setRepository(TEST_REPO);
    expectedPipeline.setTemplateId(TEST_TEMPLATE);
    expectedPipeline.setOwner(TEST_NAME);
    Revision expectedRevision = new Revision();
    expectedRevision.setName(TEST_NAME);
    PipelineLoader pipelineLoader = new PipelineLoader(apiClient);
    when(apiClient.loadPipeline(anyString())).thenReturn(expectedPipeline);
    when(apiClient.loadPipelineVersions(anyLong())).thenReturn(Collections.singletonList(expectedRevision));
    Optional<EntityContainer<PipelineDoc>> container = pipelineLoader.loadEntity(1L);
    EntityContainer<PipelineDoc> pipelineDocEntityContainer = container.orElseThrow(AssertionError::new);
    PipelineDoc actualPipelineDoc = pipelineDocEntityContainer.getEntity();
    assertNotNull(actualPipelineDoc);
    Pipeline actualPipeline = actualPipelineDoc.getPipeline();
    assertNotNull(actualPipeline);
    List<Revision> revisions = actualPipelineDoc.getRevisions();
    assertNotNull(revisions);
    assertEquals(expectedPipeline.getId(), actualPipeline.getId());
    assertEquals(expectedPipeline.getName(), actualPipeline.getName());
    assertEquals(expectedPipeline.getCreatedDate(), actualPipeline.getCreatedDate());
    assertEquals(expectedPipeline.getParentFolderId(), actualPipeline.getParentFolderId());
    assertEquals(expectedPipeline.getDescription(), actualPipeline.getDescription());
    assertEquals(expectedPipeline.getRepository(), actualPipeline.getRepository());
    assertEquals(expectedPipeline.getTemplateId(), actualPipeline.getTemplateId());
    verifyPipelineUser(pipelineDocEntityContainer.getOwner());
    verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, pipelineDocEntityContainer.getPermissions());
    verifyMetadata(EXPECTED_METADATA, new ArrayList<>(pipelineDocEntityContainer.getMetadata().values()));
}
Also used : Revision(com.epam.pipeline.entity.pipeline.Revision) EntityContainer(com.epam.pipeline.elasticsearchagent.model.EntityContainer) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) PipelineDoc(com.epam.pipeline.elasticsearchagent.model.PipelineDoc) Test(org.junit.jupiter.api.Test)

Example 88 with Pipeline

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

the class PipelineMapperTest method shouldMapPipeline.

@Test
void shouldMapPipeline() throws IOException {
    PipelineMapper mapper = new PipelineMapper();
    Pipeline pipeline = new Pipeline();
    pipeline.setId(1L);
    pipeline.setName(TEST_NAME);
    pipeline.setCreatedDate(DateUtils.now());
    pipeline.setParentFolderId(2L);
    pipeline.setDescription(TEST_DESCRIPTION);
    pipeline.setRepository(TEST_REPO);
    pipeline.setTemplateId(TEST_TEMPLATE);
    Revision revision = new Revision();
    revision.setName(TEST_NAME);
    PipelineDoc pipelineDoc = PipelineDoc.builder().pipeline(pipeline).revisions(Collections.singletonList(revision)).build();
    EntityContainer<PipelineDoc> container = EntityContainer.<PipelineDoc>builder().entity(pipelineDoc).owner(USER).metadata(METADATA).permissions(PERMISSIONS_CONTAINER).build();
    XContentBuilder contentBuilder = mapper.map(container);
    verifyPipeline(pipeline, contentBuilder);
    verifyPipelineUser(USER, contentBuilder);
    verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder);
    verifyMetadata(EXPECTED_METADATA, contentBuilder);
}
Also used : Revision(com.epam.pipeline.entity.pipeline.Revision) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) MapperVerificationUtils.verifyPipeline(com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyPipeline) PipelineDoc(com.epam.pipeline.elasticsearchagent.model.PipelineDoc) Test(org.junit.jupiter.api.Test)

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