Search in sources :

Example 1 with ArtifactPlan

use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.

the class ArtifactPlanTest method validate_shouldFailIfSourceIsEmpty.

@Test
public void validate_shouldFailIfSourceIsEmpty() {
    ArtifactPlan artifactPlan = new ArtifactPlan(null, "bar");
    artifactPlan.validate(ConfigSaveValidationContext.forChain(new JobConfig("jobname")));
    assertThat(artifactPlan.errors().on(ArtifactPlan.SRC), is("Job 'jobname' has an artifact with an empty source"));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) JobConfig(com.thoughtworks.go.config.JobConfig) Test(org.junit.Test)

Example 2 with ArtifactPlan

use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.

the class ArtifactPlanTest method shouldProvideAppendFilePathToDestWhenUsingDoubleStart.

@Test
public void shouldProvideAppendFilePathToDestWhenUsingDoubleStart() {
    ArtifactPlan artifactPlan = new ArtifactPlan("**/*/a.log", "logs");
    assertThat(artifactPlan.destURL(new File("pipelines/pipelineA"), new File("pipelines/pipelineA/test/a/b/a.log")), is("logs/test/a/b"));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) File(java.io.File) Test(org.junit.Test)

Example 3 with ArtifactPlan

use of com.thoughtworks.go.config.ArtifactPlan 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 4 with ArtifactPlan

use of com.thoughtworks.go.config.ArtifactPlan 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 5 with ArtifactPlan

use of com.thoughtworks.go.config.ArtifactPlan 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)

Aggregations

ArtifactPlan (com.thoughtworks.go.config.ArtifactPlan)25 Test (org.junit.Test)23 TestArtifactPlan (com.thoughtworks.go.config.TestArtifactPlan)13 ArtifactPlans (com.thoughtworks.go.config.ArtifactPlans)8 File (java.io.File)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 Cloner (com.rits.cloning.Cloner)1 JobConfig (com.thoughtworks.go.config.JobConfig)1