@Test public void shouldValidateTask() { Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1")); PluggableTask task = new PluggableTask("abc", new PluginConfiguration("abc.def", "1"), configuration); ValidationResult validationResult = new ValidationResult(); validationResult.addError(new ValidationError("KEY1", "error message")); when(pluginManager.doOn( eq(Task.class), eq(task.getPluginConfiguration().getId()), any(ActionWithReturn.class))) .thenReturn(validationResult); pluggableTaskService.validate(task); assertThat(task.getConfiguration().getProperty("KEY1").errors().isEmpty(), is(false)); assertThat( task.getConfiguration().getProperty("KEY1").errors().firstError(), is("error message")); }
public PluggableViewModel<PluggableTask> viewModelFor( final PluggableTask pluggableTask, String actionName) { if (PluggableTaskConfigStore.store() .hasPreferenceFor(pluggableTask.getPluginConfiguration().getId())) { TaskPreference taskPreference = PluggableTaskConfigStore.store() .preferenceFor(pluggableTask.getPluginConfiguration().getId()); return new PluggableTaskViewModel( pluggableTask, viewTemplates.get(actionName), Renderer.ERB, taskPreference.getView().displayValue(), getTemplate(taskPreference.getView())); } return new MissingPluggableTaskViewModel( pluggableTask, viewTemplates.get(actionName), Renderer.ERB); }