Search in sources :

Example 21 with PackageMaterialConfig

use of com.thoughtworks.go.config.materials.PackageMaterialConfig in project gocd by gocd.

the class GoConfigMaterialsTest method getPackageMaterialConfigWithAutoUpdateTrue.

private PackageMaterialConfig getPackageMaterialConfigWithAutoUpdateTrue() {
    PackageDefinition packageDefinition = new PackageDefinition("packageWithAutoUpdateFalse", "DTDC Package", new Configuration());
    packageDefinition.setRepository(PackageRepositoryMother.create("DTDC"));
    packageDefinition.setAutoUpdate(true);
    return new PackageMaterialConfig(new CaseInsensitiveString("Krish"), "packageWithAutoUpdateTrue", packageDefinition);
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) Configuration(com.thoughtworks.go.domain.config.Configuration) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition)

Example 22 with PackageMaterialConfig

use of com.thoughtworks.go.config.materials.PackageMaterialConfig in project gocd by gocd.

the class MagicalGoConfigXmlWriterTest method shouldAllowPackageTypeMaterialForPipeline.

@Test
public void shouldAllowPackageTypeMaterialForPipeline() throws Exception {
    CruiseConfig configToSave = new BasicCruiseConfig();
    PackageRepository packageRepository = new PackageRepository();
    packageRepository.setId("id");
    packageRepository.setName("name");
    packageRepository.setPluginConfiguration(new PluginConfiguration("plugin-id", "version"));
    packageRepository.setConfiguration(new Configuration(getConfigurationProperty("url", false, "http://go")));
    String packageId = "id";
    PackageDefinition expectedPackageDefinition = new PackageDefinition(packageId, "name", new Configuration(getConfigurationProperty("name", false, "go-agent")));
    expectedPackageDefinition.setRepository(packageRepository);
    packageRepository.getPackages().add(expectedPackageDefinition);
    configToSave.getPackageRepositories().add(packageRepository);
    PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(packageId);
    packageMaterialConfig.setPackageDefinition(expectedPackageDefinition);
    configToSave.addPipeline("default", com.thoughtworks.go.helper.PipelineConfigMother.pipelineConfig("test", new MaterialConfigs(packageMaterialConfig), new JobConfigs(new JobConfig("ls"))));
    xmlWriter.write(configToSave, output, false);
    GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(output.toString());
    PipelineConfig pipelineConfig = goConfigHolder.config.pipelineConfigByName(new CaseInsensitiveString("test"));
    assertThat(pipelineConfig.materialConfigs().get(0) instanceof PackageMaterialConfig, is(true));
    assertThat(((PackageMaterialConfig) pipelineConfig.materialConfigs().get(0)).getPackageId(), is(packageId));
    PackageDefinition packageDefinition = goConfigHolder.config.getPackageRepositories().first().getPackages().first();
    assertThat(((PackageMaterialConfig) pipelineConfig.materialConfigs().get(0)).getPackageDefinition(), is(packageDefinition));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Example 23 with PackageMaterialConfig

use of com.thoughtworks.go.config.materials.PackageMaterialConfig in project gocd by gocd.

the class MagicalGoConfigXmlWriterTest method shouldFailValidationIfPackageTypeMaterialForPipelineHasARefToNonExistantPackage.

@Test
public void shouldFailValidationIfPackageTypeMaterialForPipelineHasARefToNonExistantPackage() throws Exception {
    CruiseConfig configToSave = new BasicCruiseConfig();
    String packageId = "does-not-exist";
    PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(packageId);
    PackageRepository repository = com.thoughtworks.go.domain.packagerepository.PackageRepositoryMother.create("repo-id", "repo-name", "pluginid", "version", new Configuration(com.thoughtworks.go.domain.packagerepository.ConfigurationPropertyMother.create("k1", false, "v1")));
    packageMaterialConfig.setPackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinitionMother.create("does-not-exist", "package-name", new Configuration(com.thoughtworks.go.domain.packagerepository.ConfigurationPropertyMother.create("k2", false, "v2")), repository));
    configToSave.addPipeline("default", com.thoughtworks.go.helper.PipelineConfigMother.pipelineConfig("test", new MaterialConfigs(packageMaterialConfig), new JobConfigs(new JobConfig("ls"))));
    try {
        xmlWriter.write(configToSave, output, false);
        fail("should not allow this");
    } catch (XsdValidationException exception) {
        assertThat(exception.getMessage(), is("Key 'packageIdReferredByMaterial' with value 'does-not-exist' not found for identity constraint of element 'cruise'."));
    }
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Example 24 with PackageMaterialConfig

use of com.thoughtworks.go.config.materials.PackageMaterialConfig in project gocd by gocd.

the class PipelineConfigServiceIntegrationTest method shouldMapErrorsBackToPackageMaterials.

@Test
public void shouldMapErrorsBackToPackageMaterials() throws Exception {
    GoConfigHolder goConfigHolder = goConfigDao.loadConfigHolder();
    String packageid = "packageid";
    saveScmMaterialToConfig(packageid);
    PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(packageid);
    String xml = new MagicalGoConfigXmlWriter(configCache, registry).toXmlPartial(pipelineConfig);
    String md5 = CachedDigestUtils.md5Hex(xml);
    pipelineConfig.materialConfigs().add(packageMaterialConfig);
    pipelineConfigService.updatePipelineConfig(user, pipelineConfig, md5, result);
    assertThat(result.toString(), result.isSuccessful(), is(false));
    assertThat(result.message(localizer), is(String.format("Validations failed for pipeline '%s'. Error(s): [Validation failed.]. Please correct and resubmit.", pipelineConfig.name())));
    assertThat(packageMaterialConfig.errors().on(PackageMaterialConfig.PACKAGE_ID), is("Could not find repository for given package id:[packageid]"));
    assertThat(configRepository.getCurrentRevCommit().name(), is(headCommitBeforeUpdate));
    assertThat(goConfigDao.loadConfigHolder().configForEdit, is(goConfigHolder.configForEdit));
    assertThat(goConfigDao.loadConfigHolder().config, is(goConfigHolder.config));
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) Test(org.junit.Test)

Example 25 with PackageMaterialConfig

use of com.thoughtworks.go.config.materials.PackageMaterialConfig in project gocd by gocd.

the class PackageMaterialUpdateWithExistingPackageDefinitionCommandTest method shouldHandleDeletedPackageRepo.

@Test
public void shouldHandleDeletedPackageRepo() {
    String repoId = "deleted-repo";
    String pkgId = "pkg-2";
    HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialAssociation(repoId, pkgId);
    PackageMaterialUpdateWithExistingPackageDefinitionCommand command = new PackageMaterialUpdateWithExistingPackageDefinitionCommand(packageDefinitionService, securityService, pipelineName, materialToBeUpdated, admin, params);
    command.update(cruiseConfig);
    assertThat(pipelineConfig.materialConfigs().first() instanceof PackageMaterialConfig, is(true));
    PackageMaterialConfig editedMaterial = (PackageMaterialConfig) pipelineConfig.materialConfigs().first();
    assertThat(editedMaterial, is(materialToBeUpdated));
    assertThat(editedMaterial.getPackageDefinition(), is(nullValue()));
    assertThat(editedMaterial.getPackageId(), is(nullValue()));
    verify(packageDefinitionService, never()).performPluginValidationsFor(Matchers.<PackageDefinition>any());
}
Also used : Serializable(java.io.Serializable) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)27 Test (org.junit.Test)23 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)13 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)11 Serializable (java.io.Serializable)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)7 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)7 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)5 Configuration (com.thoughtworks.go.domain.config.Configuration)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 MergePipelineConfigs (com.thoughtworks.go.config.merge.MergePipelineConfigs)2 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)2 PipelineConfigMother.createPipelineConfig (com.thoughtworks.go.helper.PipelineConfigMother.createPipelineConfig)2 Pair (com.thoughtworks.go.util.Pair)2 Arrays.asList (java.util.Arrays.asList)2 HashMap (java.util.HashMap)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)1 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1