diff --git a/sdk/cosmos/azure-spring-data-cosmos-core/src/main/java/com/azure/spring/data/cosmos/core/CosmosTemplate.java b/sdk/cosmos/azure-spring-data-cosmos-core/src/main/java/com/azure/spring/data/cosmos/core/CosmosTemplate.java index 0858ec555a8f6..255d2bfeff155 100644 --- a/sdk/cosmos/azure-spring-data-cosmos-core/src/main/java/com/azure/spring/data/cosmos/core/CosmosTemplate.java +++ b/sdk/cosmos/azure-spring-data-cosmos-core/src/main/java/com/azure/spring/data/cosmos/core/CosmosTemplate.java @@ -385,7 +385,7 @@ public Iterable findAll(PartitionKey partitionKey, final Class domainT .publishOn(Schedulers.parallel()) .flatMap(cosmosItemFeedResponse -> { CosmosUtils.fillAndProcessResponseDiagnostics(this.responseDiagnosticsProcessor, - null, cosmosItemFeedResponse); + cosmosItemFeedResponse.getCosmosDiagnostics(), cosmosItemFeedResponse); return Flux.fromIterable(cosmosItemFeedResponse.getResults()); }) .map(jsonNode -> toDomainObject(domainType, jsonNode)) @@ -728,7 +728,7 @@ private Long getCountValue(CosmosQuery query, String containerName) { .onErrorResume(throwable -> CosmosExceptionUtils.exceptionHandler("Failed to get count value", throwable)) .doOnNext(response -> CosmosUtils.fillAndProcessResponseDiagnostics(this.responseDiagnosticsProcessor, - null, response)) + response.getCosmosDiagnostics(), response)) .next() .map(r -> r.getResults().get(0).asLong()) .block(); diff --git a/sdk/cosmos/azure-spring-data-cosmos-core/src/main/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplate.java b/sdk/cosmos/azure-spring-data-cosmos-core/src/main/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplate.java index 179e916f08283..32ecd039d27e6 100644 --- a/sdk/cosmos/azure-spring-data-cosmos-core/src/main/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplate.java +++ b/sdk/cosmos/azure-spring-data-cosmos-core/src/main/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplate.java @@ -598,7 +598,7 @@ private Mono getCountValue(CosmosQuery query, String containerName) { return executeQuery(querySpec, containerName, options) .doOnNext(feedResponse -> CosmosUtils.fillAndProcessResponseDiagnostics(this.responseDiagnosticsProcessor, - null, feedResponse)) + feedResponse.getCosmosDiagnostics(), feedResponse)) .onErrorResume(throwable -> CosmosExceptionUtils.exceptionHandler("Failed to get count value", throwable)) .next() @@ -669,7 +669,7 @@ private Flux findItems(@NonNull CosmosQuery query, .publishOn(Schedulers.parallel()) .flatMap(cosmosItemFeedResponse -> { CosmosUtils.fillAndProcessResponseDiagnostics(this.responseDiagnosticsProcessor, - null, cosmosItemFeedResponse); + cosmosItemFeedResponse.getCosmosDiagnostics(), cosmosItemFeedResponse); return Flux.fromIterable(cosmosItemFeedResponse.getResults()); }) .onErrorResume(throwable -> diff --git a/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java b/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java index ded02b1559c48..db2b701343b38 100644 --- a/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java +++ b/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java @@ -292,7 +292,7 @@ public void testCountByContainer() { final long prevCount = cosmosTemplate.count(containerName); assertThat(prevCount).isEqualTo(1); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); @@ -304,7 +304,7 @@ public void testCountByContainer() { final long newCount = cosmosTemplate.count(containerName); assertThat(newCount).isEqualTo(2); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); } @@ -332,7 +332,7 @@ public void testCountByQuery() { final long countIgnoreCase = cosmosTemplate.count(queryIgnoreCase, containerName); assertThat(countIgnoreCase).isEqualTo(1); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); } @@ -351,7 +351,7 @@ public void testFindAllPageableMultiPages() { assertThat(page1.getContent().size()).isEqualTo(PAGE_SIZE_1); PageTestUtils.validateNonLastPage(page1, PAGE_SIZE_1); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); @@ -360,7 +360,7 @@ public void testFindAllPageableMultiPages() { assertThat(page2.getContent().size()).isEqualTo(1); PageTestUtils.validateLastPage(page2, PAGE_SIZE_1); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); } @@ -392,7 +392,7 @@ public void testPaginationQuery() { assertThat(pageIgnoreCase.getContent().size()).isEqualTo(1); PageTestUtils.validateLastPage(pageIgnoreCase, pageIgnoreCase.getContent().size()); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); } @@ -419,7 +419,7 @@ public void testFindAllWithPageableAndSort() { assertThat(result.get(1).getFirstName()).isEqualTo(NEW_FIRST_NAME); assertThat(result.get(2).getFirstName()).isEqualTo(FIRST_NAME); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); @@ -479,7 +479,7 @@ public void testExists() { final Boolean existsIgnoreCase = cosmosTemplate.exists(queryIgnoreCase, Person.class, containerName); assertThat(existsIgnoreCase).isTrue(); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); } diff --git a/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplateIT.java b/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplateIT.java index a006a1c8503bd..4f39e4aa076cb 100644 --- a/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplateIT.java +++ b/sdk/cosmos/azure-spring-data-cosmos-test/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplateIT.java @@ -180,7 +180,7 @@ public void testFindAll() { Person.class); StepVerifier.create(flux).expectNextCount(1).verifyComplete(); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); } @@ -331,7 +331,7 @@ public void testDeleteById() { Flux flux = cosmosTemplate.findAll(Person.class.getSimpleName(), Person.class); StepVerifier.create(flux).expectNextCount(2).verifyComplete(); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); @@ -348,7 +348,7 @@ public void testDeleteById() { flux = cosmosTemplate.findAll(Person.class.getSimpleName(), Person.class); StepVerifier.create(flux).expectNextCount(1).verifyComplete(); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); @@ -386,7 +386,7 @@ public void testFind() { Person.class.getSimpleName()); StepVerifier.create(personFluxIgnoreCase).expectNextCount(1).verifyComplete(); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); } @@ -406,7 +406,7 @@ public void testExists() { final Mono existsIgnoreCase = cosmosTemplate.exists(queryIgnoreCase, Person.class, containerName); StepVerifier.create(existsIgnoreCase).expectNext(true).verifyComplete(); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); } @@ -416,7 +416,7 @@ public void testCount() { final Mono count = cosmosTemplate.count(containerName); StepVerifier.create(count).expectNext((long) 1).verifyComplete(); - assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNull(); + assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull(); Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0); }