File tree Expand file tree Collapse file tree
google-cloud-firestore/src
main/java/com/google/cloud/firestore
test/java/com/google/cloud/firestore Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717package com .google .cloud .firestore ;
1818
19+ import com .google .common .base .Preconditions ;
1920import com .google .common .collect .ImmutableList ;
2021import javax .annotation .Nullable ;
2122
@@ -52,6 +53,7 @@ B getParent() {
5253 * @param path A relative path
5354 */
5455 B append (String path ) {
56+ Preconditions .checkArgument (path != null && !path .isEmpty (), "'path' must be a non-empty String" );
5557 ImmutableList .Builder <String > components = ImmutableList .builder ();
5658 components .addAll (this .getSegments ());
5759 components .add (splitChildPath (path ));
Original file line number Diff line number Diff line change 1919import static org .junit .Assert .assertEquals ;
2020import static org .junit .Assert .assertNull ;
2121import static org .junit .Assert .assertTrue ;
22+ import static org .junit .Assert .fail ;
2223import static org .mockito .Mockito .doReturn ;
2324
2425import com .google .api .core .ApiFuture ;
2526import com .google .api .gax .rpc .UnaryCallable ;
27+ import com .google .cloud .firestore .Transaction .Function ;
2628import com .google .cloud .firestore .spi .v1beta1 .FirestoreRpc ;
2729import com .google .firestore .v1beta1 .CommitRequest ;
2830import com .google .firestore .v1beta1 .CommitResponse ;
@@ -68,6 +70,13 @@ public void getDocument() {
6870 assertEquals ("doc" , documentReference .getId ());
6971 documentReference = collectionReference .document ();
7072 assertEquals (20 , documentReference .getId ().length ());
73+
74+ try {
75+ collectionReference .document ("" );
76+ fail ();
77+ } catch (IllegalArgumentException e ) {
78+ assertTrue (e .getMessage ().endsWith ("'path' must be a non-empty String" ));
79+ }
7180 }
7281
7382 @ Test
Original file line number Diff line number Diff line change @@ -423,6 +423,7 @@ public String updateCallback(Transaction transaction) {
423423 }
424424 })
425425 .get ();
426+ fail ();
426427 } catch (Exception e ) {
427428 assertTrue (e .getMessage ().endsWith ("User exception" ));
428429 }
You can’t perform that action at this time.
0 commit comments