use of com.epam.pipeline.entity.git.GitCommitEntry in project cloud-pipeline by epam.
the class GitManagerTest method shouldCreateFolder.
@Test
public void shouldCreateFolder() throws GitClientException {
final Pipeline pipeline = testingPipeline();
final PipelineSourceItemVO folder = new PipelineSourceItemVO();
folder.setPath(DOCS);
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))));
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));
}
use of com.epam.pipeline.entity.git.GitCommitEntry 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.git.GitCommitEntry 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.git.GitCommitEntry in project cloud-pipeline by epam.
the class GitManagerTest method shouldDeleteFile.
@Test
public void shouldDeleteFile() throws GitClientException {
final Revision revision = new Revision("Initial commit", "", new Date(), "doesn't matter");
final Pipeline pipeline = testingPipeline();
pipeline.setCurrentVersion(revision);
final GitCommitEntry expectedCommit = new GitCommitEntry();
givenThat(post(urlPathEqualTo(api(REPOSITORY_COMMITS))).willReturn(okJson(with(expectedCommit))));
final GitCommitEntry resultingCommit = gitManager.deleteFile(pipeline, DOCS + "/" + README_FILE, pipeline.getCurrentVersion().getCommitId(), "Delete file");
assertThat(resultingCommit, is(expectedCommit));
}
use of com.epam.pipeline.entity.git.GitCommitEntry in project cloud-pipeline by epam.
the class GitManagerTest method shouldFetchRevision.
@Test
public void shouldFetchRevision() throws GitClientException {
final Pipeline pipeline = testingPipeline();
final long pageSize = 1;
final List<GitTagEntry> tags = Collections.emptyList();
givenThat(get(urlPathEqualTo(api(REPOSITORY_TAGS))).withQueryParam("per_page", equalTo(String.valueOf(pageSize))).willReturn(okJson(with(tags))));
final GitCommitEntry initialCommit = new GitCommitEntry();
initialCommit.setMessage("New pipeline initial commit");
initialCommit.setCreatedAt("2017-07-25T13:13:11Z");
final List<GitCommitEntry> commits = singletonList(initialCommit);
givenThat(get(urlPathEqualTo(api(REPOSITORY_COMMITS))).willReturn(okJson(with(commits))));
final List<Revision> revisions = gitManager.getPipelineRevisions(pipeline, pageSize);
assertFalse(revisions.isEmpty());
}
Aggregations