use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class UpdatePackageConfigCommandTest method shouldValidateIfPackageNameIsNull.
@Test
public void shouldValidateIfPackageNameIsNull() throws Exception {
PackageRepository repository = cruiseConfig.getPackageRepositories().find("repoId");
PackageDefinition pkg = new PackageDefinition("Id", null, new Configuration());
pkg.setRepository(repository);
repository.addPackage(pkg);
cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
UpdatePackageConfigCommand command = new UpdatePackageConfigCommand(goConfigService, packageUuid, pkg, currentUser, "md5", this.entityHashingService, result, packageDefinitionService);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
assertThat(pkg.errors().size(), is(1));
assertThat(pkg.errors().firstError(), is("Package name is mandatory"));
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class GoConfigMaterialsTest method getPackageMaterialConfigWithAutoUpdateTrue.
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);
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class JsonMessageHandler2_0_Test method createPipeline.
private Pipeline createPipeline() throws Exception {
Pipeline pipeline = PipelineMother.pipelineWithAllTypesOfMaterials("pipeline-name", "stage-name", "job-name", "1");
List<MaterialRevision> materialRevisions = pipeline.getMaterialRevisions().getRevisions();
PackageDefinition packageDefinition = ((PackageMaterial) materialRevisions.get(6).getMaterial()).getPackageDefinition();
packageDefinition.getRepository().getConfiguration().get(1).handleSecureValueConfiguration(true);
packageDefinition.getConfiguration().addNewConfigurationWithValue("k4", "package-v2", false);
packageDefinition.getConfiguration().get(1).handleSecureValueConfiguration(true);
SCM scm = ((PluggableSCMMaterial) materialRevisions.get(7).getMaterial()).getScmConfig();
scm.getConfiguration().get(1).handleSecureValueConfiguration(true);
Stage stage = pipeline.getFirstStage();
stage.setId(1L);
stage.setPipelineId(1L);
stage.setCreatedTime(new Timestamp(getFixedDate().getTime()));
stage.setLastTransitionedTime(new Timestamp(getFixedDate().getTime()));
JobInstance job = stage.getJobInstances().get(0);
job.setScheduledDate(getFixedDate());
job.getTransition(JobState.Assigned).setStateChangeTime(getFixedDate());
job.getTransition(JobState.Completed).setStateChangeTime(getFixedDate());
return pipeline;
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldNotWriteToFileWithDefaultValueOfTrueForPackageDefinitionAutoUpdateWhenTrue.
@Test
public void shouldNotWriteToFileWithDefaultValueOfTrueForPackageDefinitionAutoUpdateWhenTrue() throws Exception {
Configuration configuration = new Configuration(getConfigurationProperty("url", false, "http://go"));
CruiseConfig cruiseConfig = new BasicCruiseConfig();
Packages packages = new Packages();
PackageRepository repository = createPackageRepository("plugin-id", "version", "id", "name", configuration, packages);
PackageDefinition aPackage = new PackageDefinition("package-id", "package-name", configuration);
aPackage.setAutoUpdate(true);
packages.add(aPackage);
aPackage.setRepository(repository);
cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
xmlWriter.write(cruiseConfig, output, false);
assertThat(output.toString().contains("autoUpdate=\"true\""), is(false));
}
use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldWriteRepositoryConfigurationWithPackages.
@Test
public void shouldWriteRepositoryConfigurationWithPackages() throws Exception {
CruiseConfig configToSave = new BasicCruiseConfig();
PackageRepository packageRepository = new PackageRepository();
packageRepository.setId("id");
packageRepository.setName("name");
packageRepository.setPluginConfiguration(new PluginConfiguration("plugin-id", "version"));
packageRepository.setConfiguration(new Configuration(getConfigurationProperty("url", false, "http://go"), getConfigurationProperty("secure", true, "secure")));
PackageDefinition packageDefinition = new PackageDefinition("id", "name", new Configuration(getConfigurationProperty("name", false, "go-agent")));
packageDefinition.setRepository(packageRepository);
packageRepository.getPackages().add(packageDefinition);
configToSave.getPackageRepositories().add(packageRepository);
xmlWriter.write(configToSave, output, false);
GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(output.toString());
PackageRepositories packageRepositories = goConfigHolder.config.getPackageRepositories();
assertThat(packageRepositories, is(configToSave.getPackageRepositories()));
assertThat(packageRepositories.get(0).getConfiguration().first().getConfigurationValue().getValue(), is("http://go"));
assertThat(packageRepositories.get(0).getConfiguration().first().getEncryptedConfigurationValue(), is(nullValue()));
assertThat(packageRepositories.get(0).getConfiguration().last().getEncryptedValue(), is(new GoCipher().encrypt("secure")));
assertThat(packageRepositories.get(0).getConfiguration().last().getConfigurationValue(), is(nullValue()));
assertThat(packageRepositories.get(0).getPackages().get(0), is(packageDefinition));
assertThat(packageRepositories.get(0).getPackages().get(0).getConfiguration().first().getConfigurationValue().getValue(), is("go-agent"));
assertThat(packageRepositories.get(0).getPackages().get(0).getConfiguration().first().getEncryptedConfigurationValue(), is(nullValue()));
}
Aggregations