use of com.epam.pipeline.entity.git.GitTagEntry in project cloud-pipeline by epam.
the class GitManagerTest method getConfigFile.
@Test
public void getConfigFile() {
final Pipeline pipeline = testingPipeline();
final String sha = "somecommitsha";
final Revision revision = new Revision("Initial commit", "", new Date(), DRAFT_PREFIX + sha);
pipeline.setCurrentVersion(revision);
final GitCommitEntry initialCommit = new GitCommitEntry();
initialCommit.setMessage("New pipeline initial commit");
initialCommit.setCreatedAt("2017-07-25T13:13:11Z");
initialCommit.setId(sha);
givenThat(get(urlPathEqualTo(api(REPOSITORY_COMMITS + "/" + initialCommit.getId()))).willReturn(okJson(with(initialCommit))));
final GitTagEntry tag = new GitTagEntry();
tag.setName(TEST_REVISION);
givenThat(get(urlPathEqualTo(api(REPOSITORY_TAGS + "/" + tag.getName()))).willReturn(okJson(with(tag))));
final File file = gitManager.getConfigFile(pipeline, pipeline.getCurrentVersion().getCommitId());
assertThat(file.getParentFile().exists(), is(true));
}
use of com.epam.pipeline.entity.git.GitTagEntry in project cloud-pipeline by epam.
the class GitManagerTest method shouldFetchPipelineDocs.
@Test
public void shouldFetchPipelineDocs() throws GitClientException {
final Pipeline pipeline = testingPipeline();
final GitRepositoryEntry bla = new GitRepositoryEntry();
bla.setName(README_FILE);
bla.setType(BLOB_TYPE);
final List<GitRepositoryEntry> tree = singletonList(bla);
givenThat(get(urlPathEqualTo(api(REPOSITORY_TREE))).withQueryParam(REF_NAME, equalTo(TEST_REVISION)).withQueryParam(PATH, equalTo(DOCS + "/")).withQueryParam(RECURSIVE, equalTo(String.valueOf(false))).willReturn(okJson(with(tree))));
final GitTagEntry tag = new GitTagEntry();
givenThat(get(urlPathEqualTo(api(REPOSITORY_TAGS + "/" + TEST_REVISION))).willReturn(okJson(with(tag))));
final List<GitRepositoryEntry> repoEntries = gitManager.getPipelineDocs(pipeline.getId(), TEST_REVISION);
final boolean noEntries = repoEntries.isEmpty();
final boolean docsOnly = repoEntries.stream().filter(e -> !e.getName().startsWith(".")).allMatch(e -> e.getName().endsWith(".md"));
assertFalse(noEntries);
assertTrue(docsOnly);
}
use of com.epam.pipeline.entity.git.GitTagEntry in project cloud-pipeline by epam.
the class GitManagerTest method shouldCreatePipelineRevision.
@Test
public void shouldCreatePipelineRevision() throws GitClientException {
final String sha = "anothercommitsha";
final GitCommitEntry commit = new GitCommitEntry();
commit.setId(sha);
commit.setAuthoredDate("2017-07-26T13:13:11Z");
final GitTagEntry tag = new GitTagEntry();
final String tagName = "v1.0.1";
tag.setName(tagName);
tag.setCommit(commit);
givenThat(post(urlPathEqualTo(api(REPOSITORY_TAGS))).withQueryParam(REF, equalTo(sha)).withQueryParam(TAG_NAME, equalTo(tagName)).willReturn(created().withHeader(CONTENT_TYPE, "application/json").withBody(with(tag))));
final Pipeline pipeline = testingPipeline();
final Revision revision = gitManager.createPipelineRevision(pipeline, tagName, sha, "Message", "Release description");
assertThat(revision.getName(), is(tag.getName()));
assertThat(revision.getMessage(), is(tag.getMessage()));
}
use of com.epam.pipeline.entity.git.GitTagEntry in project cloud-pipeline by epam.
the class GitManagerTest method getPipelineRevision.
@Test
public void getPipelineRevision() throws GitClientException {
final Pipeline pipeline = testingPipeline();
final GitTagEntry tag = new GitTagEntry();
givenThat(get(urlPathEqualTo(api(REPOSITORY_TAGS + "/" + TEST_REVISION))).willReturn(okJson(with(tag))));
final GitTagEntry revision = gitManager.loadRevision(pipeline, TEST_REVISION);
assertNotNull(revision);
}
use of com.epam.pipeline.entity.git.GitTagEntry in project cloud-pipeline by epam.
the class GitManagerTest method shouldLoadRevisionWhenItIsDraft.
@Test
public void shouldLoadRevisionWhenItIsDraft() throws GitClientException {
final Pipeline pipeline = testingPipeline();
final GitTagEntry tag = new GitTagEntry();
final String sha = "somecommitsha";
givenThat(get(urlPathEqualTo(api(REPOSITORY_COMMITS + "/" + sha))).willReturn(okJson(with(tag))));
final GitTagEntry revision = gitManager.loadRevision(pipeline, DRAFT_PREFIX + sha);
assertNotNull(revision);
}
Aggregations