    @Test
    public void testShouldSchedulePostsLoadFromAPIOnBackgroundThread() {


        //create mocks
        Observable<List<Post>> postsObservable = (Observable<List<Post>>) mock(Observable.class);

        //define return values
        when(postsPresenter.postsAPI.getPostsObservable()).thenReturn(postsObservable);
        when(postsObservable.subscribeOn(Schedulers.io())).thenReturn(postsObservable);
        when(postsObservable.observeOn(AndroidSchedulers.mainThread())).thenReturn(postsObservable);

        //call test method
        postsPresenter.loadPostsFromAPI();

        //verify if all methods in the chain are called with correct arguments
        verify(postsPresenter.postsAPI).getPostsObservable();
        verify(postsObservable).subscribeOn(Schedulers.io());
        verify(postsObservable).observeOn(AndroidSchedulers.mainThread());
        verify(postsObservable).subscribe(Matchers.<Subscriber<List<Post>>>any());
    }