use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class PackageDefinitionServiceIntegrationTest method shouldDeletePackageDefinition.
@Test
public void shouldDeletePackageDefinition() throws Exception {
String packageUuid = "random-uuid";
String packageName = "prettyjson";
Configuration configuration = new Configuration();
configuration.add(new ConfigurationProperty(new ConfigurationKey("PACKAGE_ID"), new ConfigurationValue("prettyjson")));
PackageDefinition packageDefinition = new PackageDefinition(packageUuid, packageName, configuration);
PackageRepositories repositories = goConfigService.getConfigForEditing().getPackageRepositories();
PackageRepository repository = repositories.find(repoId);
repository.addPackage(packageDefinition);
repositories.removePackageRepository(repoId);
repositories.add(repository);
goConfigService.getConfigForEditing().setPackageRepositories(repositories);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
expectedResult.setMessage(EntityType.PackageDefinition.deleteSuccessful(packageDefinition.getId()));
assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId).getPackages().find(packageUuid), is(packageDefinition));
service.deletePackage(packageDefinition, user, result);
assertThat(result, is(expectedResult));
assertNull(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId).getPackages().find(packageUuid));
}
Aggregations