ListDirectoryObservable extends ListFileObservable { public Observable<File> create(final File rootDirectory) { return super.create(rootDirectory) .filter(isDirectory()); }  Observable<File> create(final File rootDirectory);  }
@Test public void observableShouldReturnOnlyChildDirectories() throws Exception { File stubRootDirectory = mock(File.class); File childDirectory1 = createStubDirectory(); File childFile1 = createStubFile(); File childDirectory2 = createStubDirectory(); File childrenContent[] = {childDirectory1, childFile1, childDirectory2}; when(stubRootDirectory.listFiles()).thenReturn(childrenContent); sut.create(stubRootDirectory) .subscribeOn(Schedulers.trampoline()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(mockObserver); verify(mockObserver).onNext(childDirectory1); verify(mockObserver).onNext(childDirectory2); verify(mockObserver, times(2)).onNext(any(File.class)); verify(mockObserver, never()).onNext(childFile1); verify(mockObserver).onComplete(); }