use of net.sf.json.JSONNull in project phabricator-jenkins-plugin by uber.
the class SendHarbormasterResultTask method sendMessage.
/**
* Try to send a message to harbormaster
* @param unitResults the unit testing results to send
* @param coverage the coverage data to send
* @return false if an error was encountered
*/
private boolean sendMessage(UnitResults unitResults, Map<String, String> coverage, LintResults lintResults) throws IOException, ConduitAPIException {
JSONObject result = diffClient.sendHarbormasterMessage(phid, harbormasterSuccess, unitResults, coverage, lintResults);
if (result.containsKey("error_info") && !(result.get("error_info") instanceof JSONNull)) {
info(String.format("Error from Harbormaster: %s", result.getString("error_info")));
failTask();
return false;
} else {
this.result = Result.SUCCESS;
}
return true;
}
use of net.sf.json.JSONNull in project phabricator-jenkins-plugin by uber.
the class SendHarbormasterUriTask method execute.
@Override
protected void execute() {
try {
JSONObject result = diffClient.sendHarbormasterUri(phid, buildUri);
if (result.containsKey("error_info") && !(result.get("error_info") instanceof JSONNull)) {
info(String.format("Harbormaster declined URI artifact: %s", result.getString("error_info")));
this.result = Result.FAILURE;
} else {
this.result = Result.SUCCESS;
}
} catch (ConduitAPIException e) {
e.printStackTrace();
this.result = Result.FAILURE;
} catch (IOException e) {
e.printStackTrace();
this.result = Result.FAILURE;
}
}
use of net.sf.json.JSONNull in project jmeter-plugins-manager by undera.
the class Plugin method fromJSON.
public static Plugin fromJSON(JSONObject elm) {
Plugin inst = new Plugin(elm.getString("id"));
if (!(elm.get("markerClass") instanceof JSONNull)) {
inst.markerClass = elm.getString("markerClass");
}
inst.componentClasses = new ArrayList<>();
if (inst.markerClass != null) {
inst.componentClasses.add(inst.markerClass);
}
if (elm.containsKey("componentClasses")) {
JSONArray componentsJSON = elm.getJSONArray("componentClasses");
if (componentsJSON.size() > 0) {
for (int i = 0; i < componentsJSON.size(); i++) {
inst.componentClasses.add(componentsJSON.getString(i));
}
}
}
if (elm.get("versions") instanceof JSONObject) {
inst.versions = elm.getJSONObject("versions");
}
inst.name = elm.getString("name");
inst.description = elm.getString("description");
if (elm.containsKey("screenshotUrl")) {
inst.screenshot = elm.getString("screenshotUrl");
}
inst.helpLink = elm.getString("helpUrl");
inst.vendor = elm.getString("vendor");
if (elm.containsKey("canUninstall")) {
inst.canUninstall = elm.getBoolean("canUninstall");
}
if (elm.containsKey("installerClass")) {
inst.installerClass = elm.getString("installerClass");
}
return inst;
}
use of net.sf.json.JSONNull in project phabricator-jenkins-plugin by uber.
the class UberallsClient method getParentCoverage.
public CodeCoverageMetrics getParentCoverage(String sha) {
if (sha == null) {
return null;
}
try {
String coverageJSON = getCoverage(sha);
JsonSlurper jsonParser = new JsonSlurper();
JSON responseJSON = jsonParser.parseText(coverageJSON);
if (responseJSON instanceof JSONNull) {
return null;
}
JSONObject coverage = (JSONObject) responseJSON;
return new CodeCoverageMetrics(((Double) coverage.getDouble(PACKAGE_COVERAGE_KEY)).floatValue(), ((Double) coverage.getDouble(FILES_COVERAGE_KEY)).floatValue(), ((Double) coverage.getDouble(CLASSES_COVERAGE_KEY)).floatValue(), ((Double) coverage.getDouble(METHOD_COVERAGE_KEY)).floatValue(), ((Double) coverage.getDouble(LINE_COVERAGE_KEY)).floatValue(), ((Double) coverage.getDouble(CONDITIONAL_COVERAGE_KEY)).floatValue());
} catch (Exception e) {
e.printStackTrace(logger.getStream());
}
return null;
}
use of net.sf.json.JSONNull in project phabricator-jenkins-plugin by uber.
the class PostCommentTask method execute.
/**
* {@inheritDoc}
*/
@Override
protected void execute() {
JSONObject postDifferentialCommentResult = postDifferentialComment(comment, SILENT, commentAction);
if (postDifferentialCommentResult == null || !(postDifferentialCommentResult.get("error_info") instanceof JSONNull)) {
if (postDifferentialCommentResult != null) {
info(String.format("Got error %s with action %s", postDifferentialCommentResult.get("error_info"), commentAction));
}
info("Re-trying with action 'none'");
postDifferentialComment(comment, SILENT, DEFAULT_COMMENT_ACTION);
}
}
Aggregations