Search in sources :

Example 1 with ArtifactConfig

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

the class ArtifactConfigsTest 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", TestArtifactConfig.TEST_PLAN_DISPLAY_NAME);
    HashMap<String, String> artifactPlan2 = new HashMap<>();
    artifactPlan2.put(SRC, "blah2");
    artifactPlan2.put(DEST, "something2");
    artifactPlan2.put("artifactTypeValue", ArtifactConfig.ARTIFACT_PLAN_DISPLAY_NAME);
    HashMap<String, String> artifactPlan3 = new HashMap<>();
    artifactPlan3.put(SRC, "");
    artifactPlan3.put(DEST, "");
    artifactPlan3.put("artifactTypeValue", ArtifactConfig.ARTIFACT_PLAN_DISPLAY_NAME);
    List<HashMap> artifactPlansList = new ArrayList<>();
    artifactPlansList.add(artifactPlan1);
    artifactPlansList.add(artifactPlan3);
    artifactPlansList.add(artifactPlan2);
    ArtifactConfigs artifactConfigs = new ArtifactConfigs();
    artifactConfigs.setConfigAttributes(artifactPlansList);
    assertThat(artifactConfigs.size(), is(2));
    TestArtifactConfig plan = new TestArtifactConfig();
    plan.setSource("blah");
    plan.setDestination("something");
    assertThat(artifactConfigs.get(0), is(plan));
    assertThat(artifactConfigs.get(1), is(new ArtifactConfig("blah2", "something2")));
}
Also used : TestArtifactConfig(com.thoughtworks.go.config.TestArtifactConfig) HashMap(java.util.HashMap) PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) TestArtifactConfig(com.thoughtworks.go.config.TestArtifactConfig) ArtifactConfig(com.thoughtworks.go.config.ArtifactConfig) ArrayList(java.util.ArrayList) ArtifactConfigs(com.thoughtworks.go.config.ArtifactConfigs) Test(org.junit.Test)

Example 2 with ArtifactConfig

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

the class ArtifactPlanTest method toArtifactPlans_shouldConvertArtifactConfigsToArtifactPlanList.

@Test
public void toArtifactPlans_shouldConvertArtifactConfigsToArtifactPlanList() {
    final PluggableArtifactConfig artifactConfig = new PluggableArtifactConfig("id", "storeId", create("Foo", true, "Bar"));
    final ArtifactConfigs artifactConfigs = new ArtifactConfigs(Arrays.asList(new ArtifactConfig("source", "destination"), new TestArtifactConfig("test-source", "test-destination"), artifactConfig));
    final List<ArtifactPlan> artifactPlans = ArtifactPlan.toArtifactPlans(artifactConfigs);
    assertThat(artifactPlans, containsInAnyOrder(new ArtifactPlan(ArtifactType.file, "source", "destination"), new ArtifactPlan(ArtifactType.unit, "test-source", "test-destination"), new ArtifactPlan(artifactConfig.toJSON())));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) TestArtifactConfig(com.thoughtworks.go.config.TestArtifactConfig) PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) TestArtifactConfig(com.thoughtworks.go.config.TestArtifactConfig) ArtifactConfig(com.thoughtworks.go.config.ArtifactConfig) ArtifactConfigs(com.thoughtworks.go.config.ArtifactConfigs) Test(org.junit.Test)

Example 3 with ArtifactConfig

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

the class ArtifactConfigsTest method getArtifactConfigs_shouldReturnBuiltinArtifactConfigs.

@Test
public void getArtifactConfigs_shouldReturnBuiltinArtifactConfigs() {
    ArtifactConfigs allConfigs = new ArtifactConfigs();
    allConfigs.add(new ArtifactConfig("src", "dest"));
    allConfigs.add(new ArtifactConfig("java", null));
    allConfigs.add(new PluggableArtifactConfig("s3", "cd.go.s3"));
    allConfigs.add(new PluggableArtifactConfig("docker", "cd.go.docker"));
    final List<ArtifactConfig> artifactConfigs = allConfigs.getArtifactConfigs();
    assertThat(artifactConfigs, hasSize(2));
    assertThat(artifactConfigs, containsInAnyOrder(new ArtifactConfig("src", "dest"), new ArtifactConfig("java", null)));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) TestArtifactConfig(com.thoughtworks.go.config.TestArtifactConfig) ArtifactConfig(com.thoughtworks.go.config.ArtifactConfig) ArtifactConfigs(com.thoughtworks.go.config.ArtifactConfigs) Test(org.junit.Test)

