@Test
public void bufferWithBONormal1() {

    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.onNext(1);
    source.onNext(2);
    source.onNext(3);
    boundary.onNext(1);
    inOrder.verify(o, times(1)).onNext(Arrays.asList(1, 2, 3));
    source.onNext(4);
    source.onNext(5);
    boundary.onNext(2);
    inOrder.verify(o, times(1)).onNext(Arrays.asList(4, 5));
    source.onNext(6);
    boundary.onCompleted();
    inOrder.verify(o, times(1)).onNext(Arrays.asList(6));
    inOrder.verify(o).onCompleted();
    verify(o, never()).onError(any(Throwable.class));
}