コード例 #1
0
 @Test
 public void testEventBusIsPostedWithNoDataOnServiceCallWithAnIncorrectResponse()
     throws Exception {
   server.start();
   server.enqueue(
       new MockResponse()
           .setResponseCode(200)
           .setBody(
               getStringFromFile(
                   RuntimeEnvironment.application, "incorrect_success_response.json")));
   MainActivity.URL = server.url("/").toString();
   serviceHelper.setEventBus(eventBus);
   serviceHelper.getIndividualEpisodeData("Friends", "7");
   verify(eventBus).post(anyObject());
   verify(eventBus).post(captor.capture());
   IndividualEpisodeResponseEvent episodeLists =
       (IndividualEpisodeResponseEvent) captor.getValue();
   assertNull(episodeLists.getEpisodesList());
 }
コード例 #2
0
 @Test
 public void testEventBusIsPostedOnSuccessfulServiceCall() throws Exception {
   server.start();
   server.enqueue(
       new MockResponse()
           .setResponseCode(200)
           .setBody(
               getStringFromFile(RuntimeEnvironment.application, "episodes_list_success.json")));
   MainActivity.URL = server.url("/").toString();
   serviceHelper.setEventBus(eventBus);
   serviceHelper.getIndividualEpisodeData("Friends", "7");
   verify(eventBus).post(anyObject());
   verify(eventBus).post(captor.capture());
   IndividualEpisodeResponseEvent episodeLists =
       (IndividualEpisodeResponseEvent) captor.getValue();
   assertThat(
       "The One Where I am testing something",
       equalTo(episodeLists.getEpisodesList().get(0).getTitle()));
 }