GerritProvider extends DefaultProvider { @Override public PluginSettings pluginSettings(Map<String, String> responseBodyMap) { return new GerritPluginSettings( responseBodyMap.get(PLUGIN_SETTINGS_SERVER_BASE_URL), responseBodyMap.get(PLUGIN_SETTINGS_END_POINT), responseBodyMap.get(PLUGIN_SETTINGS_USERNAME), responseBodyMap.get(PLUGIN_SETTINGS_PASSWORD), responseBodyMap.get(PLUGIN_SETTINGS_OAUTH_TOKEN), responseBodyMap.get(GerritConfigurationView.PLUGIN_SETTINGS_REVIEW_LABEL) ); } GerritProvider();  GerritProvider(HTTPClient httpClient); @Override String pluginId(); @Override String pollerPluginId(); @Override void updateStatus(String url, PluginSettings pluginSettings, String branch, String revision, String pipelineInstance,
                             String result, String trackbackURL); @Override List<Map<String, Object>> validateConfig(Map<String, Object> fields); @Override PluginSettings pluginSettings(Map<String, String> responseBodyMap); int getCodeReviewValue(String result); static final String PLUGIN_ID; static final String GERRIT_CS_POLLER_PLUGIN_ID; static final int IN_PROGRESS_VALUE; static final int SUCCESS_VALUE; static final int FAILURE_VALUE; }
@Test public void shouldReturnGerritSettingsObject() { Map<String, String> responseBodyMap = new HashMap<String, String>(); responseBodyMap.put(PLUGIN_SETTINGS_SERVER_BASE_URL, "url"); responseBodyMap.put(PLUGIN_SETTINGS_END_POINT, "endpoint"); responseBodyMap.put(PLUGIN_SETTINGS_USERNAME, "username"); responseBodyMap.put(PLUGIN_SETTINGS_PASSWORD, "password"); responseBodyMap.put(PLUGIN_SETTINGS_OAUTH_TOKEN, "token"); responseBodyMap.put(PLUGIN_SETTINGS_REVIEW_LABEL, "label"); PluginSettings pluginSettings = provider.pluginSettings(responseBodyMap); assertThat(pluginSettings instanceof GerritPluginSettings, is(true)); GerritPluginSettings gerritPluginSettings = (GerritPluginSettings) pluginSettings; assertThat(gerritPluginSettings.getServerBaseURL(), is("url")); assertThat(gerritPluginSettings.getEndPoint(), is("endpoint")); assertThat(gerritPluginSettings.getUsername(), is("username")); assertThat(gerritPluginSettings.getPassword(), is("password")); assertThat(gerritPluginSettings.getOauthToken(), is("token")); assertThat(gerritPluginSettings.getReviewLabel(), is("label")); }