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