From 537d6e01351189cc835ad1521e110d3ed2fb1885 Mon Sep 17 00:00:00 2001
From: Alan Zimmer <48699787+alzimmermsft@users.noreply.github.com>
Date: Mon, 23 Sep 2024 16:18:52 -0400
Subject: [PATCH] Pass HttpClient into tests not using helper methods (#41990)
Pass HttpClient into tests not using helper methods
---
.../azure-resourcemanager-fabric/pom.xml | 2 +-
.../search/documents/SearchClientBuilder.java | 3 +--
.../documents/SearchClientBuilderTests.java | 7 +++++++
...SearchIndexingBufferedSenderUnitTests.java | 6 ++++++
.../SearchServiceSubClientTests.java | 4 ++++
.../indexes/IndexManagementTests.java | 12 ++++++-----
.../indexes/IndexersManagementTests.java | 20 ++++++++++---------
.../documents/indexes/NonRestCallTests.java | 3 +++
.../SearchIndexClientBuilderTests.java | 18 ++++++++++++-----
.../SearchIndexerClientBuilderTests.java | 20 +++++++++++++------
10 files changed, 67 insertions(+), 28 deletions(-)
diff --git a/sdk/fabric/azure-resourcemanager-fabric/pom.xml b/sdk/fabric/azure-resourcemanager-fabric/pom.xml
index 7a77f7f6000d4..ce4f5692fb686 100644
--- a/sdk/fabric/azure-resourcemanager-fabric/pom.xml
+++ b/sdk/fabric/azure-resourcemanager-fabric/pom.xml
@@ -66,7 +66,7 @@
com.azure
azure-core-test
- 1.26.2
+ 1.27.0-beta.1
test
diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchClientBuilder.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchClientBuilder.java
index dda9e3e24d770..c2ff43c386bd8 100644
--- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchClientBuilder.java
+++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/SearchClientBuilder.java
@@ -330,8 +330,7 @@ private HttpPipeline getHttpPipeline() {
* Sets the service endpoint for the Azure AI Search instance.
*
* @param endpoint The URL of the Azure AI Search instance.
- * @return The updated SearchClientBuilder object.
- * @throws IllegalArgumentException If {@code endpoint} is null or it cannot be parsed into a valid URL.
+ * @return The updated SearchClientBuilder object.0ed into a valid URL.
*/
@Override
public SearchClientBuilder endpoint(String endpoint) {
diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchClientBuilderTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchClientBuilderTests.java
index 5b9c5febcd4ae..14b5d91006603 100644
--- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchClientBuilderTests.java
+++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchClientBuilderTests.java
@@ -47,6 +47,7 @@ public void buildSyncClientTest() {
.credential(SEARCH_CREDENTIAL)
.indexName(INDEX_NAME)
.serviceVersion(API_VERSION)
+ .httpClient(request -> Mono.just(new MockHttpResponse(request, 200)))
.buildClient();
assertNotNull(client);
@@ -59,6 +60,7 @@ public void buildSyncClientUsingDefaultApiVersionTest() {
.endpoint(SEARCH_ENDPOINT)
.credential(SEARCH_CREDENTIAL)
.indexName(INDEX_NAME)
+ .httpClient(request -> Mono.just(new MockHttpResponse(request, 200)))
.buildClient();
assertNotNull(client);
@@ -72,6 +74,7 @@ public void buildAsyncClientTest() {
.credential(SEARCH_CREDENTIAL)
.indexName(INDEX_NAME)
.serviceVersion(API_VERSION)
+ .httpClient(request -> Mono.just(new MockHttpResponse(request, 200)))
.buildAsyncClient();
assertNotNull(client);
@@ -84,6 +87,7 @@ public void buildAsyncClientUsingDefaultApiVersionTest() {
.endpoint(SEARCH_ENDPOINT)
.credential(SEARCH_CREDENTIAL)
.indexName(INDEX_NAME)
+ .httpClient(request -> Mono.just(new MockHttpResponse(request, 200)))
.buildAsyncClient();
assertNotNull(client);
@@ -96,6 +100,7 @@ public void whenBuildClientAndVerifyPropertiesThenSuccess() {
.endpoint(SEARCH_ENDPOINT)
.credential(SEARCH_CREDENTIAL)
.indexName(INDEX_NAME)
+ .httpClient(request -> Mono.just(new MockHttpResponse(request, 200)))
.buildClient();
assertEquals(SEARCH_ENDPOINT, client.getEndpoint());
@@ -105,6 +110,7 @@ public void whenBuildClientAndVerifyPropertiesThenSuccess() {
.endpoint(SEARCH_ENDPOINT)
.credential(SEARCH_CREDENTIAL)
.indexName(INDEX_NAME)
+ .httpClient(request -> Mono.just(new MockHttpResponse(request, 200)))
.buildAsyncClient();
assertEquals(SEARCH_ENDPOINT, asyncClient.getEndpoint());
@@ -214,6 +220,7 @@ public void bothRetryOptionsAndRetryPolicySet() {
.serviceVersion(API_VERSION)
.retryOptions(new RetryOptions(new ExponentialBackoffOptions()))
.retryPolicy(new RetryPolicy())
+ .httpClient(request -> Mono.just(new MockHttpResponse(request, 200)))
.buildClient());
}
}
diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchIndexingBufferedSenderUnitTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchIndexingBufferedSenderUnitTests.java
index 139477e519b0e..97650258d089b 100644
--- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchIndexingBufferedSenderUnitTests.java
+++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchIndexingBufferedSenderUnitTests.java
@@ -923,6 +923,7 @@ public void batchSplitsUntilOneAndPartiallyFailsAsync() {
public void operationsThrowAfterClientIsClosed(
Consumer>> operation) {
SearchIndexingBufferedSender