use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class GoConfigMaterialsTest method getPackageMaterialConfigWithAutoUpdateFalse.
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);
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class PluggableTaskViewModelFactoryTest method shouldReturnMissingPluginTaskViewIfPluginIsMissing.
@Test
public void shouldReturnMissingPluginTaskViewIfPluginIsMissing() {
String pluginId = "pluginId";
PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
PluggableViewModel<PluggableTask> viewModel = factory.viewModelFor(new PluggableTask(new PluginConfiguration(pluginId, "1"), new Configuration()), "edit");
assertThat(viewModel.getParameters().get("template"), is(String.format("Associated plugin '%s' not found. Please contact the Go admin to install the plugin.", pluginId)));
assertThat(viewModel.getTypeForDisplay(), is(pluginId));
assertThat(viewModel instanceof MissingPluggableTaskViewModel, is(true));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class PluggableTaskViewModelFactoryTest method dataForViewShouldIncludeErrorsIfAny.
@Test
public void dataForViewShouldIncludeErrorsIfAny() throws Exception {
ConfigurationProperty property1 = create("key1", false, "value1");
property1.addError("key1", "error msg");
ConfigurationProperty property2 = create("KEY2", false, "value2");
Configuration configuration = new Configuration(property1, property2);
PluggableTask taskConfig = new PluggableTask(new PluginConfiguration("plugin-1", "2"), configuration);
PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
PluggableViewModel<PluggableTask> viewModel = factory.viewModelFor(taskConfig, "new");
String actualData = (String) viewModel.getParameters().get("data");
Gson gson = new Gson();
Map actual = gson.fromJson(actualData, Map.class);
Map expected = gson.fromJson("{\"KEY2\":{\"value\": \"value2\"},\"key1\":{\"value\" : \"value1\", \"errors\" : \"error msg\"}}", Map.class);
assertEquals(expected, actual);
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class PluggableTaskViewModelFactoryTest method typeForDisplayAndTemplateOfViewModelShouldBeGotFromThePlugin.
@Test
public void typeForDisplayAndTemplateOfViewModelShouldBeGotFromThePlugin() throws Exception {
PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration("plugin-1", "2"), new Configuration());
PluggableTaskViewModelFactory factory = new PluggableTaskViewModelFactory();
PluggableViewModel<PluggableTask> viewModel = factory.viewModelFor(pluggableTask, "new");
assertThat(viewModel.getTypeForDisplay(), is("First plugin"));
assertThat(viewModel.getParameters().get("template"), is("<input type='text' ng-model='abc'></input>"));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class XmlPartialConfigProviderTest method shouldUseExplicitPatternWhenProvided.
@Test
public void shouldUseExplicitPatternWhenProvided() throws Exception {
GoConfigMother mother = new GoConfigMother();
PipelineConfig pipe1 = mother.cruiseConfigWithOnePipelineGroup().getAllPipelineConfigs().get(0);
File file1 = helper.addFileWithPipeline("pipe1.myextension", pipe1);
File file2 = helper.addFileWithPipeline("pipe1.gcd.xml", pipe1);
File file3 = helper.addFileWithPipeline("subdir/pipe1.gocd.xml", pipe1);
File file4 = helper.addFileWithPipeline("subdir/sub/pipe1.gocd.xml", pipe1);
PartialConfigLoadContext context = mock(PartialConfigLoadContext.class);
Configuration configs = new Configuration();
configs.addNewConfigurationWithValue("pattern", "*.myextension", false);
when(context.configuration()).thenReturn(configs);
File[] matchingFiles = xmlPartialProvider.getFiles(tmpFolder, context);
File[] expected = new File[1];
expected[0] = file1;
assertArrayEquals(expected, matchingFiles);
}
Aggregations