EnquiryHttpDao { public Enquiry get(String url) throws JSONException, IOException, HttpException { final FluentResponse fluentResponse = http() .context(RapidFtrApplication.getApplicationInstance()) .host(url) .get() .ensureSuccess(); String enquiryJSON = CharStreams.toString(new InputStreamReader(fluentResponse.getEntity().getContent())); return new Enquiry(enquiryJSON); } @Inject  EnquiryHttpDao();  EnquiryHttpDao(String apiRoot); Enquiry get(String url); Enquiry update(Enquiry enquiry); List<String> getIdsOfUpdated(DateTime lastUpdate); Enquiry create(Enquiry enquiry); static final String ENQUIRIES_API_PATH; }
@Test public void getEnquiryShouldRetrieveEnquiryFromApi() throws Exception { EnquiryHttpDao enquiryHttpDao = new EnquiryHttpDao(apiRoot); String url = "http: Robolectric.getFakeHttpLayer().setDefaultHttpResponse(200, "{\"id\":\"123\"}"); Enquiry enquiry = enquiryHttpDao.get(url); assertThat(enquiry.getString("id"), is("123")); final RequestLine requestLine = Robolectric.getSentHttpRequest(0).getRequestLine(); assertThat(requestLine.getUri(), is(url + "/")); assertThat(requestLine.getMethod(), is("GET")); }