Search in sources :

Example 1 with NullPlugin

use of com.thoughtworks.go.domain.NullPlugin 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 NullPlugin

use of com.thoughtworks.go.domain.NullPlugin in project gocd by gocd.

the class PluginService method savePluginSettingsFor.

public void savePluginSettingsFor(PluginSettings pluginSettings) {
    Plugin plugin = pluginDao.findPlugin(pluginSettings.getPluginId());
    if (plugin instanceof NullPlugin) {
        plugin = new Plugin(pluginSettings.getPluginId(), null);
    }
    Map<String, String> settingsMap = pluginSettings.getSettingsAsKeyValuePair();
    plugin.setConfiguration(toJSON(settingsMap));
    pluginDao.saveOrUpdate(plugin);
}
Also used : NullPlugin(com.thoughtworks.go.domain.NullPlugin) Plugin(com.thoughtworks.go.domain.Plugin) NullPlugin(com.thoughtworks.go.domain.NullPlugin)

Example 3 with NullPlugin

use of com.thoughtworks.go.domain.NullPlugin 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 NullPlugin

use of com.thoughtworks.go.domain.NullPlugin in project gocd by gocd.

the class PluginSqlMapDaoIntegrationTest method shouldReturnNullPluginIfPluginIdDoesNotExist.

@Test
public void shouldReturnNullPluginIfPluginIdDoesNotExist() throws Exception {
    Plugin pluginInDB = pluginSqlMapDao.findPlugin("non-existing-plugin-id");
    assertThat(pluginInDB, is(new NullPlugin()));
}
Also used : NullPlugin(com.thoughtworks.go.domain.NullPlugin) Plugin(com.thoughtworks.go.domain.Plugin) NullPlugin(com.thoughtworks.go.domain.NullPlugin) Test(org.junit.Test)

Example 5 with NullPlugin

use of com.thoughtworks.go.domain.NullPlugin in project gocd by gocd.

the class PluginSettingsRequestProcessorTest method shouldNotGetPluginSettingsForPluginThatDoesNotExistInDB.

@Test
public void shouldNotGetPluginSettingsForPluginThatDoesNotExistInDB() {
    when(pluginDescriptor.id()).thenReturn("plugin-foo-id");
    when(pluginSqlMapDao.findPlugin("plugin-foo-id")).thenReturn(new NullPlugin());
    String requestBody = "expected-request";
    when(jsonMessageHandler.responseMessagePluginSettingsGet(any(PluginSettings.class))).thenReturn(null);
    DefaultGoApiRequest apiRequest = new DefaultGoApiRequest(PluginSettingsRequestProcessor.GET_PLUGIN_SETTINGS, "1.0", null);
    apiRequest.setRequestBody(requestBody);
    GoApiResponse response = processor.process(pluginDescriptor, apiRequest);
    assertThat(response.responseCode(), is(200));
    assertThat(response.responseBody(), is(nullValue()));
}
Also used : GoApiResponse(com.thoughtworks.go.plugin.api.response.GoApiResponse) PluginSettings(com.thoughtworks.go.server.domain.PluginSettings) NullPlugin(com.thoughtworks.go.domain.NullPlugin) DefaultGoApiRequest(com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest) Test(org.junit.Test)

Aggregations

NullPlugin (com.thoughtworks.go.domain.NullPlugin)7 Plugin (com.thoughtworks.go.domain.Plugin)6 PluginSettings (com.thoughtworks.go.server.domain.PluginSettings)4 Before (org.junit.Before)2 Test (org.junit.Test)2 PluginSettingsConfiguration (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration)1 PluginSettingsProperty (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty)1 DefaultGoApiRequest (com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest)1 DefaultGoApiResponse (com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse)1 GoApiResponse (com.thoughtworks.go.plugin.api.response.GoApiResponse)1 HashMap (java.util.HashMap)1