Search in sources :

Example 21 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig 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 22 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig 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 23 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig 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)

Example 24 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PackageMaterialAddWithNewPackageDefinitionCommandTest method shouldUpdateConfigWithNewMaterialAndPackageDefinition.

@Test
public void shouldUpdateConfigWithNewMaterialAndPackageDefinition() {
    String repoId = cruiseConfig.getPackageRepositories().get(0).getId();
    String pkgName = "new-package";
    HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialCreation(repoId, pkgName);
    PackageMaterialConfig materialToBeCreated = new PackageMaterialConfig();
    PackageMaterialAddWithNewPackageDefinitionCommand command = new PackageMaterialAddWithNewPackageDefinitionCommand(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(notNullValue()));
    assertThat(packageMaterial.getPackageDefinition().getId(), is(notNullValue()));
    assertThat(packageMaterial.getPackageDefinition(), is(notNullValue()));
    assertThat(packageMaterial.getPackageDefinition(), is(notNullValue()));
    assertThat(packageMaterial.getPackageDefinition().getId(), is(notNullValue()));
    assertThat(packageMaterial.getPackageDefinition().getRepository().getId(), is(repoId));
    assertThat(packageMaterial.getPackageDefinition().getName(), is(pkgName));
    assertThat(packageMaterial.getPackageDefinition().getConfiguration().size(), is(2));
    assertThat(packageMaterial.getPackageDefinition().getConfiguration().getProperty("key1").getConfigurationValue().getValue(), is("value1"));
    assertThat(packageMaterial.getPackageDefinition().getConfiguration().getProperty("key2").getConfigurationValue().getValue(), is("value2"));
    verify(packageDefinitionService, times(1)).performPluginValidationsFor(packageMaterial.getPackageDefinition());
}
Also used : Serializable(java.io.Serializable) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 25 with PipelineConfig

use of com.thoughtworks.go.config.PipelineConfig in project gocd by gocd.

the class PackageMaterialAddWithNewPackageDefinitionCommandTest method shouldHandleDeletedPackageRepo.

@Test
public void shouldHandleDeletedPackageRepo() {
    String repoId = "deleted-repo";
    String pkgName = "new-package";
    HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialCreation(repoId, pkgName);
    PackageMaterialConfig materialToBeCreated = new PackageMaterialConfig();
    PackageMaterialAddWithNewPackageDefinitionCommand command = new PackageMaterialAddWithNewPackageDefinitionCommand(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.getPackageId(), is(nullValue()));
    assertThat(packageMaterial.getPackageDefinition(), is(notNullValue()));
    assertThat(packageMaterial.getPackageDefinition().getId(), is(nullValue()));
    assertThat(packageMaterial.getPackageDefinition().getRepository(), is(nullValue()));
    assertThat(packageMaterial.getPackageDefinition().getName(), is(pkgName));
    assertThat(packageMaterial.getPackageDefinition().getConfiguration().size(), is(0));
    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) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

PipelineConfig (com.thoughtworks.go.config.PipelineConfig)285 Test (org.junit.jupiter.api.Test)185 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)142 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)52 TimeProvider (com.thoughtworks.go.util.TimeProvider)33 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)24 Test (org.junit.Test)23 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)21 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)19 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)15 Materials (com.thoughtworks.go.config.materials.Materials)14 Date (java.util.Date)14 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)13 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)13 StageConfig (com.thoughtworks.go.config.StageConfig)12 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)12 Pipeline (com.thoughtworks.go.domain.Pipeline)12 Modification (com.thoughtworks.go.domain.materials.Modification)12