Search in sources :

Example 1 with ArtifactConfigs

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

the class ArtifactConfigsTest method findByArtifactId_shouldReturnNullWhenPluggableArtifactConfigNotExistWithGivenId.

@Test
public void findByArtifactId_shouldReturnNullWhenPluggableArtifactConfigNotExistWithGivenId() {
    ArtifactConfigs allConfigs = new ArtifactConfigs();
    allConfigs.add(new PluggableArtifactConfig("s3", "cd.go.s3"));
    allConfigs.add(new PluggableArtifactConfig("docker", "cd.go.docker"));
    final PluggableArtifactConfig s3 = allConfigs.findByArtifactId("foo");
    assertNull(s3);
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactConfigs(com.thoughtworks.go.config.ArtifactConfigs) Test(org.junit.Test)

Example 2 with ArtifactConfigs

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

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

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

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

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