19
19
import java .io .IOException ;
20
20
import org .junit .After ;
21
21
import org .junit .Test ;
22
+ import org .junit .function .ThrowingRunnable ;
22
23
23
24
public class FirestoreClientTest {
24
25
@@ -135,7 +136,7 @@ public void testFirestoreOptionsOverride() throws IOException {
135
136
@ Test
136
137
public void testAppDelete () throws IOException {
137
138
final String databaseId = "databaseIdInTestAppDelete" ;
138
- FirebaseApp app = FirebaseApp .initializeApp (FirebaseOptions .builder ()
139
+ final FirebaseApp app = FirebaseApp .initializeApp (FirebaseOptions .builder ()
139
140
.setCredentials (GoogleCredentials .fromStream (ServiceAccount .EDITOR .asStream ()))
140
141
.setProjectId ("mock-project-id" )
141
142
.setFirestoreOptions (FIRESTORE_OPTIONS )
@@ -151,13 +152,33 @@ public void testAppDelete() throws IOException {
151
152
152
153
assertNotSame (firestore1 , firestore2 );
153
154
154
- DocumentReference document = firestore1 .collection ("collection" ).document ("doc" );
155
+ final DocumentReference document = firestore1 .collection ("collection" ).document ("doc" );
155
156
app .delete ();
156
157
157
- assertThrows (IllegalStateException .class , () -> FirestoreClient .getFirestore (app ));
158
- assertThrows (IllegalStateException .class , () -> document .get ());
159
- assertThrows (IllegalStateException .class , () -> FirestoreClient .getFirestore ());
160
- assertThrows (IllegalStateException .class , () -> FirestoreClient .getFirestore (app , databaseId ));
161
- assertThrows (IllegalStateException .class , () -> FirestoreClient .getFirestore (databaseId ));
158
+ assertThrows (IllegalStateException .class , new ThrowingRunnable () {
159
+ public void run () {
160
+ FirestoreClient .getFirestore (app );
161
+ }
162
+ });
163
+ assertThrows (IllegalStateException .class , new ThrowingRunnable () {
164
+ public void run () throws Throwable {
165
+ document .get ();
166
+ }
167
+ });
168
+ assertThrows (IllegalStateException .class , new ThrowingRunnable () {
169
+ public void run () throws Throwable {
170
+ FirestoreClient .getFirestore ();
171
+ }
172
+ });
173
+ assertThrows (IllegalStateException .class , new ThrowingRunnable () {
174
+ public void run () throws Throwable {
175
+ FirestoreClient .getFirestore (app , databaseId );
176
+ }
177
+ });
178
+ assertThrows (IllegalStateException .class , new ThrowingRunnable () {
179
+ public void run () throws Throwable {
180
+ FirestoreClient .getFirestore (databaseId );
181
+ }
182
+ });
162
183
}
163
184
}
0 commit comments