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