use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.
the class PluggableTaskServiceTest method isValidShouldSkipValidationAgainstPluginIfPluggableTaskIsInvalid.
@Test
public void isValidShouldSkipValidationAgainstPluginIfPluggableTaskIsInvalid() {
PluggableTask pluggableTask = mock(PluggableTask.class);
when(pluggableTask.isValid()).thenReturn(false);
assertFalse(pluggableTaskService.isValid(pluggableTask));
verifyZeroInteractions(taskExtension);
}
use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.
the class PluggableTaskServiceTest method shouldValidateTask.
@Test
public void shouldValidateTask() {
Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
PluggableTask modifiedTask = new PluggableTask(new PluginConfiguration(pluginId, "1"), configuration);
ValidationResult validationResult = new ValidationResult();
validationResult.addError(new ValidationError("KEY1", "error message"));
when(taskExtension.validate(eq(modifiedTask.getPluginConfiguration().getId()), any(TaskConfig.class))).thenReturn(validationResult);
pluggableTaskService.validate(modifiedTask);
assertThat(modifiedTask.getConfiguration().getProperty("KEY1").errors().isEmpty(), is(false));
assertThat(modifiedTask.getConfiguration().getProperty("KEY1").errors().firstError(), is("error message"));
verify(taskExtension).validate(eq(modifiedTask.getPluginConfiguration().getId()), any(TaskConfig.class));
}
use of com.thoughtworks.go.config.pluggabletask.PluggableTask in project gocd by gocd.
the class PluggableTaskServiceTest method isValidShouldValidateThePluggableTask.
@Test
public void isValidShouldValidateThePluggableTask() {
PluggableTask pluggableTask = mock(PluggableTask.class);
PluginConfiguration pluginConfiguration = new PluginConfiguration("plugin_id", "version");
when(pluggableTask.isValid()).thenReturn(true);
when(pluggableTask.getPluginConfiguration()).thenReturn(pluginConfiguration);
when(taskExtension.validate(any(String.class), any(TaskConfig.class))).thenReturn(new ValidationResult());
assertTrue(pluggableTaskService.isValid(pluggableTask));
}
Aggregations