use of org.sonar.wsclient.jsonsimple.JSONObject in project sonarqube by SonarSource.
the class WsCallAndWait method call.
@Nonnull
public RESPONSE call() {
String response = orchestrator.getServer().wsClient().post(targetRelativeUrl);
JSONObject jsonObject = toJsonObject(response);
try {
return parse(jsonObject);
} catch (Exception e) {
throw new IllegalStateException("Failed to parse JSON response", e);
}
}
use of org.sonar.wsclient.jsonsimple.JSONObject in project sonarqube by SonarSource.
the class ScmTest method getScmData.
private Map<Integer, LineData> getScmData(String fileKey) throws ParseException {
Map<Integer, LineData> result = new HashMap<>();
String json = orchestrator.getServer().adminWsClient().get("api/sources/scm", "key", fileKey);
JSONObject obj = (JSONObject) JSONValue.parse(json);
JSONArray array = (JSONArray) obj.get("scm");
for (Object anArray : array) {
JSONArray item = (JSONArray) anArray;
String datetime = (String) item.get(2);
result.put(((Long) item.get(0)).intValue(), new LineData((String) item.get(3), datetime, (String) item.get(1)));
}
return result;
}
use of org.sonar.wsclient.jsonsimple.JSONObject in project sonarqube by SonarSource.
the class WsCallAndWait method toJsonObject.
private JSONObject toJsonObject(String s) {
try {
JSONParser parser = new JSONParser();
Object o = parser.parse(s);
if (o instanceof JSONObject) {
return (JSONObject) o;
}
throw new RuntimeException("Can not parse response from server migration WS (not a JSON object)");
} catch (Exception e) {
throw new IllegalStateException("Invalid JSON: " + s, e);
}
}
Aggregations