use of com.thoughtworks.go.domain.packagerepository.PackageDefinition 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.domain.packagerepository.PackageDefinition 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.domain.packagerepository.PackageDefinition 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.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class PackageMaterialSaveCommandTestBase method setup.
@Before
public void setup() throws Exception {
initMocks(this);
cruiseConfig = GoConfigMother.configWithPackageRepo("repo1");
pipelineName = "test";
PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig(pipelineName);
PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(0);
pipelineConfig.materialConfigs().add(0, new PackageMaterialConfig(null, "repo1-pkg-1", packageDefinition));
pipelineGroup = "grp1";
cruiseConfig.addPipeline(pipelineGroup, pipelineConfig);
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class PackageMaterialUpdateWithExistingPackageDefinitionCommandTest method shouldUpdateMaterialWithExistingPackageDefinition.
@Test
public void shouldUpdateMaterialWithExistingPackageDefinition() {
PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(1);
String repoId = packageDefinition.getRepository().getId();
String pkgId = packageDefinition.getId();
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(packageDefinition));
verify(packageDefinitionService, never()).performPluginValidationsFor(packageDefinition);
}
Aggregations