Search in sources :

Example 31 with Pipeline

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

the class GitManagerTest method shouldNotFailWhenCreateFile.

@Test
public void shouldNotFailWhenCreateFile() throws GitClientException {
    final GitFile gitFile = new GitFile();
    gitFile.setContent(Base64.getEncoder().encodeToString(FILE_CONTENT.getBytes()));
    givenThat(get(urlPathEqualTo(api(REPOSITORY_FILES))).withQueryParam(FILE_PATH, equalTo(DOCS + "/created_file.txt")).withQueryParam(REF, equalTo(GIT_MASTER_REPOSITORY)).willReturn(okJson(with(gitFile))));
    final GitCommitEntry expectedCommit = new GitCommitEntry();
    givenThat(post(urlPathEqualTo(api(REPOSITORY_COMMITS))).willReturn(okJson(with(expectedCommit))));
    final Pipeline pipeline = testingPipeline();
    final GitCommitEntry resultingCommit = gitManager.updateFile(pipeline, DOCS + "/created_file.txt", FILE_CONTENT, "last commit id doesn't matter", "Create file");
    assertThat(resultingCommit, is(expectedCommit));
}
Also used : GitFile(com.epam.pipeline.entity.git.GitFile) GitCommitEntry(com.epam.pipeline.entity.git.GitCommitEntry) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test)

Example 32 with Pipeline

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

the class GitManagerTest method describePipelineManager.

@Before
public void describePipelineManager() {
    final Pipeline pipeline = testingPipeline();
    when(pipelineManagerMock.load(pipeline.getId())).thenReturn(pipeline);
    when(pipelineManagerMock.load(eq(pipeline.getId()), anyBoolean())).thenReturn(pipeline);
}
Also used : Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Before(org.junit.Before)

Example 33 with Pipeline

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

the class GitManagerTest method shouldRemoveFolder.

@Test
public void shouldRemoveFolder() throws GitClientException {
    final GitRepositoryEntry repositoryEntry = new GitRepositoryEntry();
    repositoryEntry.setName(README_FILE);
    repositoryEntry.setType(BLOB_TYPE);
    final List<GitRepositoryEntry> tree = singletonList(repositoryEntry);
    givenThat(get(urlPathEqualTo(api(REPOSITORY_TREE))).withQueryParam(REF_NAME, equalTo(GIT_MASTER_REPOSITORY)).withQueryParam(PATH, equalTo(DOCS)).withQueryParam(RECURSIVE, equalTo(String.valueOf(true))).willReturn(okJson(with(tree))));
    final GitCommitEntry expectedCommit = new GitCommitEntry();
    givenThat(post(urlPathEqualTo(api(REPOSITORY_COMMITS))).willReturn(okJson(with(expectedCommit))));
    final Pipeline pipeline = testingPipeline();
    final GitCommitEntry resultingCommit = gitManager.removeFolder(pipeline, DOCS, pipeline.getCurrentVersion().getCommitId(), "Remove the folder");
    assertThat(resultingCommit, is(expectedCommit));
}
Also used : GitRepositoryEntry(com.epam.pipeline.entity.git.GitRepositoryEntry) GitCommitEntry(com.epam.pipeline.entity.git.GitCommitEntry) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test)

Example 34 with Pipeline

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

the class PipelineManager method updateToken.

@Transactional(propagation = Propagation.REQUIRED)
public Pipeline updateToken(final PipelineVO pipelineVO) {
    Pipeline dbPipeline = load(pipelineVO.getId());
    dbPipeline.setRepositoryToken(pipelineVO.getRepositoryToken());
    setCurrentVersion(dbPipeline);
    if (!StringUtils.isEmpty(dbPipeline.getRepositoryError())) {
        throw new IllegalArgumentException(messageHelper.getMessage(MessageConstants.ERROR_REPO_TOKEN_INVALID, dbPipeline.getRepository(), dbPipeline.getRepositoryError()));
    }
    pipelineDao.updatePipeline(dbPipeline);
    return dbPipeline;
}
Also used : Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) Transactional(org.springframework.transaction.annotation.Transactional)

Example 35 with Pipeline

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

the class PipelineManager method load.

public Pipeline load(Long id, boolean loadVersion) {
    Pipeline pipeline = pipelineDao.loadPipeline(id);
    Assert.notNull(pipeline, messageHelper.getMessage(MessageConstants.ERROR_PIPELINE_NOT_FOUND, id));
    if (loadVersion) {
        setCurrentVersion(pipeline);
    }
    pipeline.setHasMetadata(this.metadataManager.hasMetadata(new EntityVO(id, AclClass.PIPELINE)));
    return pipeline;
}
Also used : EntityVO(com.epam.pipeline.controller.vo.EntityVO) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline)

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