use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class PackageMaterialUpdateWithNewPackageDefinitionCommand method updateConfig.
@Override
protected void updateConfig(CruiseConfig cruiseConfig) {
PackageDefinition packageDefinition = createNewPackageDefinition(cruiseConfig);
packageMaterialConfig = (PackageMaterialConfig) cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipeline)).materialConfigs().get(packageMaterialConfig);
packageMaterialConfig.setPackageDefinition(packageDefinition);
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class UpdatePackageConfigCommandTest method shouldValidateDuplicateIdentity.
@Test
public void shouldValidateDuplicateIdentity() throws Exception {
PackageRepository repository = cruiseConfig.getPackageRepositories().find("repoId");
PackageDefinition pkg = new PackageDefinition("Id", "name", configuration);
pkg.setRepository(repository);
repository.addPackage(pkg);
cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
UpdatePackageConfigCommand command = new UpdatePackageConfigCommand(goConfigService, packageUuid, newPackageDefinition, currentUser, "md5", this.entityHashingService, result, packageDefinitionService);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
assertThat(newPackageDefinition.errors().size(), is(1));
assertThat(newPackageDefinition.errors().firstError(), is("Cannot save package or repo, found duplicate packages. [Repo Name: 'repoName', Package Name: 'name'], [Repo Name: 'repoName', Package Name: 'prettyjson']"));
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class UpdatePackageRepositoryCommandTest method shouldCopyPackagesFromOldRepositoryToTheUpdatedRepository.
@Test
public void shouldCopyPackagesFromOldRepositoryToTheUpdatedRepository() throws Exception {
PackageDefinition nodePackage = new PackageDefinition("foo", "bar", new Configuration());
oldPackageRepo.setPackages(new Packages(nodePackage));
UpdatePackageRepositoryCommand command = new UpdatePackageRepositoryCommand(goConfigService, packageRepositoryService, newPackageRepo, currentUser, "md5", entityHashingService, result, repoId);
assertThat(cruiseConfig.getPackageRepositories().find(repoId), is(oldPackageRepo));
assertThat(cruiseConfig.getPackageRepositories().find(repoId).getPackages().size(), is(1));
assertThat(newPackageRepo.getPackages().size(), is(0));
command.update(cruiseConfig);
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
assertThat(result, is(expectedResult));
assertThat(cruiseConfig.getPackageRepositories().find(repoId), is(newPackageRepo));
assertThat(cruiseConfig.getPackageRepositories().find(repoId).getPackages().size(), is(1));
assertThat(cruiseConfig.getPackageRepositories().find(repoId).getPackages().first(), is(nodePackage));
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class CreatePackageConfigCommandTest method setup.
@Before
public void setup() throws Exception {
initMocks(this);
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);
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition 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 and periods (however, it cannot start with a period). The maximum allowed length is 255 characters.")));
}
Aggregations