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