use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class MaterialServiceTest method shouldGetLatestModificationForPackageMaterial.
@Test
public void shouldGetLatestModificationForPackageMaterial() {
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.getLatestRevision(eq("plugin-id"), any(PackageConfiguration.class), any(RepositoryConfiguration.class))).thenReturn(new PackageRevision("blah-123", new Date(), "user"));
List<Modification> modifications = materialService.latestModification(material, null, null);
assertThat(modifications.get(0).getRevision(), is("blah-123"));
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class PackageMaterialPollerTest method setup.
@Before
public void setup() {
//setup material
material = new PackageMaterial();
PackageRepository packageRepository = PackageRepositoryMother.create("id", "name", "plugin-id", "plugin-version", new Configuration(ConfigurationPropertyMother.create("url", false, "http://some-url")));
PackageDefinition packageDefinition = create("id", "package", new Configuration(ConfigurationPropertyMother.create("name", false, "go-agent"), ConfigurationPropertyMother.create("secure", true, "value")), packageRepository);
material.setPackageDefinition(packageDefinition);
packageRepositoryExtension = mock(PackageRepositoryExtension.class);
poller = new com.thoughtworks.go.server.service.materials.PackageMaterialPoller(packageRepositoryExtension);
packageConfiguration = ArgumentCaptor.forClass(com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration.class);
repositoryConfiguration = ArgumentCaptor.forClass(RepositoryConfiguration.class);
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class PackageMaterialUpdateWithExistingPackageDefinitionCommandTest method shouldHandleDeletedPackageDefinition.
@Test
public void shouldHandleDeletedPackageDefinition() {
PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(1);
String repoId = packageDefinition.getRepository().getId();
String pkgId = "does-not-exist";
HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialAssociation(repoId, pkgId);
PackageMaterialUpdateWithExistingPackageDefinitionCommand command = new PackageMaterialUpdateWithExistingPackageDefinitionCommand(packageDefinitionService, securityService, pipelineName, materialToBeUpdated, admin, params);
command.update(cruiseConfig);
assertThat(pipelineConfig.materialConfigs().first() instanceof PackageMaterialConfig, is(true));
PackageMaterialConfig editedMaterial = (PackageMaterialConfig) pipelineConfig.materialConfigs().first();
assertThat(editedMaterial, is(materialToBeUpdated));
assertThat(editedMaterial.getPackageDefinition(), is(nullValue()));
assertThat(editedMaterial.getPackageId(), is(nullValue()));
verify(packageDefinitionService, never()).performPluginValidationsFor(Matchers.<PackageDefinition>any());
}
Aggregations