use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class MaterialServiceTest method shouldGetModificationSinceAGivenRevision.
@Test
public void shouldGetModificationSinceAGivenRevision() {
PackageMaterial material = new PackageMaterial();
PackageDefinition packageDefinition = create("id", "package", new Configuration(), PackageRepositoryMother.create("id", "name", "plugin-id", "plugin-version", new Configuration()));
material.setPackageDefinition(packageDefinition);
when(packageRepositoryExtension.latestModificationSince(eq("plugin-id"), any(PackageConfiguration.class), any(RepositoryConfiguration.class), any(PackageRevision.class))).thenReturn(new PackageRevision("new-revision-456", new Date(), "user"));
List<Modification> modifications = materialService.modificationsSince(material, null, new PackageMaterialRevision("revision-124", new Date()), null);
assertThat(modifications.get(0).getRevision(), is("new-revision-456"));
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class PackageDefinitionCreator method getPackageDefinition.
public PackageDefinition getPackageDefinition(CruiseConfig cruiseConfig) {
Map packageDefinitionMap = (Map) params.get(PACKAGE_DEFINITION);
String repositoryId = (String) packageDefinitionMap.get(REPOSITORY_ID);
PackageRepository packageRepository = cruiseConfig.getPackageRepositories().find(repositoryId);
PackageDefinition packageDefinition = null;
if (packageRepository != null) {
packageDefinition = packageRepository.findPackage((String) params.get(PACKAGE_ID));
}
return packageDefinition;
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class CreatePackageConfigCommandTest method shouldValidateDuplicatePackageName.
@Test
public void shouldValidateDuplicatePackageName() throws Exception {
PackageRepository repository = cruiseConfig.getPackageRepositories().find(repoId);
PackageDefinition pkg = new PackageDefinition("Id", "prettyjson", new Configuration());
pkg.setRepository(repository);
repository.addPackage(pkg);
cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
CreatePackageConfigCommand command = new CreatePackageConfigCommand(goConfigService, packageDefinition, repoId, currentUser, result, packageDefinitionService);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
assertThat(packageDefinition.errors().size(), is(1));
assertThat(packageDefinition.errors().firstError(), is("You have defined multiple packages called 'prettyjson'. Package names are case-insensitive and must be unique within a repository."));
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class CreatePackageConfigCommandTest method shouldValidateIfPackageNameIsNull.
@Test
public void shouldValidateIfPackageNameIsNull() {
PackageDefinition pkg = new PackageDefinition("Id", null, new Configuration());
PackageRepository repository = new PackageRepository(repoId, null, null, null);
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("Package name is mandatory")));
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class CreatePackageConfigCommandTest 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));
CreatePackageConfigCommand command = new CreatePackageConfigCommand(goConfigService, packageDefinition, repoId, currentUser, result, packageDefinitionService);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
assertThat(packageDefinition.errors().size(), is(1));
assertThat(packageDefinition.errors().firstError(), is("Cannot save package or repo, found duplicate packages. [Repo Name: 'repoName', Package Name: 'name'], [Repo Name: 'repoName', Package Name: 'prettyjson']"));
}
Aggregations