Search in sources :

Example 1 with TestArtifactPlan

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

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

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

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

the class ArtifactPlanRepositoryIntegrationTest method shouldLoadSavedArtifactPlanWithTypeUnit.

@Test
public void shouldLoadSavedArtifactPlanWithTypeUnit() {
    // Arrange
    JobInstance jobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME));
    ArtifactPlan savedArtifactPlan = new TestArtifactPlan("src", "dest");
    savedArtifactPlan.setBuildId(jobInstance.getId());
    artifactPlanRepository.save(savedArtifactPlan);
    // Act
    List<ArtifactPlan> artifactPlanList = artifactPlanRepository.findByBuildId(jobInstance.getId());
    // Assert
    assertThat(artifactPlanList.size(), is(1));
    assertThat(artifactPlanList.get(0), is(savedArtifactPlan));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) Test(org.junit.Test)

Example 5 with TestArtifactPlan

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

the class ArtifactPlanRepositoryIntegrationTest method shouldLoadSavedTestArtifactPlan.

@Test
public void shouldLoadSavedTestArtifactPlan() {
    // Arrange
    JobInstance jobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME));
    ArtifactPlan savedArtifactPlan = new TestArtifactPlan();
    savedArtifactPlan.setBuildId(jobInstance.getId());
    artifactPlanRepository.save(savedArtifactPlan);
    // Act
    List<ArtifactPlan> artifactPlanList = artifactPlanRepository.findByBuildId(jobInstance.getId());
    // Assert
    assertThat(artifactPlanList.size(), is(1));
    ArtifactPlan loadedArtifactPlan = artifactPlanList.get(0);
    assertThat(loadedArtifactPlan, is(savedArtifactPlan));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) TestArtifactPlan(com.thoughtworks.go.config.TestArtifactPlan) Test(org.junit.Test)

Aggregations

TestArtifactPlan (com.thoughtworks.go.config.TestArtifactPlan)8 Test (org.junit.Test)7 ArtifactPlan (com.thoughtworks.go.config.ArtifactPlan)6 ArtifactPlans (com.thoughtworks.go.config.ArtifactPlans)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Times (org.mockito.internal.verification.Times)1