Search in sources :

Example 16 with DocumentChange

use of com.google.firebase.firestore.remote.WatchChange.DocumentChange in project firebase-android-sdk by firebase.

the class TestUtil method updateRemoteEvent.

public static RemoteEvent updateRemoteEvent(MutableDocument doc, List<Integer> updatedInTargets, List<Integer> removedFromTargets, List<Integer> activeTargets) {
    DocumentChange change = new DocumentChange(updatedInTargets, removedFromTargets, doc.getKey(), doc);
    WatchChangeAggregator aggregator = new WatchChangeAggregator(new WatchChangeAggregator.TargetMetadataProvider() {

        @Override
        public ImmutableSortedSet<DocumentKey> getRemoteKeysForTarget(int targetId) {
            return DocumentKey.emptyKeySet().insert(doc.getKey());
        }

        @Override
        public TargetData getTargetDataForTarget(int targetId) {
            return activeTargets.contains(targetId) ? targetData(targetId, QueryPurpose.LISTEN, doc.getKey().toString()) : null;
        }
    });
    aggregator.handleDocumentChange(change);
    return aggregator.createRemoteEvent(doc.getVersion());
}
Also used : TargetData(com.google.firebase.firestore.local.TargetData) WatchChangeAggregator(com.google.firebase.firestore.remote.WatchChangeAggregator) ImmutableSortedSet(com.google.firebase.database.collection.ImmutableSortedSet) DocumentChange(com.google.firebase.firestore.remote.WatchChange.DocumentChange)

Aggregations

DocumentChange (com.google.firebase.firestore.remote.WatchChange.DocumentChange)16 TargetData (com.google.firebase.firestore.local.TargetData)14 MutableDocument (com.google.firebase.firestore.model.MutableDocument)13 WatchTargetChange (com.google.firebase.firestore.remote.WatchChange.WatchTargetChange)13 Test (org.junit.Test)11 HashMap (java.util.HashMap)5 ImmutableSortedSet (com.google.firebase.database.collection.ImmutableSortedSet)2 SnapshotVersion (com.google.firebase.firestore.model.SnapshotVersion)2 ExistenceFilterWatchChange (com.google.firebase.firestore.remote.WatchChange.ExistenceFilterWatchChange)2 WatchChangeAggregator (com.google.firebase.firestore.remote.WatchChangeAggregator)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 DocumentKey (com.google.firebase.firestore.model.DocumentKey)1 ResourcePath (com.google.firebase.firestore.model.ResourcePath)1 WatchChange (com.google.firebase.firestore.remote.WatchChange)1 ByteString (com.google.protobuf.ByteString)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1