### Question:
DicomWebClient implements IDicomWebClient { public JSONArray qidoRs(String path) throws IDicomWebClient.DicomWebException { try { HttpRequest httpRequest = requestFactory.buildGetRequest(new GenericUrl(serviceUrlPrefix + "/" + StringUtil.trim(path))); HttpResponse httpResponse = httpRequest.execute(); if (httpResponse.getStatusCode() == HttpStatusCodes.STATUS_CODE_NO_CONTENT) { return new JSONArray(); } return new JSONArray( CharStreams .toString(new InputStreamReader(httpResponse.getContent(), StandardCharsets.UTF_8))); } catch (HttpResponseException e) { throw new DicomWebException( String.format("QidoRs: %d, %s", e.getStatusCode(), e.getStatusMessage()), e, e.getStatusCode(), Status.UnableToCalculateNumberOfMatches); } catch (IOException | IllegalArgumentException e) { throw new IDicomWebClient.DicomWebException(e); } } @Inject  DicomWebClient(
      HttpRequestFactory requestFactory,
      @Annotations.DicomwebAddr String serviceUrlPrefix,
      String stowPath); InputStream wadoRs(String path); JSONArray qidoRs(String path); void stowRs(InputStream in);  }### Answer:
@Test public void testDicomWebClient_Qido() throws Exception { String qidoResponse = "[{\"0020000E\":{\"vr\":\"UI\",\"Value\":[\"1.2.840.113619.2.176.3596.3364818.7819.1259708454.108\"]}}]"; fakeDicomWebServer.addJsonResponse(qidoResponse); JSONArray jsonArray = client.qidoRs("query"); assertThat(jsonArray.length()).isEqualTo(1); JSONObject tag = jsonArray.getJSONObject(0).getJSONObject("0020000E"); JSONArray tagArray = tag.getJSONArray("Value"); assertThat(tagArray.length()).isEqualTo(1); String tagValue = tagArray.getString(0); assertThat(tagValue).isEqualTo("1.2.840.113619.2.176.3596.3364818.7819.1259708454.108"); }
@Test public void testDicomWebClient_QidoError() throws Exception { fakeDicomWebServer.addResponseWithStatusCode(404); assertThrows(IDicomWebClient.DicomWebException.class, () -> client.qidoRs("query")); }
@Test public void testDicomWebClient_NothingInjected() throws Exception { assertThrows(IDicomWebClient.DicomWebException.class, () -> client.qidoRs("query")); }