use of com.thoughtworks.go.domain.packagerepository.Packages 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.Packages in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldNotWriteToFileWithDefaultValueOfTrueForPackageDefinitionAutoUpdateWhenTrue.
@Test
public void shouldNotWriteToFileWithDefaultValueOfTrueForPackageDefinitionAutoUpdateWhenTrue() throws Exception {
Configuration configuration = new Configuration(getConfigurationProperty("url", false, "http://go"));
CruiseConfig cruiseConfig = new BasicCruiseConfig();
Packages packages = new Packages();
PackageRepository repository = createPackageRepository("plugin-id", "version", "id", "name", configuration, packages);
PackageDefinition aPackage = new PackageDefinition("package-id", "package-name", configuration);
aPackage.setAutoUpdate(true);
packages.add(aPackage);
aPackage.setRepository(repository);
cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
xmlWriter.write(cruiseConfig, output, false);
assertThat(output.toString().contains("autoUpdate=\"true\""), is(false));
}
use of com.thoughtworks.go.domain.packagerepository.Packages in project gocd by gocd.
the class GoConfigMother method configWithPackageRepo.
public static CruiseConfig configWithPackageRepo(String... ids) throws Exception {
final CruiseConfig config = new BasicCruiseConfig();
PackageConfigurations configuration = new PackageConfigurations();
configuration.addConfiguration(new PackageConfiguration("key1"));
configuration.addConfiguration(new PackageConfiguration("key2").with(PackageConfiguration.SECURE, true));
RepositoryMetadataStore.getInstance().addMetadataFor("plugin-1", configuration);
for (String id : ids) {
PackageRepository packageRepository = new PackageRepository();
packageRepository.setId(id);
packageRepository.setName("name" + id);
packageRepository.setPluginConfiguration(new PluginConfiguration("plugin-1", "1.0.0"));
packageRepository.setPackages(new Packages(PackageDefinitionMother.create(id + "-pkg-1", packageRepository), PackageDefinitionMother.create(id + "-pkg-2", packageRepository)));
GoCipher cipher = new GoCipher();
ConfigurationProperty p1 = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"));
ConfigurationProperty p2 = new ConfigurationProperty(new ConfigurationKey("key2"), null, new EncryptedConfigurationValue(cipher.encrypt("value2")), cipher);
packageRepository.setConfiguration(new Configuration(p1, p2));
config.setPackageRepositories(new PackageRepositories(packageRepository));
}
return config;
}
use of com.thoughtworks.go.domain.packagerepository.Packages in project gocd by gocd.
the class PackageConfigCommand method isValid.
public boolean isValid(CruiseConfig preprocessedConfig, String repositoryId) {
PackageRepositories packageRepositories = preprocessedConfig.getPackageRepositories();
PackageRepository repository = packageRepositories.find(repositoryId);
Packages packages = repository.getPackages();
preprocessedPackageDefinition = packages.find(this.packageDefinition.getId());
preprocessedPackageDefinition.validate(null);
if (preprocessedPackageDefinition.getAllErrors().isEmpty()) {
packageRepositories.validate(null);
packages.validate(null);
packageDefinitionService.validatePackageConfiguration(preprocessedPackageDefinition);
BasicCruiseConfig.copyErrors(preprocessedPackageDefinition, packageDefinition);
return preprocessedPackageDefinition.getAllErrors().isEmpty() && result.isSuccessful();
}
BasicCruiseConfig.copyErrors(preprocessedPackageDefinition, packageDefinition);
return false;
}
Aggregations