Postman { public void listCharacters(Context context, String query, int limit, int offset) { this.mRequestService.setUrl(mRequestUtil.buildBasicUrl(context, context.getString(R.string.MARVEL_SERVICE_LIST_CHARACTERS), query, limit, offset)); this.mRequestService.setBody(EventCatalog.e0000, Request.Method.GET); this.mRequestService.execute(context); } Postman(); void listCharacters(Context context, String query, int limit, int offset); void listComicDetails(String resourceURI, Context context); void cancelRequests(); static final String TAG; }
@Test public void testListCharacters() { String query = "query"; String MARVEL_SERVICE_LIST_CHARACTERS = "service"; String URL = ""; int limit = 0; int offset = 0; Context context = Mockito.mock(Context.class); Mockito.doCallRealMethod().when(postman).listCharacters(context, query, limit, offset); Mockito.when(context.getString(R.string.MARVEL_SERVICE_LIST_CHARACTERS)).thenReturn(MARVEL_SERVICE_LIST_CHARACTERS); Mockito.when(mRequestUtil.buildBasicUrl(context, MARVEL_SERVICE_LIST_CHARACTERS, query, limit, offset)).thenReturn(URL); postman.listCharacters(context, query, limit, offset); Mockito.verify(mRequestService).setBody(EventCatalog.e0000, Request.Method.GET); Mockito.verify(mRequestService).execute(context); }