public void processResponse()

in commit-status-publisher-server/src/main/java/jetbrains/buildServer/swarm/SwarmClient.java [451:515]


    public void processResponse(HttpHelper.HttpResponse response) throws HttpPublisherException, IOException {
      if (response.getStatusCode() >= 400) {
        if (response.getStatusCode() == 401 || response.getStatusCode() == 403) {
          throw new HttpPublisherException(response.getStatusCode(), response.getStatusText(),
                                           "Cannot access Perforce Swarm Server at '" + mySwarmUrl + "' to add details for " + myDebugInfo);
        }
        throw new HttpPublisherException(response.getStatusCode(), response.getStatusText(), "Cannot get the list of review testruns for " + myDebugInfo);
      }

      /*
      {
  "error": null,
  "messages": [],
  "data" : {
    "testruns" : [
      {
        "id": 706,
        "change": 12345,
        "version": 2,
        "test": "global1",
        "startTime": 1567895432,
        "completedTime": 1567895562,
        "status": "pass",
        "messages": [
          "Test completed successfully",
          "another message"
        ],
        "url": "http://my.jenkins.com/projectx/main/1224"
        "uuid": "FAE4501C-E4BC-73E4-A11A-FF710601BC3F"
      },
      {
        <ids for other testruns of the review, formatted as above>
      }
    ]
  }
}
       */

      debug("Test runs response for " + myDebugInfo + " = " + response.getContent() + " " + response.getStatusCode() + " " + response.getStatusText());

      try {
        final JsonNode jsonNode = new ObjectMapper().readTree(response.getContent());
        final JsonNode dataNode = jsonNode.get("data");
        if (dataNode == null) {
          return;
        }

        final ArrayNode testruns = (ArrayNode)dataNode.get("testruns");

        if (testruns != null) {
          for (Iterator<JsonNode> it = testruns.elements(); it.hasNext(); ) {
            JsonNode element = it.next();
            // Collect test runs whose test name match external build configuration ID and which are not completed
            fillTestRunUsingAttr(element, "test");
            fillTestRunUsingAttr(element, "title");
          }
        }
        if (mySwarmRuns.size() > 0) {
          info(String.format("Found Perforce Swarm testruns %s for %s", mySwarmRuns, myDebugInfo));
        }

      } catch (JsonProcessingException e) {
        throw new HttpPublisherException("Error parsing JSON response from Perforce Swarm: " + e.getMessage(), e);
      }
    }