urbanairship-core/src/test/java/com/urbanairship/remotedata/RemoteDataTest.java
@Test
    public void testPayloadsForTypesWithEmptyCache() {
        remoteData.init();
        final List<Collection<RemoteDataPayload>> subscribedPayloads = new ArrayList<>();

        Observable<Collection<RemoteDataPayload>> payloadsObservable = remoteData.payloadsForTypes(Arrays.asList("type", "otherType"));

        payloadsObservable.subscribe(new Subscriber<Collection<RemoteDataPayload>>(){
            @Override
            public void onNext(Collection<RemoteDataPayload> value) {
                subscribedPayloads.add(value);
            }
        });

        runLooperTasks();

        // The first callback should be an empty placeholder
        Assert.assertEquals(subscribedPayloads.size(), 1);
        Collection<RemoteDataPayload> collection = subscribedPayloads.get(0);
        Assert.assertEquals(collection.size(), 2);

        for (RemoteDataPayload payload : collection) {
            Assert.assertEquals(payload.getTimestamp(), 0);
        }

        subscribedPayloads.clear();

        remoteData.handleRefreshResponse(asSet(payload, otherPayload));
        runLooperTasks();

        // The second callback should be the refreshed data
        Assert.assertEquals(subscribedPayloads.size(), 1);
        collection = subscribedPayloads.get(0);
        Assert.assertEquals(collection.size(), 2);
        Assert.assertEquals(collection, asSet(payload, otherPayload));
    }
/**
     * Test that an empty cache will result in empty model objects in the initial callback.
     */
Test that an empty cache will result in empty model objects in the initial callback.
Test that an empty cache will result in empty model objects in the initial callback .
@Test
    public void testPayloadsForTypesWithEmptyCache() {
        remoteData.init();
        final List<Collection<RemoteDataPayload>> subscribedPayloads = new ArrayList<>();
        Observable<Collection<RemoteDataPayload>> payloadsObservable = remoteData.payloadsForTypes(Arrays.asList("type", "otherType"));
        payloadsObservable.subscribe(new Subscriber<Collection<RemoteDataPayload>>(){
            @Override
            public void onNext(Collection<RemoteDataPayload> value) {
                subscribedPayloads.add(value);
            }
        });
        runLooperTasks();
        Assert.assertEquals(subscribedPayloads.size(), 1);
        Collection<RemoteDataPayload> collection = subscribedPayloads.get(0);
        Assert.assertEquals(collection.size(), 2);
        for (RemoteDataPayload payload : collection) {
            Assert.assertEquals(payload.getTimestamp(), 0);
        }
        subscribedPayloads.clear();
        remoteData.handleRefreshResponse(asSet(payload, otherPayload));
        runLooperTasks();
        Assert.assertEquals(subscribedPayloads.size(), 1);
        collection = subscribedPayloads.get(0);
        Assert.assertEquals(collection.size(), 2);
        Assert.assertEquals(collection, asSet(payload, otherPayload));
    }
@ Test public void testPayloadsForTypesWithEmptyCache ( ) { remoteData . init ( ) ; final List < Collection < RemoteDataPayload > > subscribedPayloads = new ArrayList < > ( ) ; Observable < Collection < RemoteDataPayload > > payloadsObservable = remoteData . payloadsForTypes ( Arrays . asList ( "type" , "otherType" ) ) ; payloadsObservable . subscribe ( new Subscriber < Collection < RemoteDataPayload > > ( ) { @ Override public void onNext ( Collection < RemoteDataPayload > value ) { subscribedPayloads . add ( value ) ; } } ) ; runLooperTasks ( ) ; Assert . assertEquals ( subscribedPayloads . size ( ) , 1 ) ; Collection < RemoteDataPayload > collection = subscribedPayloads . get ( 0 ) ; Assert . assertEquals ( collection . size ( ) , 2 ) ; for ( RemoteDataPayload payload : collection ) { Assert . assertEquals ( payload . getTimestamp ( ) , 0 ) ; } subscribedPayloads . clear ( ) ; remoteData . handleRefreshResponse ( asSet ( payload , otherPayload ) ) ; runLooperTasks ( ) ; Assert . assertEquals ( subscribedPayloads . size ( ) , 1 ) ; collection = subscribedPayloads . get ( 0 ) ; Assert . assertEquals ( collection . size ( ) , 2 ) ; Assert . assertEquals ( collection , asSet ( payload , otherPayload ) ) ; }
Test that an empty cache will result in empty model objects in the initial callback.
Test that an empty cache will result in empty model objects in the initial callback .
// The first callback should be an empty placeholder // The second callback should be the refreshed data