private PackageMaterialConfig getPackageMaterialConfigWithAutoUpdateTrue() { PackageDefinition packageDefinition = new PackageDefinition("packageWithAutoUpdateFalse", "DTDC Package", new Configuration()); packageDefinition.setRepository(PackageRepositoryMother.create("DTDC")); packageDefinition.setAutoUpdate(true); return new PackageMaterialConfig( new CaseInsensitiveString("Krish"), "packageWithAutoUpdateTrue", packageDefinition); }
private PackageMaterialConfig getPackageMaterialConfigWithAutoUpdateFalse() { PackageDefinition packageDefinition = new PackageDefinition("packageWithAutoUpdateFalse", "DLF Package", new Configuration()); packageDefinition.setRepository(PackageRepositoryMother.create("DLF")); packageDefinition.setAutoUpdate(false); return new PackageMaterialConfig( new CaseInsensitiveString("JamesBond"), "packageWithAutoUpdateFalse", packageDefinition); }
@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(pluginManager.doOn( eq(PackageMaterialProvider.class), eq("plugin-id"), any(ActionWithReturn.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")); }
private PipelineConfig setupPipelineWithPackageMaterial( String pipelineName, String stageName, String jobName) { PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig("p-id"); Configuration repoConfig = new Configuration( ConfigurationPropertyMother.create("repo-key1", false, "repo-k1-value"), ConfigurationPropertyMother.create("repo-key2", false, "repo-k2-value")); PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo-name", "pluginid", "version", repoConfig); Configuration packageConfig = new Configuration( ConfigurationPropertyMother.create("package-key1", false, "package-key1-value"), ConfigurationPropertyMother.create("package-key2", false, "package-key2-value")); PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "package-name", packageConfig, repository); packageMaterialConfig.setPackageDefinition(packageDefinition); repository.getPackages().add(packageDefinition); PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig( pipelineName, stageName, new MaterialConfigs(packageMaterialConfig), jobName); configHelper.addPackageDefinition(packageMaterialConfig); configHelper.addPipeline(pipelineConfig); PackageConfigurations packageConfigurations = new PackageConfigurations(); packageConfigurations.add( new PackageConfiguration("package-key1").with(PackageConfiguration.PART_OF_IDENTITY, true)); packageConfigurations.add( new PackageConfiguration("package-key2") .with(PackageConfiguration.PART_OF_IDENTITY, false)); PackageMetadataStore.getInstance() .addMetadataFor(packageMaterialConfig.getPluginId(), packageConfigurations); PackageConfigurations configuration = new PackageConfigurations(); configuration.add( new PackageConfiguration("repo-key1").with(PackageConfiguration.PART_OF_IDENTITY, true)); configuration.add( new PackageConfiguration("repo-key2").with(PackageConfiguration.PART_OF_IDENTITY, false)); RepositoryMetadataStore.getInstance() .addMetadataFor(packageMaterialConfig.getPluginId(), configuration); return pipelineConfig; }