Search in sources :

Example 1 with ArtifactPlans

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;
}
Also used : ArtifactPlans(com.thoughtworks.go.config.ArtifactPlans) ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan)

Example 2 with 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)));
}
Also used : ArtifactPlans(com.thoughtworks.go.config.ArtifactPlans) ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) Test(org.junit.Test)

Example 3 with ArtifactPlans

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)));
}
Also used : ArtifactPlans(com.thoughtworks.go.config.ArtifactPlans) ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) Test(org.junit.Test)

Example 4 with ArtifactPlans

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")));
}
Also used : ArtifactPlans(com.thoughtworks.go.config.ArtifactPlans) ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) Test(org.junit.Test)

Example 5 with ArtifactPlans

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));
}
Also used : ArtifactPlans(com.thoughtworks.go.config.ArtifactPlans) ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) Test(org.junit.Test)

Aggregations

ArtifactPlans (com.thoughtworks.go.config.ArtifactPlans)9 ArtifactPlan (com.thoughtworks.go.config.ArtifactPlan)8 TestArtifactPlan (com.thoughtworks.go.config.TestArtifactPlan)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 EnvironmentVariablesConfig (com.thoughtworks.go.config.EnvironmentVariablesConfig)1 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)1 DefaultJobPlan (com.thoughtworks.go.domain.DefaultJobPlan)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1