### Question:
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);  }### Answer:
@Test public void requestInputControlsInitialStatesShouldThrowRestErrorFor500() throws Exception { mExpectedException.expect(HttpException.class); mWebMockRule.enqueue(MockResponseFactory.create500()); restApiUnderTest.requestInputControlsInitialStates("any_id", true); }
@Test public void apiShouldProvideListOfInputControlsInitialStatesWithFreshData() throws Exception { MockResponse mockResponse = MockResponseFactory.create200() .setBody(icsStates.asString()); mWebMockRule.enqueue(mockResponse); Collection<InputControlState> states = restApiUnderTest.requestInputControlsInitialStates("/my/uri", true); assertThat(states, is(not(empty()))); RecordedRequest request = mWebMockRule.get().takeRequest(); assertThat(request, containsHeader("Accept", "application/json; charset=UTF-8")); assertThat(request, hasPath("/rest_v2/reports/my/uri/inputControls/values?freshData=true")); assertThat(request, wasMethod("GET")); }
@Test public void list_input_control_initial_states_returns_empty_collection_on_204() throws Exception { mWebMockRule.enqueue(MockResponseFactory.create204()); List<InputControlState> expected = restApiUnderTest.requestInputControlsInitialStates("/my/uri", false); assertThat(expected, Matchers.is(Matchers.empty())); }