urbanairship-core/src/test/java/com/urbanairship/remotedata/RemoteDataTest.java
@Test
    public void testPayloadsForTypesWithMissingTypeInResponse() throws Exception {
        remoteData.init();
        remoteData.dataStore.savePayload(payload);
        remoteData.dataStore.savePayload(otherPayload);

        Assert.assertEquals(remoteData.dataStore.getPayloads().size(), 2);

        runLooperTasks();

        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 the cached payload
        Assert.assertEquals(subscribedPayloads.size(), 1);
        Collection<RemoteDataPayload> collection = subscribedPayloads.get(0);
        Assert.assertEquals(collection, asSet(payload, otherPayload));

        subscribedPayloads.clear();

        RemoteDataPayload freshOtherPayload = new RemoteDataPayload(otherPayload.getType(), otherPayload.getTimestamp() + 10000, otherPayload.getData());

        remoteData.handleRefreshResponse(asSet(freshOtherPayload));
        runLooperTasks();

        // The second callback should have an empty placeholder for the first payload
        Assert.assertEquals(subscribedPayloads.size(), 1);
        collection = subscribedPayloads.get(0);
        Assert.assertEquals(collection, asSet(emptyPayload, freshOtherPayload));
    }
/**
     * Test that a type missing in the response will result in empty model objects in the callback.
     */
Test that a type missing in the response will result in empty model objects in the callback.
Test that a type missing in the response will result in empty model objects in the callback .
@Test
    public void testPayloadsForTypesWithMissingTypeInResponse() throws Exception {
        remoteData.init();
        remoteData.dataStore.savePayload(payload);
        remoteData.dataStore.savePayload(otherPayload);
        Assert.assertEquals(remoteData.dataStore.getPayloads().size(), 2);
        runLooperTasks();
        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, asSet(payload, otherPayload));
        subscribedPayloads.clear();
        RemoteDataPayload freshOtherPayload = new RemoteDataPayload(otherPayload.getType(), otherPayload.getTimestamp() + 10000, otherPayload.getData());
        remoteData.handleRefreshResponse(asSet(freshOtherPayload));
        runLooperTasks();
        Assert.assertEquals(subscribedPayloads.size(), 1);
        collection = subscribedPayloads.get(0);
        Assert.assertEquals(collection, asSet(emptyPayload, freshOtherPayload));
    }
@ Test public void testPayloadsForTypesWithMissingTypeInResponse ( ) throws Exception { remoteData . init ( ) ; remoteData . dataStore . savePayload ( payload ) ; remoteData . dataStore . savePayload ( otherPayload ) ; Assert . assertEquals ( remoteData . dataStore . getPayloads ( ) . size ( ) , 2 ) ; runLooperTasks ( ) ; 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 , asSet ( payload , otherPayload ) ) ; subscribedPayloads . clear ( ) ; RemoteDataPayload freshOtherPayload = new RemoteDataPayload ( otherPayload . getType ( ) , otherPayload . getTimestamp ( ) + 10000 , otherPayload . getData ( ) ) ; remoteData . handleRefreshResponse ( asSet ( freshOtherPayload ) ) ; runLooperTasks ( ) ; Assert . assertEquals ( subscribedPayloads . size ( ) , 1 ) ; collection = subscribedPayloads . get ( 0 ) ; Assert . assertEquals ( collection , asSet ( emptyPayload , freshOtherPayload ) ) ; }
Test that a type missing in the response will result in empty model objects in the callback.
Test that a type missing in the response will result in empty model objects in the callback .
// The first callback should be the cached payload // The second callback should have an empty placeholder for the first payload