use of com.google.firestore.v1.Write.Builder in project spring-cloud-gcp by spring-cloud.
the class FirestoreTemplateTests method countWithQueryTest.
@Test
public void countWithQueryTest() {
mockRunQueryMethod();
StructuredQuery.Builder builder = StructuredQuery.newBuilder();
addWhere(builder);
StepVerifier.create(this.firestoreTemplate.count(TestEntity.class, builder)).expectNext(2L).verifyComplete();
StructuredQuery.Builder expectedBuilder = StructuredQuery.newBuilder().addFrom(StructuredQuery.CollectionSelector.newBuilder().setCollectionId("testEntities").build()).setSelect(StructuredQuery.Projection.newBuilder().addFields(StructuredQuery.FieldReference.newBuilder().setFieldPath("__name__").build()).build());
addWhere(expectedBuilder);
RunQueryRequest request = RunQueryRequest.newBuilder().setParent(this.parent).setStructuredQuery(expectedBuilder).build();
verify(this.firestoreStub, times(1)).runQuery(eq(request), any());
verify(this.firestoreStub, times(1)).runQuery(any(), any());
}
Aggregations