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)));
}
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)));
}
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();
}
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");
}
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"));
}
Aggregations