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));
}
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);
}
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));
}
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;
}
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;
}
Aggregations