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());
}
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());
}
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);
}
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());
}
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());
}
Aggregations