baku-toolkit/lib/src/test/java/io/v/baku/toolkit/blessings/BlessingsManagerBlessingsProviderTest.java
/**
     * Verifies that if a new subscriber needs to seek blessings, the new subscriber does not
     * receive blessings until the seek completes (does not receive old blessings), and that the old
     * subscriber is refreshed as well.
     */
Verifies that if a new subscriber needs to seek blessings, the new subscriber does not
receive blessings until the seek completes (does not receive old blessings), and that the old
subscriber is refreshed as well.
Verifies that if a new subscriber needs to seek blessings the new subscriber does not receive blessings until the seek completes ( does not receive old blessings ) and that the old subscriber is refreshed as well .
@SuppressWarnings("unchecked")
    @Test
    public void testDeferOnNewSubscriber() throws Exception {
        final Action1<Blessings>
                s1 = mock(Action1.class),
                s2 = mock(Action1.class);
        final Blessings
                b1 = PowerMockito.mock(Blessings.class),
                b2 = PowerMockito.mock(Blessings.class);
        final SettableFuture<Blessings>
                bf1 = SettableFuture.create(),
                bf2 = SettableFuture.create();
        when(BlessingsManager.getBlessings(any(), any(), any(), anyBoolean()))
                .thenReturn(bf1, bf2);
        final RefreshableBlessingsProvider t = new BlessingsManagerBlessingsProvider(null, null);
        t.getRxBlessings().subscribe(s1);
        bf1.set(b1);
        t.getRxBlessings().subscribe(s2);
        verify(s2, never()).call(any());
        bf2.set(b2);
        verify(s1).call(b2);
        verify(s2).call(b2);
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testDeferOnNewSubscriber ( ) throws Exception { final Action1 < Blessings > s1 = mock ( Action1 . class ) , s2 = mock ( Action1 . class ) ; final Blessings b1 = PowerMockito . mock ( Blessings . class ) , b2 = PowerMockito . mock ( Blessings . class ) ; final SettableFuture < Blessings > bf1 = SettableFuture . create ( ) , bf2 = SettableFuture . create ( ) ; when ( BlessingsManager . getBlessings ( any ( ) , any ( ) , any ( ) , anyBoolean ( ) ) ) . thenReturn ( bf1 , bf2 ) ; final RefreshableBlessingsProvider t = new BlessingsManagerBlessingsProvider ( null , null ) ; t . getRxBlessings ( ) . subscribe ( s1 ) ; bf1 . set ( b1 ) ; t . getRxBlessings ( ) . subscribe ( s2 ) ; verify ( s2 , never ( ) ) . call ( any ( ) ) ; bf2 . set ( b2 ) ; verify ( s1 ) . call ( b2 ) ; verify ( s2 ) . call ( b2 ) ; }
Verifies that if a new subscriber needs to seek blessings, the new subscriber does not
 receive blessings until the seek completes (does not receive old blessings), and that the old
 subscriber is refreshed as well.
Verifies that if a new subscriber needs to seek blessings the new subscriber does not receive blessings until the seek completes ( does not receive old blessings ) and that the old subscriber is refreshed as well .