use of com.thoughtworks.go.config.ArtifactPlans 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.ArtifactPlans in project gocd by gocd.
the class PipelineBeanTest method shouldReturnArtifact.
@Test
public void shouldReturnArtifact() throws Exception {
String[] src = new String[] { "log/log.xml", "logoutput/log.xml" };
String[] dest = new String[] { "test/test1", "" };
String[] type = new String[] { "artifact", "test" };
PipelineBean bean = new PipelineBean("", null, "ant", "build.xml", "clean", src, dest, type, null, null);
ArtifactPlans artifactPlans = bean.getArtifactPlans();
ArtifactPlan artifactPlan = artifactPlans.get(0);
assertThat(artifactPlan.getSrc(), is("log/log.xml"));
assertThat(artifactPlan.getDest(), is("test/test1"));
assertThat(artifactPlan, is(instanceOf(ArtifactPlan.class)));
}
use of com.thoughtworks.go.config.ArtifactPlans in project gocd by gocd.
the class PipelineBeanTest method shouldReturnTestArtifact.
@Test
public void shouldReturnTestArtifact() throws Exception {
String[] src = new String[] { "log/log.xml", "logoutput/log.xml" };
String[] dest = new String[] { "test/test1", "" };
String[] type = new String[] { "artifact", "test" };
PipelineBean bean = new PipelineBean("", null, "ant", "build.xml", "clean", src, dest, type, null, null);
ArtifactPlans artifactPlans = bean.getArtifactPlans();
ArtifactPlan artifactPlan = artifactPlans.get(1);
assertThat(artifactPlan.getSrc(), is("logoutput/log.xml"));
assertThat(artifactPlan.getDest(), is(""));
assertThat(artifactPlan, is(instanceOf(TestArtifactPlan.class)));
}
use of com.thoughtworks.go.config.ArtifactPlans 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.ArtifactPlans in project gocd by gocd.
the class ArtifactPlansTest method shouldValidateTree.
@Test
public void shouldValidateTree() {
ArtifactPlans artifactPlans = new ArtifactPlans();
artifactPlans.add(new ArtifactPlan("src", "dest"));
artifactPlans.add(new ArtifactPlan("src", "dest"));
artifactPlans.add(new ArtifactPlan("src", "../a"));
artifactPlans.validateTree(null);
assertThat(artifactPlans.get(0).errors().on(ArtifactPlan.DEST), is("Duplicate artifacts defined."));
assertThat(artifactPlans.get(0).errors().on(ArtifactPlan.SRC), is("Duplicate artifacts defined."));
assertThat(artifactPlans.get(1).errors().on(ArtifactPlan.DEST), is("Duplicate artifacts defined."));
assertThat(artifactPlans.get(1).errors().on(ArtifactPlan.SRC), is("Duplicate artifacts defined."));
assertThat(artifactPlans.get(2).errors().on(ArtifactPlan.DEST), is("Invalid destination path. Destination path should match the pattern " + FilePathTypeValidator.PATH_PATTERN));
}
Aggregations