use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class PluggableTaskTest method isValidShouldVerifyIfPluginIdIsValid.
@Test
public void isValidShouldVerifyIfPluginIdIsValid() {
PluginConfiguration pluginConfiguration = new PluginConfiguration("does_not_exist", "1.1");
Configuration configuration = new Configuration();
PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, configuration);
pluggableTask.isValid();
assertThat(pluggableTask.errors().get("pluggable_task").get(0), is("Could not find plugin for given pluggable id:[does_not_exist]."));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class PluggableTaskTest method validateTreeShouldVerifyIfOnCancelTasksHasErrors.
@Test
public void validateTreeShouldVerifyIfOnCancelTasksHasErrors() {
PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration(), new Configuration());
pluggableTask.onCancelConfig = mock(OnCancelConfig.class);
com.thoughtworks.go.domain.Task cancelTask = mock(com.thoughtworks.go.domain.Task.class);
when(pluggableTask.onCancelConfig.getTask()).thenReturn(cancelTask);
when(cancelTask.hasCancelTask()).thenReturn(false);
when(pluggableTask.onCancelConfig.validateTree(null)).thenReturn(false);
assertFalse(pluggableTask.validateTree(null));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class PluggableTaskTest method validateTreeShouldVerifyIfConfigurationHasErrors.
@Test
public void validateTreeShouldVerifyIfConfigurationHasErrors() {
Configuration configuration = mock(Configuration.class);
PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration(), configuration);
when(configuration.hasErrors()).thenReturn(true);
assertFalse(pluggableTask.validateTree(null));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class PluggableTaskTest method shouldPopulateItselfFromConfigAttributesMap.
@Test
public void shouldPopulateItselfFromConfigAttributesMap() throws Exception {
TaskPreference taskPreference = mock(TaskPreference.class);
Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"), ConfigurationPropertyMother.create("Key2"));
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");
TaskProperty property2 = new TaskProperty("Key2", "value2");
taskConfig.addProperty(property1.getName());
taskConfig.addProperty(property2.getName());
when(taskPreference.getConfig()).thenReturn(taskConfig);
task.setTaskConfigAttributes(attributeMap);
assertThat(task.configAsMap().get("KEY1").get(PluggableTask.VALUE_KEY), is("value1"));
assertThat(task.configAsMap().get("Key2").get(PluggableTask.VALUE_KEY), is("value2"));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class PluggableTaskTest method shouldAddConfigurationPropertiesForAInvalidPlugin.
@Test
public void shouldAddConfigurationPropertiesForAInvalidPlugin() {
List<ConfigurationProperty> configurationProperties = Arrays.asList(ConfigurationPropertyMother.create("key", "value", "encValue"));
PluginConfiguration pluginConfiguration = new PluginConfiguration("does_not_exist", "1.1");
Configuration configuration = new Configuration();
PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, configuration);
pluggableTask.addConfigurations(configurationProperties);
assertThat(configuration.size(), is(1));
}
Aggregations