@Test
public void bufferWithBOEmptyLastViaSource() {

    PublishSubject<Integer> source = PublishSubject.create();
    PublishSubject<Integer> boundary = PublishSubject.create();
    @SuppressWarnings("unchecked")
    Observer<Object> o = mock(Observer.class);
    InOrder inOrder = Mockito.inOrder(o);
    source.buffer(boundary).subscribe(o);
    source.onCompleted();
    inOrder.verify(o, times(1)).onNext(Arrays.asList());
    inOrder.verify(o).onCompleted();
    verify(o, never()).onError(any(Throwable.class));
}