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;
}
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);
}
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;
}
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()));
}
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()));
}
Aggregations