@Test public void returnsErrorIfServerHasAnInternalError() throws Exception { enqueueMockResponse(SERVER_ERROR_CODE); Reports reports = givenSomeReports(); ApiClientResult result = reportApiClient.sendReports(reports); assertFalse(result.isSuccess()); }
public ApiClientResult sendReports(Reports reports) { Request request = generateReportRequest(reports); Response response = null; try { response = httpClient.newCall(request).execute(); if (response.isSuccessful()) { response.close(); return new ApiClientResult(reports); } } catch (IOException e) { return new ApiClientResult(ApiClientResult.Error.NETWORK_ERROR); } ApiClientResult.Error error = mapError(response); return new ApiClientResult(error); }
ReportApiClient extends ApiClient { public ApiClientResult sendReports(Reports reports) { Request request = generateReportRequest(reports); Response response = null; try { response = httpClient.newCall(request).execute(); if (response.isSuccessful()) { response.close(); return new ApiClientResult(reports); } } catch (IOException e) { return new ApiClientResult(ApiClientResult.Error.NETWORK_ERROR); } ApiClientResult.Error error = mapError(response); return new ApiClientResult(error); } }
ReportApiClient extends ApiClient { public ApiClientResult sendReports(Reports reports) { Request request = generateReportRequest(reports); Response response = null; try { response = httpClient.newCall(request).execute(); if (response.isSuccessful()) { response.close(); return new ApiClientResult(reports); } } catch (IOException e) { return new ApiClientResult(ApiClientResult.Error.NETWORK_ERROR); } ApiClientResult.Error error = mapError(response); return new ApiClientResult(error); } ReportApiClient(String apiKey, Device device, String scheme, String host, int port,
      boolean debugEnabled);  ReportApiClient(String apiKey, Device device, String scheme, String host, int port,
      boolean forceReportsEnabled, boolean useGzip); }
ReportApiClient extends ApiClient { public ApiClientResult sendReports(Reports reports) { Request request = generateReportRequest(reports); Response response = null; try { response = httpClient.newCall(request).execute(); if (response.isSuccessful()) { response.close(); return new ApiClientResult(reports); } } catch (IOException e) { return new ApiClientResult(ApiClientResult.Error.NETWORK_ERROR); } ApiClientResult.Error error = mapError(response); return new ApiClientResult(error); } ReportApiClient(String apiKey, Device device, String scheme, String host, int port,
      boolean debugEnabled);  ReportApiClient(String apiKey, Device device, String scheme, String host, int port,
      boolean forceReportsEnabled, boolean useGzip); ApiClientResult sendReports(Reports reports); }
ReportApiClient extends ApiClient { public ApiClientResult sendReports(Reports reports) { Request request = generateReportRequest(reports); Response response = null; try { response = httpClient.newCall(request).execute(); if (response.isSuccessful()) { response.close(); return new ApiClientResult(reports); } } catch (IOException e) { return new ApiClientResult(ApiClientResult.Error.NETWORK_ERROR); } ApiClientResult.Error error = mapError(response); return new ApiClientResult(error); } ReportApiClient(String apiKey, Device device, String scheme, String host, int port,
      boolean debugEnabled);  ReportApiClient(String apiKey, Device device, String scheme, String host, int port,
      boolean forceReportsEnabled, boolean useGzip); ApiClientResult sendReports(Reports reports);  }