@Test public void requestInputControlsInitialStatesShouldThrowRestErrorFor500() throws Exception { mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); restApiUnderTest.requestInputControlsInitialStates("any_id", true); }
@NotNull public List<InputControlState> requestInputControlsInitialStates(@NotNull String reportUri, boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUri) .addPath("inputControls") .addPath("values") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("freshData", String.valueOf(freshData)) .build(); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .get() .url(url) .build(); Response response = mNetworkClient.makeCall(request); if (response.code() == 204) { return Collections.emptyList(); } InputControlStateCollection inputControlStateCollection = mNetworkClient.deserializeJson(response, InputControlStateCollection.class); return Collections.unmodifiableList(inputControlStateCollection.get()); }
InputControlRestApi { @NotNull public List<InputControlState> requestInputControlsInitialStates(@NotNull String reportUri, boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUri) .addPath("inputControls") .addPath("values") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("freshData", String.valueOf(freshData)) .build(); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .get() .url(url) .build(); Response response = mNetworkClient.makeCall(request); if (response.code() == 204) { return Collections.emptyList(); } InputControlStateCollection inputControlStateCollection = mNetworkClient.deserializeJson(response, InputControlStateCollection.class); return Collections.unmodifiableList(inputControlStateCollection.get()); } }
InputControlRestApi { @NotNull public List<InputControlState> requestInputControlsInitialStates(@NotNull String reportUri, boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUri) .addPath("inputControls") .addPath("values") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("freshData", String.valueOf(freshData)) .build(); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .get() .url(url) .build(); Response response = mNetworkClient.makeCall(request); if (response.code() == 204) { return Collections.emptyList(); } InputControlStateCollection inputControlStateCollection = mNetworkClient.deserializeJson(response, InputControlStateCollection.class); return Collections.unmodifiableList(inputControlStateCollection.get()); } InputControlRestApi(NetworkClient networkClient); }
InputControlRestApi { @NotNull public List<InputControlState> requestInputControlsInitialStates(@NotNull String reportUri, boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUri) .addPath("inputControls") .addPath("values") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("freshData", String.valueOf(freshData)) .build(); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .get() .url(url) .build(); Response response = mNetworkClient.makeCall(request); if (response.code() == 204) { return Collections.emptyList(); } InputControlStateCollection inputControlStateCollection = mNetworkClient.deserializeJson(response, InputControlStateCollection.class); return Collections.unmodifiableList(inputControlStateCollection.get()); } InputControlRestApi(NetworkClient networkClient); @NotNull List<InputControl> requestInputControls(@NotNull String reportUri,
                                                   @Nullable Set<String> controlIds,
                                                   boolean excludeState); @NotNull List<InputControlState> requestInputControlsInitialStates(@NotNull String reportUri,
                                                                     boolean freshData); @NotNull List<InputControlState> requestInputControlsStates(@NotNull String reportUri,
                                                              @NotNull List<ReportParameter> parameters,
                                                              boolean freshData); }
InputControlRestApi { @NotNull public List<InputControlState> requestInputControlsInitialStates(@NotNull String reportUri, boolean freshData) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUri) .addPath("inputControls") .addPath("values") .build() .resolve(mNetworkClient.getBaseUrl()) .newBuilder() .addQueryParameter("freshData", String.valueOf(freshData)) .build(); Request request = new Request.Builder() .addHeader("Accept", "application/json; charset=UTF-8") .get() .url(url) .build(); Response response = mNetworkClient.makeCall(request); if (response.code() == 204) { return Collections.emptyList(); } InputControlStateCollection inputControlStateCollection = mNetworkClient.deserializeJson(response, InputControlStateCollection.class); return Collections.unmodifiableList(inputControlStateCollection.get()); } InputControlRestApi(NetworkClient networkClient); @NotNull List<InputControl> requestInputControls(@NotNull String reportUri,
                                                   @Nullable Set<String> controlIds,
                                                   boolean excludeState); @NotNull List<InputControlState> requestInputControlsInitialStates(@NotNull String reportUri,
                                                                     boolean freshData); @NotNull List<InputControlState> requestInputControlsStates(@NotNull String reportUri,
                                                              @NotNull List<ReportParameter> parameters,
                                                              boolean freshData);  }