Search in sources :

Example 1 with PackageMaterialConfig

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

the class PipelineConfigTest method shouldGetPackageMaterialConfigs.

@Test
public void shouldGetPackageMaterialConfigs() throws Exception {
    SvnMaterialConfig svn = new SvnMaterialConfig("svn", false);
    PackageMaterialConfig packageMaterialOne = new PackageMaterialConfig();
    PackageMaterialConfig packageMaterialTwo = new PackageMaterialConfig();
    PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(svn, packageMaterialOne, packageMaterialTwo));
    List<PackageMaterialConfig> packageMaterialConfigs = pipelineConfig.packageMaterialConfigs();
    assertThat(packageMaterialConfigs.size(), is(2));
    assertThat(packageMaterialConfigs, hasItems(packageMaterialOne, packageMaterialTwo));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.Test)

Example 2 with PackageMaterialConfig

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

the class PipelineConfigValidationTest method isValid_shouldAllowColonForLabelTemplate.

@Test
public void isValid_shouldAllowColonForLabelTemplate() throws Exception {
    pipeline.setLabelTemplate("pipeline-${COUNT}-${repo:name}");
    pipeline.addMaterialConfig(new PackageMaterialConfig(new CaseInsensitiveString("repo:name"), "package-id", PackageDefinitionMother.create("package-id")));
    pipeline.validate(validationContext);
    assertThat(pipeline.errors().getAllOn("labelTemplate"), is(nullValue()));
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) Test(org.junit.Test)

Example 3 with PackageMaterialConfig

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

the class PackageMaterialAddWithExistingPackageDefinitionCommandTest method shouldHandleDeletedPackageRepo.

@Test
public void shouldHandleDeletedPackageRepo() {
    PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(0);
    String repoId = "deleted-repo";
    String pkgId = packageDefinition.getId();
    HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialAssociation(repoId, pkgId);
    PackageMaterialConfig materialToBeCreated = new PackageMaterialConfig();
    PackageMaterialAddWithExistingPackageDefinitionCommand command = new PackageMaterialAddWithExistingPackageDefinitionCommand(packageDefinitionService, securityService, pipelineName, materialToBeCreated, admin, params);
    command.update(cruiseConfig);
    PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    assertThat(pipelineConfig.materialConfigs().last() instanceof PackageMaterialConfig, is(true));
    PackageMaterialConfig packageMaterial = (PackageMaterialConfig) pipelineConfig.materialConfigs().last();
    assertThat(packageMaterial, is(materialToBeCreated));
    assertThat(packageMaterial.getPackageDefinition(), is(nullValue()));
    assertThat(packageMaterial.getPackageId(), is(nullValue()));
    verify(packageDefinitionService, never()).performPluginValidationsFor(Matchers.<PackageDefinition>any());
}
Also used : Serializable(java.io.Serializable) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 4 with PackageMaterialConfig

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

the class PackageMaterialAddWithExistingPackageDefinitionCommandTest method shouldHandleDeletedPackageDefinition.

@Test
public void shouldHandleDeletedPackageDefinition() {
    PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(0);
    String repoId = packageDefinition.getRepository().getId();
    String pkgId = "deleted-package-definition";
    HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialAssociation(repoId, pkgId);
    PackageMaterialConfig materialToBeCreated = new PackageMaterialConfig();
    PackageMaterialAddWithExistingPackageDefinitionCommand command = new PackageMaterialAddWithExistingPackageDefinitionCommand(packageDefinitionService, securityService, pipelineName, materialToBeCreated, admin, params);
    command.update(cruiseConfig);
    PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    assertThat(pipelineConfig.materialConfigs().last() instanceof PackageMaterialConfig, is(true));
    PackageMaterialConfig packageMaterial = (PackageMaterialConfig) pipelineConfig.materialConfigs().last();
    assertThat(packageMaterial, is(materialToBeCreated));
    assertThat(packageMaterial.getPackageDefinition(), is(nullValue()));
    assertThat(packageMaterial.getPackageId(), is(nullValue()));
    verify(packageDefinitionService, never()).performPluginValidationsFor(Matchers.<PackageDefinition>any());
}
Also used : Serializable(java.io.Serializable) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 5 with PackageMaterialConfig

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

the class PackageMaterialAddWithExistingPackageDefinitionCommandTest method shouldUpdateConfigWithNewMaterial.

@Test
public void shouldUpdateConfigWithNewMaterial() {
    PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(0);
    String repoId = packageDefinition.getRepository().getId();
    String pkgId = packageDefinition.getId();
    HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialAssociation(repoId, pkgId);
    PackageMaterialConfig materialToBeCreated = new PackageMaterialConfig();
    PackageMaterialAddWithExistingPackageDefinitionCommand command = new PackageMaterialAddWithExistingPackageDefinitionCommand(packageDefinitionService, securityService, pipelineName, materialToBeCreated, admin, params);
    command.update(cruiseConfig);
    PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    assertThat(pipelineConfig.materialConfigs().last() instanceof PackageMaterialConfig, is(true));
    PackageMaterialConfig packageMaterial = (PackageMaterialConfig) pipelineConfig.materialConfigs().last();
    assertThat(packageMaterial, is(materialToBeCreated));
    assertThat(packageMaterial.getPackageDefinition(), is(packageDefinition));
    verify(packageDefinitionService, never()).performPluginValidationsFor(packageDefinition);
}
Also used : Serializable(java.io.Serializable) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.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