OpenRosaFormListApi implements FormListApi { @Override public ManifestFile fetchManifest(String manifestURL) throws FormApiException { if (manifestURL == null) { return null; } DocumentFetchResult result = mapException(() -> openRosaXMLFetcher.getXML(manifestURL)); if (result.errorMessage != null) { throw new FormApiException(FETCH_ERROR); } if (!result.isOpenRosaResponse) { throw new FormApiException(FETCH_ERROR); } return parseManifest(result); } 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 fetchManifest_whenThereIsAnUnknownHostException_throwsUnreachableFormApiException() throws Exception { OpenRosaHttpInterface httpInterface = mock(OpenRosaHttpInterface.class); WebCredentialsUtils webCredentialsUtils = mock(WebCredentialsUtils.class); OpenRosaFormListApi formListApi = new OpenRosaFormListApi("http: try { when(httpInterface.executeGetRequest(any(), any(), any())).thenThrow(UnknownHostException.class); formListApi.fetchManifest("http: fail("No exception thrown!"); } catch (FormApiException e) { assertThat(e.getType(), is(UNREACHABLE)); assertThat(e.getServerUrl(), is("http: } }