Search in sources :

Example 71 with PackageDefinition

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));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ContextConfiguration(org.springframework.test.context.ContextConfiguration) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.jupiter.api.Test)

Aggregations

PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)71 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)38 Test (org.junit.jupiter.api.Test)36 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)28 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)13 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)11 Packages (com.thoughtworks.go.domain.packagerepository.Packages)11 Test (org.junit.Test)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)8 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)8 Serializable (java.io.Serializable)7 Configuration (com.thoughtworks.go.domain.config.Configuration)6 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)4 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)4 SCM (com.thoughtworks.go.domain.scm.SCM)4 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)4 XsdValidationException (com.thoughtworks.go.util.XsdValidationException)4 Timestamp (java.sql.Timestamp)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4