GitHubProvider extends DefaultProvider { GHCommitState getState(String result) { result = result == null ? "" : result; GHCommitState state = GHCommitState.PENDING; if (result.equalsIgnoreCase("Passed")) { state = GHCommitState.SUCCESS; } else if (result.equalsIgnoreCase("Failed")) { state = GHCommitState.FAILURE; } else if (result.equalsIgnoreCase("Cancelled")) { state = GHCommitState.ERROR; } return state; } GitHubProvider(); @Override String pluginId(); @Override String pollerPluginId(); @Override void updateStatus(String url, PluginSettings pluginSettings, String prIdStr, String revision, String pipelineStage,
                             String result, String trackbackURL); @Override List<Map<String, Object>> validateConfig(Map<String, Object> fields); String getRepository(String url); static final String PLUGIN_ID; static final String GITHUB_PR_POLLER_PLUGIN_ID; }
@Test public void shouldGetStateFromResult() { assertThat(provider.getState("Unknown"), is(GHCommitState.PENDING)); assertThat(provider.getState("Passed"), is(GHCommitState.SUCCESS)); assertThat(provider.getState("Failed"), is(GHCommitState.FAILURE)); assertThat(provider.getState("Cancelled"), is(GHCommitState.ERROR)); }