OpenRosaFormListApi implements FormListApi { @Override public InputStream fetchForm(String formURL) throws FormApiException { return fetchFile(formURL); } OpenRosaFormListApi(String serverURL, String formListPath, OpenRosaHttpInterface openRosaHttpInterface, WebCredentialsUtils webCredentialsUtils); @Deprecated  OpenRosaFormListApi(OpenRosaXmlFetcher openRosaXmlFetcher); @Override List<FormListItem> fetchFormList(); @Override ManifestFile fetchManifest(String manifestURL); @Override InputStream fetchForm(String formURL); @Override InputStream fetchMediaFile(String mediaFileURL); @Override void updateUrl(String url); @Override void updateWebCredentialsUtils(WebCredentialsUtils webCredentialsUtils);  }
@Test public void fetchForm_whenThereIsAServerError_throwsFetchErrorFormApiException() throws Exception { OpenRosaHttpInterface httpInterface = mock(OpenRosaHttpInterface.class); WebCredentialsUtils webCredentialsUtils = mock(WebCredentialsUtils.class); OpenRosaFormListApi formListApi = new OpenRosaFormListApi("http: try { when(httpInterface.executeGetRequest(any(), any(), any())).thenReturn(new HttpGetResult(null, new HashMap<>(), "hash", 500)); formListApi.fetchForm("http: fail("No exception thrown!"); } catch (FormApiException e) { assertThat(e.getType(), is(FETCH_ERROR)); } }