@Test public void testEventBusIsNotPostedOn500Error() throws Exception { server.start(); server.enqueue( new MockResponse() .setResponseCode(500) .setBody( getStringFromFile( RuntimeEnvironment.application, "incorrect_success_response.json"))); MainActivity.URL = server.url("/").toString(); serviceHelper.setEventBus(eventBus); serviceHelper.getIndividualEpisodeData("Friends", "7"); verifyNoMoreInteractions(eventBus); }
@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()); }
@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())); }