GerritProvider extends DefaultProvider { @Override public List<Map<String, Object>> validateConfig(Map<String, Object> fields) { List<Map<String, Object>> response = new ArrayList<Map<String, Object>>(); if (!fields.containsKey(GerritConfigurationView.PLUGIN_SETTINGS_REVIEW_LABEL)) { response.add(getValidationError( GerritConfigurationView.PLUGIN_SETTINGS_REVIEW_LABEL, "Review field must be set" )); } return response; } 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 shouldValidateConfigurationSuccessfully() { Map<String, Object> settings = new HashMap<String, Object>(); settings.put("review_label", getSettingValue()); List<Map<String, Object>> validationErrors = provider.validateConfig(settings); assertThat(validationErrors.size(), is(0)); }
@Test public void shouldValidateMissingReviewField() { Map<String, Object> config = new HashMap<String, Object>(); List<Map<String, Object>> validationErrors = provider.validateConfig(config); assertThat(validationErrors.size(), is(1)); assertThat((String) validationErrors.get(0).get("key"), is("review_label")); assertThat((String) validationErrors.get(0).get("message"), is("Review field must be set")); }