use of com.thoughtworks.go.domain.packagerepository.PackageRepository 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.PackageRepository in project gocd by gocd.
the class CreatePackageRepositoryCommandTest method shouldCreatePackageRepository.
@Test
public void shouldCreatePackageRepository() throws Exception {
PackageRepository repository = new PackageRepository("id", "name", new PluginConfiguration(), new Configuration());
CreatePackageRepositoryCommand command = new CreatePackageRepositoryCommand(goConfigService, packageRepositoryService, repository, currentUser, result);
assertNull(cruiseConfig.getPackageRepositories().find("id"));
command.update(cruiseConfig);
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
assertThat(result, is(expectedResult));
assertThat(cruiseConfig.getPackageRepositories().find("id"), is(repository));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class CreatePackageRepositoryCommandTest method setup.
@BeforeEach
public void setup() throws Exception {
currentUser = new Username(new CaseInsensitiveString("user"));
cruiseConfig = GoConfigMother.defaultCruiseConfig();
repoId = "npmOrg";
packageRepository = new PackageRepository(repoId, repoId, new PluginConfiguration("npm", "1"), new Configuration());
result = new HttpLocalizedOperationResult();
cruiseConfig.getPackageRepositories().add(packageRepository);
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository 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.PackageRepository 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'"));
}
Aggregations