Search in sources :

Example 1 with LintResult

use of com.uber.jenkins.phabricator.lint.LintResult in project phabricator-jenkins-plugin by uber.

the class BuildResultProcessorTest method testProcessLintViolations.

@Test
public void testProcessLintViolations() throws Exception {
    String content = "{\"name\": \"Syntax Error\"," + "\"code\": \"EXAMPLE\"," + "\"severity\": \"error\"," + "\"path\": \"path/to/example\"," + "\"line\": 17," + "\"char\": 3}";
    final LintResult result = new LintResult("Syntax Error", "EXAMPLE", "error", "path/to/example", 17, 3, "");
    ConduitAPIClient conduitAPIClient = new ConduitAPIClient(null, null) {

        @Override
        public JSONObject perform(String action, JSONObject params) throws IOException, ConduitAPIException {
            if (action == "harbormaster.sendmessage") {
                JSONObject json = (JSONObject) ((JSONArray) params.get("lint")).get(0);
                JSONObject parsed = result.toHarbormaster();
                assertNotNull(parsed);
                assertNotNull(json);
                for (String key : (Set<String>) params.keySet()) {
                    assertEquals("mismatch in expected json key: " + key, parsed.get(key), json.get(key));
                }
                return result.toHarbormaster();
            }
            return new JSONObject();
        }
    };
    runProcessLintViolationsTest(content, conduitAPIClient);
}
Also used : Set(java.util.Set) JSONObject(net.sf.json.JSONObject) LintResult(com.uber.jenkins.phabricator.lint.LintResult) ConduitAPIClient(com.uber.jenkins.phabricator.conduit.ConduitAPIClient) Test(org.junit.Test)

Example 2 with LintResult

use of com.uber.jenkins.phabricator.lint.LintResult in project phabricator-jenkins-plugin by uber.

the class PhabricatorNotifierTest method testPostToHarbormasterValidLint.

@Test
public void testPostToHarbormasterValidLint() throws Exception {
    JSONObject json = new JSONObject();
    LintResults result = new LintResults();
    result.add(new LintResult("test", "testcode", "error", "to/path", 10, 3, "test description"));
    json.element("lint", result);
    FreeStyleBuild build = buildWithConduit(getFetchDiffResponse(), null, json);
    assertEquals(Result.SUCCESS, build.getResult());
}
Also used : JSONObject(net.sf.json.JSONObject) LintResult(com.uber.jenkins.phabricator.lint.LintResult) LintResults(com.uber.jenkins.phabricator.lint.LintResults) FreeStyleBuild(hudson.model.FreeStyleBuild) Test(org.junit.Test)

Aggregations

LintResult (com.uber.jenkins.phabricator.lint.LintResult)2 JSONObject (net.sf.json.JSONObject)2 Test (org.junit.Test)2 ConduitAPIClient (com.uber.jenkins.phabricator.conduit.ConduitAPIClient)1 LintResults (com.uber.jenkins.phabricator.lint.LintResults)1 FreeStyleBuild (hudson.model.FreeStyleBuild)1 Set (java.util.Set)1