@Test public void requestInputControlsShouldNotAllowNullReportUri() throws Exception { mExpectedException.expect(NullPointerException.class); mExpectedException.expectMessage("Report URI should not be null"); restApiUnderTest.requestInputControls(null, null, false); }
@NotNull public List<InputControl> requestInputControls(@NotNull String reportUri, @Nullable Set<String> controlIds, boolean excludeState) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); String ids = ""; if (controlIds != null && !controlIds.isEmpty()) { ids = Utils.joinString(";", controlIds); } HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUri) .addPath("inputControls") .addPath(ids) .build() .resolve(mNetworkClient.getBaseUrl()); if (excludeState) { url = url.newBuilder() .addQueryParameter("exclude", "state") .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(); } InputControlCollection inputControlCollection = mNetworkClient.deserializeJson(response, InputControlCollection.class); return Collections.unmodifiableList(inputControlCollection.get()); }
InputControlRestApi { @NotNull public List<InputControl> requestInputControls(@NotNull String reportUri, @Nullable Set<String> controlIds, boolean excludeState) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); String ids = ""; if (controlIds != null && !controlIds.isEmpty()) { ids = Utils.joinString(";", controlIds); } HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUri) .addPath("inputControls") .addPath(ids) .build() .resolve(mNetworkClient.getBaseUrl()); if (excludeState) { url = url.newBuilder() .addQueryParameter("exclude", "state") .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(); } InputControlCollection inputControlCollection = mNetworkClient.deserializeJson(response, InputControlCollection.class); return Collections.unmodifiableList(inputControlCollection.get()); } }
InputControlRestApi { @NotNull public List<InputControl> requestInputControls(@NotNull String reportUri, @Nullable Set<String> controlIds, boolean excludeState) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); String ids = ""; if (controlIds != null && !controlIds.isEmpty()) { ids = Utils.joinString(";", controlIds); } HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUri) .addPath("inputControls") .addPath(ids) .build() .resolve(mNetworkClient.getBaseUrl()); if (excludeState) { url = url.newBuilder() .addQueryParameter("exclude", "state") .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(); } InputControlCollection inputControlCollection = mNetworkClient.deserializeJson(response, InputControlCollection.class); return Collections.unmodifiableList(inputControlCollection.get()); } InputControlRestApi(NetworkClient networkClient); }
InputControlRestApi { @NotNull public List<InputControl> requestInputControls(@NotNull String reportUri, @Nullable Set<String> controlIds, boolean excludeState) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); String ids = ""; if (controlIds != null && !controlIds.isEmpty()) { ids = Utils.joinString(";", controlIds); } HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUri) .addPath("inputControls") .addPath(ids) .build() .resolve(mNetworkClient.getBaseUrl()); if (excludeState) { url = url.newBuilder() .addQueryParameter("exclude", "state") .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(); } InputControlCollection inputControlCollection = mNetworkClient.deserializeJson(response, InputControlCollection.class); return Collections.unmodifiableList(inputControlCollection.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<InputControl> requestInputControls(@NotNull String reportUri, @Nullable Set<String> controlIds, boolean excludeState) throws IOException, HttpException { Utils.checkNotNull(reportUri, "Report URI should not be null"); String ids = ""; if (controlIds != null && !controlIds.isEmpty()) { ids = Utils.joinString(";", controlIds); } HttpUrl url = new PathResolver.Builder() .addPath("rest_v2") .addPath("reports") .addPaths(reportUri) .addPath("inputControls") .addPath(ids) .build() .resolve(mNetworkClient.getBaseUrl()); if (excludeState) { url = url.newBuilder() .addQueryParameter("exclude", "state") .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(); } InputControlCollection inputControlCollection = mNetworkClient.deserializeJson(response, InputControlCollection.class); return Collections.unmodifiableList(inputControlCollection.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);  }