use of com.google.firebase.firestore.remote.WatchChangeAggregator in project firebase-android-sdk by firebase.
the class TestUtil method existenceFilterEvent.
public static RemoteEvent existenceFilterEvent(int targetId, ImmutableSortedSet<DocumentKey> syncedKeys, int remoteCount, int version) {
TargetData targetData = TestUtil.targetData(targetId, QueryPurpose.LISTEN, "foo");
TestTargetMetadataProvider testTargetMetadataProvider = new TestTargetMetadataProvider();
testTargetMetadataProvider.setSyncedKeys(targetData, syncedKeys);
ExistenceFilter existenceFilter = new ExistenceFilter(remoteCount);
WatchChangeAggregator aggregator = new WatchChangeAggregator(testTargetMetadataProvider);
WatchChange.ExistenceFilterWatchChange existenceFilterWatchChange = new WatchChange.ExistenceFilterWatchChange(targetId, existenceFilter);
aggregator.handleExistenceFilter(existenceFilterWatchChange);
return aggregator.createRemoteEvent(version(version));
}
use of com.google.firebase.firestore.remote.WatchChangeAggregator in project firebase-android-sdk by firebase.
the class TestUtil method addedRemoteEvent.
public static RemoteEvent addedRemoteEvent(List<MutableDocument> docs, List<Integer> updatedInTargets, List<Integer> removedFromTargets) {
Preconditions.checkArgument(!docs.isEmpty(), "Cannot pass empty docs array");
WatchChangeAggregator aggregator = new WatchChangeAggregator(new WatchChangeAggregator.TargetMetadataProvider() {
@Override
public ImmutableSortedSet<DocumentKey> getRemoteKeysForTarget(int targetId) {
return DocumentKey.emptyKeySet();
}
@Override
public TargetData getTargetDataForTarget(int targetId) {
ResourcePath collectionPath = docs.get(0).getKey().getCollectionPath();
return targetData(targetId, QueryPurpose.LISTEN, collectionPath.toString());
}
});
SnapshotVersion version = SnapshotVersion.NONE;
for (MutableDocument doc : docs) {
DocumentChange change = new DocumentChange(updatedInTargets, removedFromTargets, doc.getKey(), doc);
aggregator.handleDocumentChange(change);
version = doc.getVersion().compareTo(version) > 0 ? doc.getVersion() : version;
}
return aggregator.createRemoteEvent(version);
}
use of com.google.firebase.firestore.remote.WatchChangeAggregator in project firebase-android-sdk by firebase.
the class TestUtil method noChangeEvent.
public static RemoteEvent noChangeEvent(int targetId, int version, ByteString resumeToken) {
TargetData targetData = TestUtil.targetData(targetId, QueryPurpose.LISTEN, "foo/bar");
TestTargetMetadataProvider testTargetMetadataProvider = new TestTargetMetadataProvider();
testTargetMetadataProvider.setSyncedKeys(targetData, DocumentKey.emptyKeySet());
WatchChangeAggregator aggregator = new WatchChangeAggregator(testTargetMetadataProvider);
WatchChange.WatchTargetChange watchChange = new WatchChange.WatchTargetChange(WatchChange.WatchTargetChangeType.NoChange, asList(targetId), resumeToken);
aggregator.handleTargetChange(watchChange);
return aggregator.createRemoteEvent(version(version));
}
use of com.google.firebase.firestore.remote.WatchChangeAggregator 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());
}
Aggregations