Search in sources :

Example 26 with PackageDefinition

use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.

the class GoConfigGraphWalkerTest method shouldNotWalkPackageDefinitionWhileTraversingPackageMaterial.

@Test
public void shouldNotWalkPackageDefinitionWhileTraversingPackageMaterial() {
    PackageDefinition packageDefinition = mock(PackageDefinition.class);
    PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig("package-id");
    setField(packageMaterialConfig, "packageDefinition", packageDefinition);
    BasicCruiseConfig config = new BasicCruiseConfig();
    PackageRepository packageRepository = mock(PackageRepository.class);
    when(packageRepository.getPackages()).thenReturn(new Packages(packageDefinition));
    when(packageDefinition.getRepository()).thenReturn(packageRepository);
    when(packageRepository.doesPluginExist()).thenReturn(true);
    when(packageDefinition.getId()).thenReturn("package-id");
    config.getPackageRepositories().add(packageRepository);
    final ConfigSaveValidationContext context = new ConfigSaveValidationContext(config);
    new GoConfigGraphWalker(packageMaterialConfig).walk(new GoConfigGraphWalker.Handler() {

        @Override
        public void handle(Validatable validatable, ValidationContext ctx) {
            validatable.validate(context);
        }
    });
    verify(packageDefinition, never()).validate(any(ValidationContext.class));
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) Packages(com.thoughtworks.go.domain.packagerepository.Packages) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Example 27 with PackageDefinition

use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.

the class PackageDefinitionCreator method createNewPackageDefinition.

public PackageDefinition createNewPackageDefinition(CruiseConfig cruiseConfig) {
    Map packageDefinitionMap = (Map) params.get(PACKAGE_DEFINITION);
    String repositoryId = (String) packageDefinitionMap.get(REPOSITORY_ID);
    PackageRepository packageRepository = cruiseConfig.getPackageRepositories().find(repositoryId);
    PackageDefinition packageDefinition = new PackageDefinition();
    packageDefinition.setRepository(packageRepository);
    packageDefinition.setConfigAttributes(packageDefinitionMap);
    if (packageRepository != null) {
        validatePackageDefinition(packageDefinition);
        cruiseConfig.savePackageDefinition(packageDefinition);
    }
    return packageDefinition;
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Map(java.util.Map)

Example 28 with PackageDefinition

use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.

the class PackageMaterialAddWithExistingPackageDefinitionCommand method updateConfig.

@Override
protected void updateConfig(CruiseConfig cruiseConfig) {
    PackageDefinition packageDefinition = getPackageDefinition(cruiseConfig);
    packageMaterialConfig.setPackageDefinition(packageDefinition);
    PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipeline));
    pipelineConfig.addMaterialConfig(packageMaterialConfig);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 29 with PackageDefinition

use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.

the class PackageMaterialAddWithNewPackageDefinitionCommand method updateConfig.

@Override
protected void updateConfig(CruiseConfig cruiseConfig) {
    PackageDefinition packageDefinition = createNewPackageDefinition(cruiseConfig);
    packageMaterialConfig.setPackageDefinition(packageDefinition);
    PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipeline));
    pipelineConfig.addMaterialConfig(packageMaterialConfig);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 30 with PackageDefinition

use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.

the class PackageMaterialUpdateWithExistingPackageDefinitionCommand method updateConfig.

@Override
protected void updateConfig(CruiseConfig cruiseConfig) {
    PackageDefinition packageDefinition = getPackageDefinition(cruiseConfig);
    packageMaterialConfig = (PackageMaterialConfig) cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipeline)).materialConfigs().get(packageMaterialConfig);
    packageMaterialConfig.setPackageDefinition(packageDefinition);
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Aggregations

PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)69 Test (org.junit.Test)47 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)41 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)28 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)12 Configuration (com.thoughtworks.go.domain.config.Configuration)12 Packages (com.thoughtworks.go.domain.packagerepository.Packages)12 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)7 Serializable (java.io.Serializable)7 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)6 Before (org.junit.Before)6 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)4 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)4 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)3 SCM (com.thoughtworks.go.domain.scm.SCM)3 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)3 Username (com.thoughtworks.go.server.domain.Username)3 Timestamp (java.sql.Timestamp)3