Search in sources :

Example 71 with MaterialConfig

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

the class ConfigReposMaterialParseResultManager method checkForMaterialErrors.

private PartialConfigParseResult checkForMaterialErrors(String fingerprint) {
    MaterialConfig naterial = configRepoService.findByFingerprint(fingerprint).getRepo();
    HealthStateScope healthStateScope = HealthStateScope.forMaterialConfig(naterial);
    List<ServerHealthState> serverHealthStates = serverHealthService.filterByScope(healthStateScope);
    return serverHealthStates.isEmpty() ? null : PartialConfigParseResult.parseFailed(null, asError(serverHealthStates.get(0)));
}
Also used : HealthStateScope(com.thoughtworks.go.serverhealth.HealthStateScope) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ServerHealthState(com.thoughtworks.go.serverhealth.ServerHealthState)

Example 72 with MaterialConfig

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

the class SpecificMaterialRevisionFactoryTest method shouldCreateDependencyMaterialForAPipeline.

@Test
public void shouldCreateDependencyMaterialForAPipeline() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("upstream"), new CaseInsensitiveString("blah-stage"));
    MaterialConfig dependencyMaterialConfig = dependencyMaterial.config();
    MaterialRevision expected = new MaterialRevision(dependencyMaterial, new Modification(new Date(), "upstream/4/blah-stage/2", "MOCK_LABEL-12", null));
    String upstreamFingerprint = "234fa4";
    when(mockGoConfigService.findMaterial(new CaseInsensitiveString("blahPipeline"), upstreamFingerprint)).thenReturn(dependencyMaterialConfig);
    when(materialConfigConverter.toMaterial(dependencyMaterialConfig)).thenReturn(dependencyMaterial);
    when(mockMaterialChecker.findSpecificRevision(dependencyMaterial, "upstream/4/blah-stage/2")).thenReturn(expected);
    MaterialRevisions materialRevisions = specificMaterialRevisionFactory.create("blahPipeline", Collections.singletonMap(upstreamFingerprint, "upstream/4/blah-stage/2"));
    assertThat(materialRevisions, is(new MaterialRevisions(expected)));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 73 with MaterialConfig

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

the class GoConfigMigrationIntegrationTest method migration99_shouldMigrateHgMaterialsUnderConfigRepoAndRetainOnlyTheMinimalRequiredAttributes.

@Test
public void migration99_shouldMigrateHgMaterialsUnderConfigRepoAndRetainOnlyTheMinimalRequiredAttributes() throws Exception {
    String configXml = "<cruise schemaVersion='98'>" + "<config-repos>\n" + "   <config-repo pluginId=\"json.config.plugin\" id=\"config-repo-1\">\n" + "      <hg url=\"test-repo\" dest='dest' autoUpdate='true' invertFilter='true' materialName=\"foo\">\n" + "        <filter>\n" + "          <ignore pattern=\"asdsd\" />\n" + "        </filter>\n" + "      </hg>" + "   </config-repo>\n" + "</config-repos>" + "</cruise>";
    assertThat(configXml).contains("<filter>");
    assertThat(configXml).contains("dest='dest'");
    assertThat(configXml).contains("autoUpdate='true'");
    assertThat(configXml).contains("invertFilter='true'");
    String migratedContent = migrateXmlString(configXml, 98);
    CruiseConfig cruiseConfig = loader.deserializeConfig(migratedContent);
    MaterialConfig materialConfig = cruiseConfig.getConfigRepos().getConfigRepo("config-repo-1").getRepo();
    assertThat(migratedContent).doesNotContain("<filter>");
    assertThat(migratedContent).doesNotContain("dest='dest'");
    assertThat(migratedContent).doesNotContain("invertFilter='true'");
    assertThat(materialConfig.getFolder()).isNull();
    assertThat(materialConfig.filter().size()).isEqualTo(0);
    assertThat(materialConfig.isAutoUpdate()).isTrue();
    assertThat(materialConfig.isInvertFilter()).isFalse();
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.jupiter.api.Test)

Example 74 with MaterialConfig

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

the class GoConfigMigratorIntegrationTest method shouldMigrateMaterialFolderAttributeToDest.

@Test
public void shouldMigrateMaterialFolderAttributeToDest() throws Exception {
    CruiseConfig cruiseConfig = loadConfigFileWithContent(ConfigFileFixture.VERSION_2);
    MaterialConfig actual = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("multiple")).materialConfigs().first();
    assertThat(actual.getFolder()).isEqualTo("part1");
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 75 with MaterialConfig

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

the class GoConfigMigratorIntegrationTest method shouldMigrateDependsOnTagToBeADependencyMaterial.

@Test
public void shouldMigrateDependsOnTagToBeADependencyMaterial() throws Exception {
    String content = FileUtils.readFileToString(new File("../common/src/test/resources/data/config/version4/cruise-config-dependency-migration.xml"), UTF_8);
    CruiseConfig cruiseConfig = loadConfigFileWithContent(content);
    MaterialConfig actual = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("depends")).materialConfigs().first();
    Assertions.assertThat(actual).isInstanceOf(DependencyMaterialConfig.class);
    DependencyMaterialConfig depends = (DependencyMaterialConfig) actual;
    assertThat(depends.getPipelineName()).isEqualTo(new CaseInsensitiveString("multiple"));
    assertThat(depends.getStageName()).isEqualTo(new CaseInsensitiveString("helloworld-part2"));
}
Also used : DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) File(java.io.File) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) 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