Search in sources :

Example 1 with JSONArray

use of org.sonar.wsclient.jsonsimple.JSONArray 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;
}
Also used : JSONObject(org.sonar.wsclient.jsonsimple.JSONObject) HashMap(java.util.HashMap) JSONArray(org.sonar.wsclient.jsonsimple.JSONArray) JSONObject(org.sonar.wsclient.jsonsimple.JSONObject)

Aggregations

HashMap (java.util.HashMap)1 JSONArray (org.sonar.wsclient.jsonsimple.JSONArray)1 JSONObject (org.sonar.wsclient.jsonsimple.JSONObject)1