use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class ConfigConverterTest method shouldConvertPackageMaterial.
@Test
void shouldConvertPackageMaterial() {
PackageRepositories repositories = new PackageRepositories();
PackageRepository packageRepository = new PackageRepository();
PackageDefinition definition = new PackageDefinition("package-id", "n", new Configuration());
packageRepository.addPackage(definition);
repositories.add(packageRepository);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setPackageRepositories(repositories);
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
CRPackageMaterial crPackageMaterial = new CRPackageMaterial("name", "package-id");
PackageMaterialConfig packageMaterialConfig = (PackageMaterialConfig) configConverter.toMaterialConfig(crPackageMaterial, context, new SCMs());
assertThat(packageMaterialConfig.getName().toLower()).isEqualTo("name");
assertThat(packageMaterialConfig.getPackageId()).isEqualTo("package-id");
assertThat(packageMaterialConfig.getPackageDefinition()).isEqualTo(definition);
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class DeletePackageRepositoryCommandTest method setup.
@BeforeEach
public void setup() throws Exception {
currentUser = new Username(new CaseInsensitiveString("user"));
cruiseConfig = new GoConfigMother().defaultCruiseConfig();
packageRepository = new PackageRepository();
repoId = "npm";
packageRepository.setId(repoId);
result = new HttpLocalizedOperationResult();
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class CreatePackageConfigCommandTest method shouldValidateIfPackageNameIsInvalid.
@Test
public void shouldValidateIfPackageNameIsInvalid() {
PackageRepository repository = cruiseConfig.getPackageRepositories().find(repoId);
PackageDefinition pkg = new PackageDefinition("Id", "!$#", new Configuration());
pkg.setRepository(repository);
repository.addPackage(pkg);
cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
CreatePackageConfigCommand command = new CreatePackageConfigCommand(goConfigService, pkg, repoId, currentUser, result, packageDefinitionService);
assertFalse(command.isValid(cruiseConfig));
assertThat(pkg.errors().getAllOn("name"), is(Arrays.asList("Invalid Package name '!$#'. This must be alphanumeric and can contain underscores, hyphens and periods (however, it cannot start with a period). The maximum allowed length is 255 characters.")));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class CreatePackageConfigCommandTest method shouldValidateDuplicatePropertiesInConfiguration.
@Test
public void shouldValidateDuplicatePropertiesInConfiguration() {
PackageRepository repository = cruiseConfig.getPackageRepositories().find(repoId);
ConfigurationProperty property = new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value"));
Configuration configuration = new Configuration();
configuration.add(property);
configuration.add(property);
PackageDefinition pkg = new PackageDefinition("Id", "name", configuration);
pkg.setRepository(repository);
repository.addPackage(pkg);
cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
CreatePackageConfigCommand command = new CreatePackageConfigCommand(goConfigService, pkg, repoId, currentUser, result, packageDefinitionService);
assertFalse(command.isValid(cruiseConfig));
assertThat(pkg.getAllErrors().toString(), containsString("Duplicate key 'key' found for Package 'name'"));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class CreatePackageConfigCommandTest method setup.
@BeforeEach
public void setup() throws Exception {
currentUser = new Username(new CaseInsensitiveString("user"));
result = new HttpLocalizedOperationResult();
cruiseConfig = new GoConfigMother().defaultCruiseConfig();
packageId = "prettyjson";
packageUuid = "random-uuid";
configuration = new Configuration(new ConfigurationProperty(new ConfigurationKey("PACKAGE_ID"), new ConfigurationValue(packageId)));
packageDefinition = new PackageDefinition(packageUuid, "prettyjson", configuration);
PackageRepositories repositories = cruiseConfig.getPackageRepositories();
repoId = "repoId";
Configuration configuration = new Configuration(new ConfigurationProperty(new ConfigurationKey("foo"), new ConfigurationValue("bar")));
PluginConfiguration pluginConfiguration = new PluginConfiguration("plugin-id", "1");
repository = new PackageRepository(repoId, "repoName", pluginConfiguration, configuration);
repositories.add(repository);
cruiseConfig.setPackageRepositories(repositories);
}
Aggregations