Search in sources :

Example 1 with CRGitMaterial

use of com.thoughtworks.go.plugin.access.configrepo.contract.material.CRGitMaterial in project gocd by gocd.

the class CRPipelineTest method shouldCheckMissingDestinationDirectoryWhenManySCMs.

@Test
public void shouldCheckMissingDestinationDirectoryWhenManySCMs() {
    CRPipeline p = new CRPipeline();
    p.setName("pipe4");
    CRGitMaterial simpleGit1 = new CRGitMaterial();
    simpleGit1.setUrl("url1");
    CRGitMaterial simpleGit2 = new CRGitMaterial();
    simpleGit2.setUrl("url2");
    p.addMaterial(simpleGit1);
    p.addMaterial(simpleGit2);
    ErrorCollection errors = new ErrorCollection();
    p.getErrors(errors, "TEST");
    String fullError = errors.getErrorsAsText();
    assertThat(fullError, contains("Pipeline pipe4; Git material"));
    assertThat(fullError, contains("Material must have destination directory when there are many SCM materials"));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) CRGitMaterial(com.thoughtworks.go.plugin.access.configrepo.contract.material.CRGitMaterial) Test(org.junit.Test)

Example 2 with CRGitMaterial

use of com.thoughtworks.go.plugin.access.configrepo.contract.material.CRGitMaterial in project gocd by gocd.

the class CRPipelineTest method shouldCheckErrorsInMaterials.

@Test
public void shouldCheckErrorsInMaterials() {
    CRPipeline p = new CRPipeline();
    p.setName("pipe4");
    CRGitMaterial invalidGit = new CRGitMaterial("gitMaterial1", "dir1", false, true, null, "feature12", false, "externals", "tools");
    p.addMaterial(invalidGit);
    // plugin may voluntarily set this
    p.setLocation("pipe4.json");
    ErrorCollection errors = new ErrorCollection();
    p.getErrors(errors, "TEST");
    String fullError = errors.getErrorsAsText();
    assertThat(fullError, contains("Pipeline pipe4; Git material"));
    assertThat(fullError, contains("Missing field 'url'"));
}
Also used : ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) CRGitMaterial(com.thoughtworks.go.plugin.access.configrepo.contract.material.CRGitMaterial) Test(org.junit.Test)

Example 3 with CRGitMaterial

use of com.thoughtworks.go.plugin.access.configrepo.contract.material.CRGitMaterial in project gocd by gocd.

the class CRPipelineTest method shouldHandlePolymorphismWhenDeserializingJobs.

@Test
public void shouldHandlePolymorphismWhenDeserializingJobs() {
    String json = gson.toJson(pipe1);
    CRPipeline deserializedValue = gson.fromJson(json, CRPipeline.class);
    CRMaterial git = deserializedValue.getMaterialByName("gitMaterial1");
    assertThat(git instanceof CRGitMaterial, is(true));
    assertThat(((CRGitMaterial) git).getBranch(), is("feature12"));
}
Also used : CRGitMaterial(com.thoughtworks.go.plugin.access.configrepo.contract.material.CRGitMaterial) CRMaterial(com.thoughtworks.go.plugin.access.configrepo.contract.material.CRMaterial) Test(org.junit.Test)

Aggregations

CRGitMaterial (com.thoughtworks.go.plugin.access.configrepo.contract.material.CRGitMaterial)3 Test (org.junit.Test)3 ErrorCollection (com.thoughtworks.go.plugin.access.configrepo.ErrorCollection)2 CRMaterial (com.thoughtworks.go.plugin.access.configrepo.contract.material.CRMaterial)1