use of com.thoughtworks.go.config.TestArtifactPlan in project gocd by gocd.
the class PipelineBean method getArtifactPlans.
public ArtifactPlans getArtifactPlans() {
ArtifactPlans artifactPlans = new ArtifactPlans();
for (int i = 0; i < src.length; i++) {
if (isBlank(src[i])) {
continue;
}
ArtifactPlan plan;
if (StringUtils.equals(type[i], "test")) {
plan = new TestArtifactPlan();
} else {
plan = new ArtifactPlan();
}
plan.setSrc(defaultString(src[i]));
plan.setDest(defaultString(dest[i]));
artifactPlans.add(plan);
}
return artifactPlans;
}
use of com.thoughtworks.go.config.TestArtifactPlan in project gocd by gocd.
the class ArtifactPlansTest method shouldLoadArtifactPlans.
@Test
public void shouldLoadArtifactPlans() {
HashMap<String, String> artifactPlan1 = new HashMap<>();
artifactPlan1.put(SRC, "blah");
artifactPlan1.put(DEST, "something");
artifactPlan1.put("artifactTypeValue", TestArtifactPlan.TEST_PLAN_DISPLAY_NAME);
HashMap<String, String> artifactPlan2 = new HashMap<>();
artifactPlan2.put(SRC, "blah2");
artifactPlan2.put(DEST, "something2");
artifactPlan2.put("artifactTypeValue", ArtifactPlan.ARTIFACT_PLAN_DISPLAY_NAME);
List<HashMap> artifactPlansList = new ArrayList<>();
artifactPlansList.add(artifactPlan1);
artifactPlansList.add(artifactPlan2);
ArtifactPlans artifactPlans = new ArtifactPlans();
artifactPlans.setConfigAttributes(artifactPlansList);
assertThat(artifactPlans.size(), is(2));
TestArtifactPlan plan = new TestArtifactPlan();
plan.setSrc("blah");
plan.setDest("something");
assertThat(artifactPlans.get(0), is(plan));
assertThat(artifactPlans.get(1), is(new ArtifactPlan("blah2", "something2")));
}
use of com.thoughtworks.go.config.TestArtifactPlan in project gocd by gocd.
the class ArtifactPlansTest method setConfigAttributes_shouldIgnoreEmptySourceAndDest.
@Test
public void setConfigAttributes_shouldIgnoreEmptySourceAndDest() {
HashMap<String, String> artifactPlan1 = new HashMap<>();
artifactPlan1.put(SRC, "blah");
artifactPlan1.put(DEST, "something");
artifactPlan1.put("artifactTypeValue", TestArtifactPlan.TEST_PLAN_DISPLAY_NAME);
HashMap<String, String> artifactPlan2 = new HashMap<>();
artifactPlan2.put(SRC, "blah2");
artifactPlan2.put(DEST, "something2");
artifactPlan2.put("artifactTypeValue", ArtifactPlan.ARTIFACT_PLAN_DISPLAY_NAME);
HashMap<String, String> artifactPlan3 = new HashMap<>();
artifactPlan3.put(SRC, "");
artifactPlan3.put(DEST, "");
artifactPlan3.put("artifactTypeValue", ArtifactPlan.ARTIFACT_PLAN_DISPLAY_NAME);
List<HashMap> artifactPlansList = new ArrayList<>();
artifactPlansList.add(artifactPlan1);
artifactPlansList.add(artifactPlan3);
artifactPlansList.add(artifactPlan2);
ArtifactPlans artifactPlans = new ArtifactPlans();
artifactPlans.setConfigAttributes(artifactPlansList);
assertThat(artifactPlans.size(), is(2));
TestArtifactPlan plan = new TestArtifactPlan();
plan.setSrc("blah");
plan.setDest("something");
assertThat(artifactPlans.get(0), is(plan));
assertThat(artifactPlans.get(1), is(new ArtifactPlan("blah2", "something2")));
}
use of com.thoughtworks.go.config.TestArtifactPlan in project gocd by gocd.
the class ArtifactPlanRepositoryIntegrationTest method shouldLoadSavedArtifactPlanWithTypeUnit.
@Test
public void shouldLoadSavedArtifactPlanWithTypeUnit() {
// Arrange
JobInstance jobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME));
ArtifactPlan savedArtifactPlan = new TestArtifactPlan("src", "dest");
savedArtifactPlan.setBuildId(jobInstance.getId());
artifactPlanRepository.save(savedArtifactPlan);
// Act
List<ArtifactPlan> artifactPlanList = artifactPlanRepository.findByBuildId(jobInstance.getId());
// Assert
assertThat(artifactPlanList.size(), is(1));
assertThat(artifactPlanList.get(0), is(savedArtifactPlan));
}
use of com.thoughtworks.go.config.TestArtifactPlan in project gocd by gocd.
the class ArtifactPlanRepositoryIntegrationTest method shouldLoadSavedTestArtifactPlan.
@Test
public void shouldLoadSavedTestArtifactPlan() {
// Arrange
JobInstance jobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME));
ArtifactPlan savedArtifactPlan = new TestArtifactPlan();
savedArtifactPlan.setBuildId(jobInstance.getId());
artifactPlanRepository.save(savedArtifactPlan);
// Act
List<ArtifactPlan> artifactPlanList = artifactPlanRepository.findByBuildId(jobInstance.getId());
// Assert
assertThat(artifactPlanList.size(), is(1));
ArtifactPlan loadedArtifactPlan = artifactPlanList.get(0);
assertThat(loadedArtifactPlan, is(savedArtifactPlan));
}
Aggregations