@Override
    public PluggableTaskPluginInfo pluginInfoFor(GoPluginDescriptor descriptor) {
        final TaskPreference[] tp = {null};
        extension.doOnTask(descriptor.id(), (task, pluginDescriptor) -> tp[0] = new TaskPreference(task));

        TaskConfig config = tp[0].getConfig();
        TaskView view = tp[0].getView();
        if (config == null) {
            throw new RuntimeException(format("Plugin[%s] returned null task configuration", descriptor.id()));
        }
        if (view == null) {
            throw new RuntimeException(format("Plugin[%s] returned null task view", descriptor.id()));
        }
        String displayName = view.displayValue();

        PluggableInstanceSettings taskSettings = new PluggableInstanceSettings(configurations(config), new PluginView(view.template()));
        return new PluggableTaskPluginInfo(descriptor, displayName, taskSettings);
    }
@Test
    public void shouldBuildPluginInfo() throws Exception {
        GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();

        PluggableTaskPluginInfo pluginInfo = new PluggableTaskPluginInfoBuilder(extension) .pluginInfoFor(descriptor);

        List<PluginConfiguration> pluginConfigurations = List.of(
                new PluginConfiguration("username", new Metadata(true, false)),
                new PluginConfiguration("password", new Metadata(true, true))
        );
        PluginView pluginView = new PluginView("some html");

        assertThat(pluginInfo.getDescriptor(), is(descriptor));
        assertThat(pluginInfo.getExtensionName(), is("task"));
        assertThat(pluginInfo.getDisplayName(), is("my task plugin"));
        assertThat(pluginInfo.getTaskSettings(), is(new PluggableInstanceSettings(pluginConfigurations, pluginView)));
        assertNull(pluginInfo.getPluginSettings());
    }