use of com.epam.pipeline.entity.git.GitFile in project cloud-pipeline by epam.
the class GitManagerTest method shouldFetchConfigFileContent.
@Test
public void shouldFetchConfigFileContent() throws GitClientException {
final GitCommitEntry gitCommitEntry = new GitCommitEntry();
givenThat(post(urlPathEqualTo(api(REPOSITORY_COMMITS))).willReturn(okJson(with(gitCommitEntry))));
final GitTagEntry tag = new GitTagEntry();
tag.setName(TEST_REVISION);
givenThat(get(urlPathEqualTo(api(REPOSITORY_TAGS + "/" + tag.getName()))).willReturn(okJson(with(tag))));
final GitFile gitFile = new GitFile();
gitFile.setContent(Base64.getEncoder().encodeToString(FILE_CONTENT.getBytes()));
givenThat(get(urlPathEqualTo(api(REPOSITORY_FILES))).withQueryParam(FILE_PATH, equalTo("config.json")).withQueryParam(REF, equalTo(tag.getName())).willReturn(okJson(with(gitFile))));
final Pipeline pipeline = testingPipeline();
final String fileContent = gitManager.getConfigFileContent(pipeline, pipeline.getCurrentVersion().getName());
assertThat(fileContent, not(isEmptyString()));
}
use of com.epam.pipeline.entity.git.GitFile in project cloud-pipeline by epam.
the class GitManagerTest method shouldRenameFolder.
@Test
@Ignore
public void shouldRenameFolder() throws GitClientException {
final Pipeline pipeline = testingPipeline();
final PipelineSourceItemVO folder = new PipelineSourceItemVO();
folder.setPreviousPath(DOCS);
folder.setPath("doc");
folder.setLastCommitId(pipeline.getCurrentVersion().getCommitId());
final GitRepositoryEntry bla = new GitRepositoryEntry();
bla.setName(README_FILE);
bla.setType(BLOB_TYPE);
bla.setPath(DOCS + "/" + README_FILE);
final List<GitRepositoryEntry> tree = singletonList(bla);
givenThat(get(urlPathEqualTo(api(REPOSITORY_TREE))).withQueryParam(REF_NAME, equalTo(GIT_MASTER_REPOSITORY)).withQueryParam(PATH, equalTo(DOCS)).willReturn(okJson(with(tree))));
final GitFile file = new GitFile();
file.setContent(Base64.getEncoder().encodeToString(FILE_CONTENT.getBytes()));
givenThat(get(urlPathEqualTo(api(REPOSITORY_FILES))).withQueryParam(FILE_PATH, equalTo(DOCS + File.separator + ".gitkeep")).withQueryParam(REF, equalTo(GIT_MASTER_REPOSITORY)).willReturn(okJson(with(file))));
givenThat(get(urlPathEqualTo(api(REPOSITORY_FILES))).withQueryParam(FILE_PATH, equalTo("doc" + File.separator + ".gitkeep")).withQueryParam(REF, equalTo(GIT_MASTER_REPOSITORY)).willReturn(notFound()));
final GitCommitEntry expectedCommit = new GitCommitEntry();
givenThat(post(urlPathEqualTo(api(REPOSITORY_COMMITS))).willReturn(okJson(with(expectedCommit))));
final GitCommitEntry resultingCommit = gitManager.createOrRenameFolder(pipeline.getId(), folder);
assertThat(resultingCommit, is(expectedCommit));
}
Aggregations