use of com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference in project gocd by gocd.
the class PluggableTaskViewModelFactoryTest method setUp.
@Before
public void setUp() throws Exception {
cleanupTaskPreferences();
taskPreference = mock(TaskPreference.class);
PluggableTaskConfigStore.store().setPreferenceFor("plugin-1", taskPreference);
TaskView view = mock(TaskView.class);
when(taskPreference.getView()).thenReturn(view);
when(view.template()).thenReturn("<input type='text' ng-model='abc'></input>");
when(view.displayValue()).thenReturn("First plugin");
}
use of com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference in project gocd by gocd.
the class PluggableTaskTest method shouldAddPropertyComingFromAttributesMapIfPresentInConfigStoreEvenIfItISNotPresentInCurrentConfiguration.
@Test
public void shouldAddPropertyComingFromAttributesMapIfPresentInConfigStoreEvenIfItISNotPresentInCurrentConfiguration() 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");
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.plugin.access.pluggabletask.TaskPreference in project gocd by gocd.
the class PluggableTaskTest method postConstructShouldDoNothingForAInvalidConfigurationProperty.
@Test
public void postConstructShouldDoNothingForAInvalidConfigurationProperty() throws Exception {
TaskPreference taskPreference = mock(TaskPreference.class);
ConfigurationProperty configurationProperty = ConfigurationPropertyMother.create("KEY1");
Configuration configuration = new Configuration(configurationProperty);
PluggableTaskConfigStore.store().setPreferenceFor("abc.def", taskPreference);
TaskConfig taskConfig = new TaskConfig();
when(taskPreference.getConfig()).thenReturn(taskConfig);
PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
assertFalse(configurationProperty.isSecure());
task.applyPluginMetadata();
assertFalse(configurationProperty.isSecure());
}
use of com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference in project gocd by gocd.
the class PluggableTaskTest method shouldHandleSecureConfigurations.
@Test
public void shouldHandleSecureConfigurations() throws Exception {
TaskPreference taskPreference = mock(TaskPreference.class);
Configuration configuration = new Configuration();
PluggableTaskConfigStore.store().setPreferenceFor("abc.def", taskPreference);
PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1");
TaskConfig taskConfig = new TaskConfig();
taskConfig.addProperty("KEY1").with(Property.SECURE, true);
when(taskPreference.getConfig()).thenReturn(taskConfig);
task.setTaskConfigAttributes(attributeMap);
assertThat(task.getConfiguration().size(), is(1));
assertTrue(task.getConfiguration().first().isSecure());
assertThat(task.getConfiguration().first().getValue(), is("value1"));
}
use of com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference 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"));
}
Aggregations