use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class PluggableTaskTest method shouldIgnoreKeysPresentInConfigAttributesMapButNotPresentInConfigStore.
@Test
public void shouldIgnoreKeysPresentInConfigAttributesMapButNotPresentInConfigStore() throws Exception {
TaskPreference taskPreference = mock(TaskPreference.class);
Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
PluggableTaskConfigStore.store().setPreferenceFor("abc.def", taskPreference);
PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
TaskConfig taskConfig = new TaskConfig();
TaskProperty property1 = new TaskProperty("KEY1", "value1");
taskConfig.addProperty(property1.getName());
when(taskPreference.getConfig()).thenReturn(taskConfig);
task.setTaskConfigAttributes(attributeMap);
assertThat(task.configAsMap().get("KEY1").get(PluggableTask.VALUE_KEY), is("value1"));
assertFalse(task.configAsMap().containsKey("Key2"));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class CruiseConfigTestBase method shouldAddPackageDefinitionToGivenRepository.
@Test
public void shouldAddPackageDefinitionToGivenRepository() throws Exception {
String repoId = "repo-id";
PackageRepository packageRepository = PackageRepositoryMother.create(repoId, "repo-name", "plugin-id", "1.0", new Configuration());
PackageDefinition existing = PackageDefinitionMother.create("pkg-1", "pkg1-name", new Configuration(), packageRepository);
packageRepository.setPackages(new Packages(existing));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository));
Configuration configuration = new Configuration();
configuration.add(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")));
configuration.add(new ConfigurationProperty(new ConfigurationKey("key-with-no-value"), new ConfigurationValue("")));
PackageDefinition packageDefinition = PackageDefinitionMother.create(null, "pkg2-name", configuration, packageRepository);
cruiseConfig.savePackageDefinition(packageDefinition);
assertThat(cruiseConfig.getPackageRepositories().size(), is(1));
assertThat(cruiseConfig.getPackageRepositories().get(0).getId(), is(repoId));
assertThat(cruiseConfig.getPackageRepositories().get(0).getPackages().size(), is(2));
assertThat(cruiseConfig.getPackageRepositories().get(0).getPackages().get(0).getId(), is(existing.getId()));
PackageDefinition createdPkgDef = cruiseConfig.getPackageRepositories().get(0).getPackages().get(1);
assertThat(createdPkgDef.getId(), is(notNullValue()));
assertThat(createdPkgDef.getConfiguration().getProperty("key"), is(Matchers.notNullValue()));
assertThat(createdPkgDef.getConfiguration().getProperty("key-with-no-value"), is(nullValue()));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class CruiseConfigTestBase method shouldDecideIfRepoCanBeDeleted_BasedOnPackageRepositoryBeingUsedByPipelines.
@Test
public void shouldDecideIfRepoCanBeDeleted_BasedOnPackageRepositoryBeingUsedByPipelines() throws Exception {
PackageRepository repo1 = PackageRepositoryMother.create(null, "repo1", "plugin", "1.3", new Configuration());
PackageRepository repo2 = PackageRepositoryMother.create(null, "repo2", "plugin", "1.3", new Configuration());
PackageDefinition packageDefinition = PackageDefinitionMother.create("package", repo2);
repo2.addPackage(packageDefinition);
PipelineConfig pipeline = PipelineConfigMother.pipelineConfig("pipeline");
pipeline.addMaterialConfig(new PackageMaterialConfig(new CaseInsensitiveString("p1"), packageDefinition.getId(), packageDefinition));
cruiseConfig.addPipeline("existing_group", pipeline);
cruiseConfig.savePackageRepository(repo1);
cruiseConfig.savePackageRepository(repo2);
assertThat(cruiseConfig.canDeletePackageRepository(repo1), is(true));
assertThat(cruiseConfig.canDeletePackageRepository(repo2), is(false));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class CruiseConfigTestBase method shouldRemovePackageRepositoryById.
@Test
public void shouldRemovePackageRepositoryById() throws Exception {
PackageRepository packageRepository = PackageRepositoryMother.create(null, "repo", "pid", "1.3", new Configuration());
cruiseConfig.savePackageRepository(packageRepository);
cruiseConfig.removePackageRepository(packageRepository.getId());
assertThat(cruiseConfig.getPackageRepositories().find(packageRepository.getId()), is(Matchers.nullValue()));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class PackageRepositoryMother method create.
public static PackageRepository create(String id) {
PackageRepository packageRepository = create(id, "repo-" + id, "plugin", "1.0", new Configuration());
packageRepository.setPackages(new Packages(PackageDefinitionMother.create("package-name", packageRepository)));
return packageRepository;
}
Aggregations