Search in sources :

Example 26 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)

Example 27 with PackageMaterialConfig

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

the class PackageMaterialUpdateWithNewPackageDefinitionCommandTest method shouldUpdateMaterialWithNewPackageDefinition.

@Test
public void shouldUpdateMaterialWithNewPackageDefinition() {
    String repoId = "repo1";
    String pkgName = "pkg-2";
    HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialCreation(repoId, pkgName);
    PackageMaterialUpdateWithNewPackageDefinitionCommand command = new PackageMaterialUpdateWithNewPackageDefinitionCommand(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(notNullValue()));
    assertThat(editedMaterial.getPackageDefinition().getId(), is(notNullValue()));
    assertThat(editedMaterial.getPackageDefinition().getRepository().getId(), is(repoId));
    assertThat(editedMaterial.getPackageDefinition().getName(), is(pkgName));
    assertThat(editedMaterial.getPackageDefinition().getConfiguration().size(), is(2));
    assertThat(editedMaterial.getPackageDefinition().getConfiguration().getProperty("key1").getConfigurationValue().getValue(), is("value1"));
    assertThat(editedMaterial.getPackageDefinition().getConfiguration().getProperty("key2").getConfigurationValue().getValue(), is("value2"));
    verify(packageDefinitionService, times(1)).performPluginValidationsFor(editedMaterial.getPackageDefinition());
}
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)22 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