Search in sources :

Example 46 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class BuildCauseTest method shouldThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenAutoTrigger.

@Test
public void shouldThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenAutoTrigger() {
    SvnMaterial material = MaterialsMother.svnMaterial();
    MaterialConfig materialConfig = material.config();
    MaterialRevisions first = new MaterialRevisions(new MaterialRevision(material, oneModifiedFile("revision1")));
    BuildCause buildCause = BuildCause.createWithModifications(first, "");
    buildCause.setMaterialRevisions(first);
    PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build");
    pipelineConfig.materialConfigs().clear();
    pipelineConfig.materialConfigs().add(materialConfig);
    pipelineConfig.setOrigin(new RepoConfigOrigin(ConfigRepoConfig.createConfigRepoConfig(materialConfig, "plug", "id"), "revision2"));
    try {
        buildCause.assertPipelineConfigAndMaterialRevisionMatch(pipelineConfig);
    } catch (BuildCauseOutOfDateException ex) {
        // good
        return;
    }
    fail("should have thrown");
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) BuildCauseOutOfDateException(com.thoughtworks.go.domain.buildcause.BuildCauseOutOfDateException) Test(org.junit.jupiter.api.Test)

Example 47 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class BuildCauseTest method shouldNotThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenManualTrigger.

@Test
public void shouldNotThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenManualTrigger() {
    SvnMaterial material = MaterialsMother.svnMaterial();
    MaterialConfig materialConfig = material.config();
    MaterialRevisions first = new MaterialRevisions(new MaterialRevision(material, oneModifiedFile("revision1")));
    BuildCause buildCause = BuildCause.createManualForced();
    buildCause.setMaterialRevisions(first);
    PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build");
    pipelineConfig.materialConfigs().clear();
    pipelineConfig.materialConfigs().add(materialConfig);
    pipelineConfig.setOrigin(new RepoConfigOrigin(ConfigRepoConfig.createConfigRepoConfig(materialConfig, "plug", "id"), "revision2"));
    buildCause.assertPipelineConfigAndMaterialRevisionMatch(pipelineConfig);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.jupiter.api.Test)

Example 48 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ConfigRepoConfigTest method hasMaterialWithFingerprint_shouldReturnFalseWhenFingerprintNotEquals.

@Test
public void hasMaterialWithFingerprint_shouldReturnFalseWhenFingerprintNotEquals() {
    MaterialConfig configRepo = git("url", "branch");
    GitMaterialConfig someRepo = git("url", "branch1");
    ConfigRepoConfig config = ConfigRepoConfig.createConfigRepoConfig(configRepo, "myplugin", "id");
    assertThat(config.hasMaterialWithFingerprint(someRepo.getFingerprint())).isFalse();
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.jupiter.api.Test)

Example 49 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ConfigRepoConfigTest method validateTree_shouldValidateTheMaterialConfig.

@Test
public void validateTree_shouldValidateTheMaterialConfig() {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    MaterialConfig materialConfig = mock(MaterialConfig.class);
    when(materialConfig.errors()).thenReturn(new ConfigErrors());
    ConfigRepoConfig configRepoConfig = ConfigRepoConfig.createConfigRepoConfig(materialConfig, "plug", "id");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
    ConfigSaveValidationContext validationContext = ConfigSaveValidationContext.forChain(cruiseConfig);
    configRepoConfig.validateTree(validationContext);
    verify(materialConfig).validateTree(validationContext);
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ConfigErrors(com.thoughtworks.go.domain.ConfigErrors) Test(org.junit.jupiter.api.Test)

Example 50 with MaterialConfig

use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.

the class ConfigRepoConfigTest method hasSameMaterial_shouldReturnTrueWhenFingerprintEquals_AndDestinationDirectoriesAreDifferent.

@Test
public void hasSameMaterial_shouldReturnTrueWhenFingerprintEquals_AndDestinationDirectoriesAreDifferent() {
    MaterialConfig configRepo = git("url", "branch");
    GitMaterialConfig someRepo = git("url", "branch");
    someRepo.setFolder("someFolder");
    ConfigRepoConfig config = ConfigRepoConfig.createConfigRepoConfig(configRepo, "myplugin", "id");
    assertThat(config.hasSameMaterial(someRepo)).isTrue();
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.jupiter.api.Test)

Aggregations

MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)171 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)90 Test (org.junit.jupiter.api.Test)86 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)74 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)64 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)48 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)44 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)42 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)42 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)39 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)36 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)20 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)19 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)19 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)13 Material (com.thoughtworks.go.domain.materials.Material)13 Modification (com.thoughtworks.go.domain.materials.Modification)13 Test (org.junit.Test)12