Search in sources :

Example 51 with DocumentKey

use of com.google.firebase.firestore.model.DocumentKey in project firebase-android-sdk by firebase.

the class LruGarbageCollectorTestCase method markADocumentEligibleForGcInTransaction.

private void markADocumentEligibleForGcInTransaction() {
    DocumentKey key = nextTestDocumentKey();
    markDocumentEligibleForGcInTransaction(key);
}
Also used : DocumentKey(com.google.firebase.firestore.model.DocumentKey)

Example 52 with DocumentKey

use of com.google.firebase.firestore.model.DocumentKey in project firebase-android-sdk by firebase.

the class LruGarbageCollectorTestCase method markADocumentEligibleForGc.

private void markADocumentEligibleForGc() {
    DocumentKey key = nextTestDocumentKey();
    markDocumentEligibleForGc(key);
}
Also used : DocumentKey(com.google.firebase.firestore.model.DocumentKey)

Example 53 with DocumentKey

use of com.google.firebase.firestore.model.DocumentKey in project firebase-android-sdk by firebase.

the class TargetCacheTestCase method testRemoveQueryRemovesMatchingKeysToo.

@Test
public void testRemoveQueryRemovesMatchingKeysToo() {
    TargetData rooms = newTargetData(query("rooms"), 1, 1);
    addTargetData(rooms);
    DocumentKey key1 = key("rooms/foo");
    DocumentKey key2 = key("rooms/bar");
    addMatchingKey(key1, rooms.getTargetId());
    addMatchingKey(key2, rooms.getTargetId());
    assertTrue(targetCache.containsKey(key1));
    assertTrue(targetCache.containsKey(key2));
    removeTargetData(rooms);
    assertFalse(targetCache.containsKey(key1));
    assertFalse(targetCache.containsKey(key2));
}
Also used : DocumentKey(com.google.firebase.firestore.model.DocumentKey) Test(org.junit.Test)

Example 54 with DocumentKey

use of com.google.firebase.firestore.model.DocumentKey in project firebase-android-sdk by firebase.

the class TargetCacheTestCase method testRemoveMatchingKeysForTargetId.

@Test
public void testRemoveMatchingKeysForTargetId() {
    DocumentKey key1 = key("foo/bar");
    DocumentKey key2 = key("foo/baz");
    DocumentKey key3 = key("foo/blah");
    addMatchingKey(key1, 1);
    addMatchingKey(key2, 1);
    addMatchingKey(key3, 2);
    assertTrue(targetCache.containsKey(key1));
    assertTrue(targetCache.containsKey(key2));
    assertTrue(targetCache.containsKey(key3));
    removeMatchingKeysForTargetId(1);
    assertFalse(targetCache.containsKey(key1));
    assertFalse(targetCache.containsKey(key2));
    assertTrue(targetCache.containsKey(key3));
    removeMatchingKeysForTargetId(2);
    assertFalse(targetCache.containsKey(key1));
    assertFalse(targetCache.containsKey(key2));
    assertFalse(targetCache.containsKey(key3));
}
Also used : DocumentKey(com.google.firebase.firestore.model.DocumentKey) Test(org.junit.Test)

Example 55 with DocumentKey

use of com.google.firebase.firestore.model.DocumentKey in project firebase-android-sdk by firebase.

the class TargetCacheTestCase method testMatchingKeysForTargetID.

@Test
public void testMatchingKeysForTargetID() {
    DocumentKey key1 = key("foo/bar");
    DocumentKey key2 = key("foo/baz");
    DocumentKey key3 = key("foo/blah");
    addMatchingKey(key1, 1);
    addMatchingKey(key2, 1);
    addMatchingKey(key3, 2);
    assertSetEquals(asList(key1, key2), targetCache.getMatchingKeysForTargetId(1));
    assertSetEquals(asList(key3), targetCache.getMatchingKeysForTargetId(2));
    addMatchingKey(key1, 2);
    assertSetEquals(asList(key1, key2), targetCache.getMatchingKeysForTargetId(1));
    assertSetEquals(asList(key1, key3), targetCache.getMatchingKeysForTargetId(2));
}
Also used : DocumentKey(com.google.firebase.firestore.model.DocumentKey) Test(org.junit.Test)

Aggregations

DocumentKey (com.google.firebase.firestore.model.DocumentKey)139 MutableDocument (com.google.firebase.firestore.model.MutableDocument)53 Test (org.junit.Test)36 HashMap (java.util.HashMap)34 ArrayList (java.util.ArrayList)24 Document (com.google.firebase.firestore.model.Document)20 Mutation (com.google.firebase.firestore.model.mutation.Mutation)18 Map (java.util.Map)18 SnapshotVersion (com.google.firebase.firestore.model.SnapshotVersion)16 ResourcePath (com.google.firebase.firestore.model.ResourcePath)13 MutationBatch (com.google.firebase.firestore.model.mutation.MutationBatch)11 ImmutableSortedMap (com.google.firebase.database.collection.ImmutableSortedMap)10 Overlay (com.google.firebase.firestore.model.mutation.Overlay)10 HashSet (java.util.HashSet)10 TestUtil.patchMutation (com.google.firebase.firestore.testutil.TestUtil.patchMutation)8 TestUtil.setMutation (com.google.firebase.firestore.testutil.TestUtil.setMutation)8 ByteString (com.google.protobuf.ByteString)7 Target (com.google.firebase.firestore.core.Target)6 ObjectValue (com.google.firebase.firestore.model.ObjectValue)6 TestUtil.deleteMutation (com.google.firebase.firestore.testutil.TestUtil.deleteMutation)6