Search in sources :

Example 36 with TargetData

use of com.google.firebase.firestore.local.TargetData 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)

Example 37 with TargetData

use of com.google.firebase.firestore.local.TargetData in project firebase-android-sdk by firebase.

the class TestUtil method activeLimboQueries.

public static Map<Integer, TargetData> activeLimboQueries(String docKey, Iterable<Integer> targets) {
    Query query = query(docKey);
    Map<Integer, TargetData> listenMap = new HashMap<>();
    for (Integer targetId : targets) {
        TargetData targetData = new TargetData(query.toTarget(), targetId, ARBITRARY_SEQUENCE_NUMBER, QueryPurpose.LIMBO_RESOLUTION);
        listenMap.put(targetId, targetData);
    }
    return listenMap;
}
Also used : TargetData(com.google.firebase.firestore.local.TargetData) StructuredQuery(com.google.firestore.v1.StructuredQuery) Query(com.google.firebase.firestore.core.Query) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 38 with TargetData

use of com.google.firebase.firestore.local.TargetData in project firebase-android-sdk by firebase.

the class TestUtil method activeQueries.

public static Map<Integer, TargetData> activeQueries(Iterable<Integer> targets) {
    Query query = query("foo");
    Map<Integer, TargetData> listenMap = new HashMap<>();
    for (Integer targetId : targets) {
        TargetData targetData = new TargetData(query.toTarget(), targetId, ARBITRARY_SEQUENCE_NUMBER, QueryPurpose.LISTEN);
        listenMap.put(targetId, targetData);
    }
    return listenMap;
}
Also used : TargetData(com.google.firebase.firestore.local.TargetData) StructuredQuery(com.google.firestore.v1.StructuredQuery) Query(com.google.firebase.firestore.core.Query) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

TargetData (com.google.firebase.firestore.local.TargetData)38 Test (org.junit.Test)23 WatchTargetChange (com.google.firebase.firestore.remote.WatchChange.WatchTargetChange)22 MutableDocument (com.google.firebase.firestore.model.MutableDocument)15 DocumentChange (com.google.firebase.firestore.remote.WatchChange.DocumentChange)14 HashMap (java.util.HashMap)8 Query (com.google.firebase.firestore.core.Query)7 StructuredQuery (com.google.firestore.v1.StructuredQuery)6 DocumentKey (com.google.firebase.firestore.model.DocumentKey)5 WatchChangeAggregator (com.google.firebase.firestore.remote.WatchChangeAggregator)4 ByteString (com.google.protobuf.ByteString)4 ImmutableSortedSet (com.google.firebase.database.collection.ImmutableSortedSet)3 Target (com.google.firestore.v1.Target)3 DocumentsTarget (com.google.firestore.v1.Target.DocumentsTarget)3 QueryTarget (com.google.firestore.v1.Target.QueryTarget)3 Map (java.util.Map)3 WatchChange (com.google.firebase.firestore.remote.WatchChange)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 Target (com.google.firebase.firestore.core.Target)1