Example 4 with ArtifactConfig

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

the class ArtifactConfigsTest method shouldErrorOutWhenDuplicateArtifactConfigExists.

@Test
public void shouldErrorOutWhenDuplicateArtifactConfigExists() {
    final ArtifactConfigs artifactConfigs = new ArtifactConfigs(new ArtifactConfig("src", "dest"));
    artifactConfigs.add(new ArtifactConfig("src", "dest"));
    artifactConfigs.add(new ArtifactConfig("src", "dest"));
    artifactConfigs.validate(null);
    assertFalse(artifactConfigs.get(0).errors().isEmpty());
    assertThat(artifactConfigs.get(0).errors().on(ArtifactConfig.SRC), Matchers.is("Duplicate artifacts defined."));
    assertThat(artifactConfigs.get(0).errors().on(ArtifactConfig.DEST), Matchers.is("Duplicate artifacts defined."));
    assertFalse(artifactConfigs.get(1).errors().isEmpty());
    assertThat(artifactConfigs.get(1).errors().on(ArtifactConfig.SRC), Matchers.is("Duplicate artifacts defined."));
    assertThat(artifactConfigs.get(1).errors().on(ArtifactConfig.DEST), Matchers.is("Duplicate artifacts defined."));
    assertFalse(artifactConfigs.get(2).errors().isEmpty());
    assertThat(artifactConfigs.get(2).errors().on(ArtifactConfig.SRC), Matchers.is("Duplicate artifacts defined."));
    assertThat(artifactConfigs.get(2).errors().on(ArtifactConfig.DEST), Matchers.is("Duplicate artifacts defined."));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) TestArtifactConfig(com.thoughtworks.go.config.TestArtifactConfig) ArtifactConfig(com.thoughtworks.go.config.ArtifactConfig) ArtifactConfigs(com.thoughtworks.go.config.ArtifactConfigs) Test(org.junit.Test)

Example 5 with ArtifactConfig

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

the class ArtifactConfigsTest method getPluggableArtifactConfigs_shouldReturnPluggableArtifactConfigs.

@Test
public void getPluggableArtifactConfigs_shouldReturnPluggableArtifactConfigs() {
    ArtifactConfigs allConfigs = new ArtifactConfigs();
    allConfigs.add(new ArtifactConfig("src", "dest"));
    allConfigs.add(new ArtifactConfig("java", null));
    allConfigs.add(new PluggableArtifactConfig("s3", "cd.go.s3"));
    allConfigs.add(new PluggableArtifactConfig("docker", "cd.go.docker"));
    final List<PluggableArtifactConfig> artifactConfigs = allConfigs.getPluggableArtifactConfigs();
    assertThat(artifactConfigs, hasSize(2));
    assertThat(artifactConfigs, containsInAnyOrder(new PluggableArtifactConfig("s3", "cd.go.s3"), new PluggableArtifactConfig("docker", "cd.go.docker")));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) TestArtifactConfig(com.thoughtworks.go.config.TestArtifactConfig) ArtifactConfig(com.thoughtworks.go.config.ArtifactConfig) ArtifactConfigs(com.thoughtworks.go.config.ArtifactConfigs) Test(org.junit.Test)

Aggregations

ArtifactConfig (com.thoughtworks.go.config.ArtifactConfig)9 ArtifactConfigs (com.thoughtworks.go.config.ArtifactConfigs)9 PluggableArtifactConfig (com.thoughtworks.go.config.PluggableArtifactConfig)9 TestArtifactConfig (com.thoughtworks.go.config.TestArtifactConfig)9 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2