Search in sources :

Example 1 with PluginSettings

use of com.thoughtworks.go.server.domain.PluginSettings in project gocd by gocd.

the class PluginService method getPluginSettingsFor.

public PluginSettings getPluginSettingsFor(String pluginId) {
    PluginSettings pluginSettings = new PluginSettings(pluginId);
    Plugin plugin = pluginDao.findPlugin(pluginId);
    if (plugin instanceof NullPlugin) {
        pluginSettings.populateSettingsMap(PluginSettingsMetadataStore.getInstance().configuration(pluginId));
    } else {
        pluginSettings.populateSettingsMap(plugin);
    }
    return pluginSettings;
}
Also used : PluginSettings(com.thoughtworks.go.server.domain.PluginSettings) NullPlugin(com.thoughtworks.go.domain.NullPlugin) Plugin(com.thoughtworks.go.domain.Plugin) NullPlugin(com.thoughtworks.go.domain.NullPlugin)

Example 2 with PluginSettings

use of com.thoughtworks.go.server.domain.PluginSettings in project gocd by gocd.

the class PluginService method getPluginSettingsFor.

public PluginSettings getPluginSettingsFor(String pluginId, Map<String, String> parameterMap) {
    PluginSettings pluginSettings = new PluginSettings(pluginId);
    pluginSettings.populateSettingsMap(parameterMap);
    return pluginSettings;
}
Also used : PluginSettings(com.thoughtworks.go.server.domain.PluginSettings)

Example 3 with PluginSettings

use of com.thoughtworks.go.server.domain.PluginSettings in project gocd by gocd.

the class PluginSettingsRequestProcessor method handlePluginSettingsGetRequest.

private GoApiResponse handlePluginSettingsGetRequest(String pluginId, GoApiRequest goPluginApiRequest) {
    Plugin plugin = pluginSqlMapDao.findPlugin(pluginId);
    PluginSettings pluginSettings = new PluginSettings(pluginId);
    if (!(plugin instanceof NullPlugin)) {
        pluginSettings.populateSettingsMap(plugin);
    }
    DefaultGoApiResponse response = new DefaultGoApiResponse(200);
    response.setResponseBody(messageHandlerMap.get(goPluginApiRequest.apiVersion()).responseMessagePluginSettingsGet(pluginSettings));
    return response;
}
Also used : DefaultGoApiResponse(com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse) PluginSettings(com.thoughtworks.go.server.domain.PluginSettings) NullPlugin(com.thoughtworks.go.domain.NullPlugin) Plugin(com.thoughtworks.go.domain.Plugin) NullPlugin(com.thoughtworks.go.domain.NullPlugin)

Example 4 with PluginSettings

use of com.thoughtworks.go.server.domain.PluginSettings in project gocd by gocd.

the class PluginServiceTest method shouldStorePluginSettingsToDBIfItDoesNotExist.

@Test
public void shouldStorePluginSettingsToDBIfItDoesNotExist() {
    Map<String, String> parameterMap = new HashMap<>();
    parameterMap.put("p2-k1", "v1");
    parameterMap.put("p2-k2", "");
    parameterMap.put("p2-k3", null);
    PluginSettings pluginSettings = new PluginSettings("plugin-id-2");
    pluginSettings.populateSettingsMap(parameterMap);
    pluginService.savePluginSettingsFor(pluginSettings);
    Plugin plugin = new Plugin("plugin-id-2", toJSON(parameterMap));
    verify(pluginDao).saveOrUpdate(plugin);
}
Also used : PluginSettings(com.thoughtworks.go.server.domain.PluginSettings) NullPlugin(com.thoughtworks.go.domain.NullPlugin) Plugin(com.thoughtworks.go.domain.Plugin) Test(org.junit.Test)

Example 5 with PluginSettings

use of com.thoughtworks.go.server.domain.PluginSettings in project gocd by gocd.

the class PluginServiceTest method shouldUpdatePluginSettingsWithErrorsIfExists.

@Test
public void shouldUpdatePluginSettingsWithErrorsIfExists() {
    when(notificationExtension.canHandlePlugin("plugin-id-4")).thenReturn(true);
    ValidationResult validationResult = new ValidationResult();
    validationResult.addError(new ValidationError("p4-k1", "m1"));
    validationResult.addError(new ValidationError("p4-k3", "m3"));
    when(notificationExtension.validatePluginSettings(eq("plugin-id-4"), any(PluginSettingsConfiguration.class))).thenReturn(validationResult);
    Map<String, String> parameterMap = new HashMap<>();
    parameterMap.put("p4-k1", "v1");
    parameterMap.put("p4-k2", "v2");
    PluginSettings pluginSettings = new PluginSettings("plugin-id-4");
    pluginSettings.populateSettingsMap(parameterMap);
    pluginService.validatePluginSettingsFor(pluginSettings);
    assertThat(pluginSettings.hasErrors(), is(true));
    assertThat(pluginSettings.getErrorFor("p4-k1"), is("m1"));
    assertThat(pluginSettings.getErrorFor("p4-k2"), is(nullValue()));
    assertThat(pluginSettings.getErrorFor("p4-k3"), is("m3"));
}
Also used : PluginSettings(com.thoughtworks.go.server.domain.PluginSettings) ValidationError(com.thoughtworks.go.plugin.api.response.validation.ValidationError) PluginSettingsConfiguration(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) Test(org.junit.Test)

Aggregations

PluginSettings (com.thoughtworks.go.server.domain.PluginSettings)13 Test (org.junit.Test)10 NullPlugin (com.thoughtworks.go.domain.NullPlugin)4 Plugin (com.thoughtworks.go.domain.Plugin)4 PluginSettingsConfiguration (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration)4 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)4 GoPluginExtension (com.thoughtworks.go.plugin.access.common.settings.GoPluginExtension)1 DefaultGoApiResponse (com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse)1 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)1 LinkedHashMap (java.util.LinkedHashMap)1