File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
firebase-firestore/src/test/java/com/google/firebase/firestore/local Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 23
23
import static com .google .firebase .firestore .testutil .TestUtil .setMutation ;
24
24
import static org .junit .Assert .assertEquals ;
25
25
import static org .junit .Assert .assertNull ;
26
+ import static org .junit .Assert .assertThrows ;
26
27
import static org .junit .Assert .assertTrue ;
27
28
28
29
import com .google .firebase .firestore .auth .User ;
41
42
import org .junit .After ;
42
43
import org .junit .Before ;
43
44
import org .junit .Test ;
45
+ import org .junit .function .ThrowingRunnable ;
44
46
45
47
/**
46
48
* These are tests for any implementation of the DocumentOverlayCache interface.
@@ -252,6 +254,24 @@ public void testUpdateDocumentOverlay() {
252
254
assertNull (cache .getOverlay (DocumentKey .fromPathString ("coll/doc" )));
253
255
}
254
256
257
+ @ Test
258
+ public void testSaveOverlaysThrowsNullPointerExceptionOnNullMapValue () {
259
+ Map <DocumentKey , Mutation > data = new HashMap <>();
260
+ data .put (key ("coll/doc" ), null );
261
+
262
+ NullPointerException e =
263
+ assertThrows (
264
+ NullPointerException .class ,
265
+ new ThrowingRunnable () {
266
+ @ Override
267
+ public void run () {
268
+ cache .saveOverlays (1 , data );
269
+ }
270
+ });
271
+
272
+ assertThat (e .getMessage ()).contains ("coll/doc" );
273
+ }
274
+
255
275
void verifyOverlayContains (Map <DocumentKey , Overlay > overlays , String ... keys ) {
256
276
Set <DocumentKey > expected = Arrays .stream (keys ).map (TestUtil ::key ).collect (Collectors .toSet ());
257
277
assertThat (overlays .keySet ()).containsExactlyElementsIn (expected );
You can’t perform that action at this time.
0 commit comments