I am creating a REST API in Spring Boot and I am stuck with unit testing my service, which makes calls to my firestore database. I am trying to mock my Firestore database so I don't add unnecessary data to my firestore database as part of my tests. However, when I try to stub responses on the mocked Firestore object, I am getting a Null Pointer Exception. I am using JUnit 5 and mocking the Firestore class by

```
@Mock
private Firestore db;

@InjectMocks
private ProductsService productsService;

```

In my test, I am stubbing a response from a method of the Firestore object by

```
// Getting a null pointer exception here
when(db.collection("products").add(productToCreate).get()).thenReturn(any(DocumentReference.class));

```