Search in sources :

Example 36 with PackageMaterialConfig

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

the class BasicCruiseConfigTest method shouldListAllPipelinesAssociatedWithThePackageRepository.

@Test
public void shouldListAllPipelinesAssociatedWithThePackageRepository() {
    GitMaterialConfig git = git("http://example.com");
    PackageMaterialConfig packageMaterialConfig = packageMaterialConfig();
    PipelineConfig p1 = pipelineConfig("p1", new MaterialConfigs(git, packageMaterialConfig));
    PipelineConfig p2 = pipelineConfig("p2", new MaterialConfigs(git));
    PipelineConfig p3 = pipelineConfig("p3", new MaterialConfigs(packageMaterialConfig));
    PipelineConfigs group1 = createGroup("group1", p1, p2);
    PipelineConfigs group2 = createGroup("group2", p3);
    CruiseConfig config = createCruiseConfig();
    config.setGroup(new PipelineGroups(group1, group2));
    List<PipelineConfig> pipelineConfigs = config.pipelinesAssociatedWithPackageRepository(packageMaterialConfig.getPackageDefinition().getRepository());
    assertThat(pipelineConfigs.size(), is(2));
    assertThat(pipelineConfigs.get(0).getName(), is(new CaseInsensitiveString("p1")));
    assertThat(pipelineConfigs.get(1).getName(), is(new CaseInsensitiveString("p3")));
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 37 with PackageMaterialConfig

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

the class PipelineConfigValidationTest method isValid_shouldAllowColonForLabelTemplate.

@Test
void isValid_shouldAllowColonForLabelTemplate() {
    pipeline.addMaterialConfig(new PackageMaterialConfig(new CaseInsensitiveString("repo:name"), "package-id", PackageDefinitionMother.create("package-id")));
    assertLabelTemplate("pipeline-${COUNT}-${repo:name}", emptyCheck);
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 38 with PackageMaterialConfig

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

the class ConfigConverterTest method shouldConvertPackageMaterialConfig.

@Test
void shouldConvertPackageMaterialConfig() {
    PackageRepositories repositories = new PackageRepositories();
    PackageRepository packageRepository = new PackageRepository();
    PackageDefinition definition = new PackageDefinition("package-id", "n", new Configuration());
    packageRepository.addPackage(definition);
    repositories.add(packageRepository);
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setPackageRepositories(repositories);
    when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
    PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(new CaseInsensitiveString("name"), "package-id", definition);
    CRPackageMaterial crPackageMaterial = (CRPackageMaterial) configConverter.materialToCRMaterial(packageMaterialConfig);
    assertThat(crPackageMaterial.getName()).isEqualTo("name");
    assertThat(crPackageMaterial.getPackageId()).isEqualTo("package-id");
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.jupiter.api.Test)

Example 39 with PackageMaterialConfig

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

the class UpdatePackageRepositoryCommandTest method shouldUpdatePackageRepositoryConfigurationOnAssociatedPipelines.

@Test
public void shouldUpdatePackageRepositoryConfigurationOnAssociatedPipelines() {
    GitMaterialConfig git = git("http://example.com");
    PackageMaterialConfig packageMaterial = packageMaterialConfig();
    PipelineConfig p1 = pipelineConfig("p1", new MaterialConfigs(git, packageMaterial));
    PipelineConfig p2 = pipelineConfig("p2", new MaterialConfigs(git));
    PipelineConfig p3 = pipelineConfig("p3", new MaterialConfigs(packageMaterial));
    PipelineConfigs group1 = createGroup("group1", p1, p2);
    PipelineConfigs group2 = createGroup("group2", p3);
    cruiseConfig.setGroup(new PipelineGroups(group1, group2));
    cruiseConfig.setPackageRepositories(new PackageRepositories(packageMaterial.getPackageDefinition().getRepository()));
    Configuration updatedConfiguration = new Configuration(create("new_key1", "new_value1"), create("new_key2", "new_value2"));
    PackageRepository updatePackageRepo = PackageRepositoryMother.create(packageMaterial.getPackageDefinition().getRepository().getId(), "repo", "id", "version", updatedConfiguration);
    UpdatePackageRepositoryCommand command = new UpdatePackageRepositoryCommand(goConfigService, packageRepositoryService, updatePackageRepo, currentUser, "digest", entityHashingService, result, repoId);
    command.update(cruiseConfig);
    PackageMaterialConfig materialConfig1 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p1")).packageMaterialConfigs().get(0);
    assertThat(materialConfig1.getPackageDefinition().getRepository(), is(updatePackageRepo));
    PackageMaterialConfig materialConfig2 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p3")).packageMaterialConfigs().get(0);
    assertThat(materialConfig2.getPackageDefinition().getRepository(), is(updatePackageRepo));
}
Also used : PipelineGroups(com.thoughtworks.go.domain.PipelineGroups) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Example 40 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 digest = entityHashingService.hashForEntity(pipelineConfig, groupName);
    pipelineConfig.materialConfigs().add(packageMaterialConfig);
    pipelineConfigService.updatePipelineConfig(user, pipelineConfig, groupName, digest, result);
    assertThat(result.toString(), result.isSuccessful(), is(false));
    assertThat(result.message(), 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.jupiter.api.Test)

Aggregations

PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)40 Test (org.junit.jupiter.api.Test)17 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)14 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)14 Test (org.junit.Test)13 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)12 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)10 Serializable (java.io.Serializable)10 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)6 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)6 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)5 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)4 PipelineGroups (com.thoughtworks.go.domain.PipelineGroups)4 HashMap (java.util.HashMap)4 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)3 Configuration (com.thoughtworks.go.domain.config.Configuration)3 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 ErrorGetter (com.thoughtworks.go.api.representers.ErrorGetter)2