use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method validateTreeShouldVerifyIfCancelTasksHasNestedCancelTask.
@Test
public void validateTreeShouldVerifyIfCancelTasksHasNestedCancelTask() {
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(true);
when(pluggableTask.onCancelConfig.validateTree(null)).thenReturn(true);
assertFalse(pluggableTask.validateTree(null));
assertThat(pluggableTask.errors().get("onCancelConfig").get(0), is("Cannot nest 'oncancel' within a cancel task"));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method postConstructShouldHandleSecureConfigurationForConfigurationProperties.
@Test
public void postConstructShouldHandleSecureConfigurationForConfigurationProperties() 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();
taskConfig.addProperty("KEY1").with(Property.SECURE, true);
when(taskPreference.getConfig()).thenReturn(taskConfig);
PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
assertFalse(configurationProperty.isSecure());
task.applyPluginMetadata();
assertTrue(configurationProperty.isSecure());
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method shouldPopulatePropertiesForDisplay.
@Test
public void shouldPopulatePropertiesForDisplay() throws Exception {
Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1", false, "value1"), ConfigurationPropertyMother.create("Key2", false, "value2"), ConfigurationPropertyMother.create("key3", true, "encryptedValue1"));
PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
List<TaskProperty> propertiesForDisplay = task.getPropertiesForDisplay();
assertThat(propertiesForDisplay.size(), is(3));
assertProperty(propertiesForDisplay.get(0), "KEY1", "value1", "key1");
assertProperty(propertiesForDisplay.get(1), "Key2", "value2", "key2");
assertProperty(propertiesForDisplay.get(2), "key3", "****", "key3");
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method validateTreeShouldVerifyIfPluggableTaskHasErrors.
@Test
public void validateTreeShouldVerifyIfPluggableTaskHasErrors() {
PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration(), new Configuration());
pluggableTask.addError("task", "invalid plugin");
assertFalse(pluggableTask.validateTree(null));
}
use of com.thoughtworks.go.domain.config.PluginConfiguration in project gocd by gocd.
the class PluggableTaskTest method isValidShouldVerifyForValidConfigurationProperties.
@Test
public void isValidShouldVerifyForValidConfigurationProperties() {
PluginConfiguration pluginConfiguration = new PluginConfiguration("github.pr", "1.1");
Configuration configuration = mock(Configuration.class);
PluggableTaskConfigStore.store().setPreferenceFor(pluginConfiguration.getId(), mock(TaskPreference.class));
when(configuration.hasErrors()).thenReturn(true);
PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, configuration);
assertFalse(pluggableTask.isValid());
verify(configuration).validateTree();
verify(configuration).hasErrors();
}
Aggregations