Search in sources :

Example 16 with ArtifactPlan

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

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

Example 18 with ArtifactPlan

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

the class ArtifactPlansTest method shouldClearAllArtifactsWhenTheMapIsNull.

@Test
public void shouldClearAllArtifactsWhenTheMapIsNull() {
    ArtifactPlans artifactPlans = new ArtifactPlans();
    artifactPlans.add(new ArtifactPlan("src", "dest"));
    artifactPlans.setConfigAttributes(null);
    assertThat(artifactPlans.size(), is(0));
}
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 19 with ArtifactPlan

use of com.thoughtworks.go.config.ArtifactPlan 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")));
}
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 20 with ArtifactPlan

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

the class ArtifactPlansTest method shouldAddDuplicatedArtifactSoThatValidationKicksIn.

@Test
public void shouldAddDuplicatedArtifactSoThatValidationKicksIn() throws Exception {
    final ArtifactPlans artifactPlans = new ArtifactPlans();
    assertThat(artifactPlans.size(), is(0));
    artifactPlans.add(new ArtifactPlan("src", "dest"));
    artifactPlans.add(new ArtifactPlan("src", "dest"));
    assertThat(artifactPlans.size(), is(2));
}
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

ArtifactPlan (com.thoughtworks.go.config.ArtifactPlan)29 Test (org.junit.Test)25 TestArtifactPlan (com.thoughtworks.go.config.TestArtifactPlan)15 ArtifactPlans (com.thoughtworks.go.config.ArtifactPlans)8 File (java.io.File)7 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 Cloner (com.rits.cloning.Cloner)1 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)1 JobConfig (com.thoughtworks.go.config.JobConfig)1 Resource (com.thoughtworks.go.config.Resource)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 JobPlan (com.thoughtworks.go.domain.JobPlan)1 Property (com.thoughtworks.go.domain.Property)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)1 Document (org.dom4j.Document)1 Element (org.dom4j.Element)1 DOMDocument (org.dom4j.dom.DOMDocument)1 DOMElement (org.dom4j.dom.DOMElement)1