diff --git a/sdk/communication/azure-communication-phonenumbers/pom.xml b/sdk/communication/azure-communication-phonenumbers/pom.xml index 09d615e04a8a1..2bd491f72a8f9 100644 --- a/sdk/communication/azure-communication-phonenumbers/pom.xml +++ b/sdk/communication/azure-communication-phonenumbers/pom.xml @@ -134,6 +134,7 @@ com/azure/communication/phonenumbers/*.class + com/azure/communication/phonenumbers/siprouting/*.class diff --git a/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/siprouting/SipRoutingClientBuilderTest.java b/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/siprouting/SipRoutingClientBuilderTest.java index 8a7bcb2f0d6b8..f1c86973377a3 100644 --- a/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/siprouting/SipRoutingClientBuilderTest.java +++ b/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/siprouting/SipRoutingClientBuilderTest.java @@ -7,7 +7,9 @@ import com.azure.core.credential.AzureKeyCredential; import com.azure.core.http.HttpClient; import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelinePosition; import com.azure.core.http.policy.*; +import com.azure.core.util.ClientOptions; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; import org.junit.jupiter.api.AfterEach; @@ -17,6 +19,8 @@ import org.mockito.Mockito; import org.mockito.stubbing.Answer; +import java.time.Duration; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -115,6 +119,69 @@ public void buildClientWithServiceVersion() { assertNotNull(sipRoutingClient); } + @Test + public void buildClientWithRetryPolicy() { + SipRoutingClient sipRoutingClient = this.setupBuilderWithHttpClientWithCredential(this.clientBuilder) + .retryPolicy(new RetryPolicy("1", ChronoUnit.SECONDS)) + .buildClient(); + assertNotNull(sipRoutingClient); + } + + @Test + public void buildClientWithRetryOptions() { + SipRoutingClient sipRoutingClient = this.setupBuilderWithHttpClientWithCredential(this.clientBuilder) + .retryOptions(new RetryOptions(new FixedDelayOptions(3, Duration.ZERO))) + .buildClient(); + assertNotNull(sipRoutingClient); + } + + @Test + public void buildClientWithClientOptions() { + SipRoutingClient sipRoutingClient = this.setupBuilderWithHttpClientWithCredential(this.clientBuilder) + .clientOptions(new ClientOptions()) + .buildClient(); + assertNotNull(sipRoutingClient); + } + + @Test + public void buildClientByReplacingHttpClient() { + SipRoutingClient sipRoutingClient = this.setupBuilderWithHttpClientWithCredential(this.clientBuilder) + .httpClient(this.httpClient) + .httpClient(this.httpClient) + .buildClient(); + assertNotNull(sipRoutingClient); + } + + @Test + public void buildClientByReplacingPipeline() { + HttpPipeline httpPipeline = mock(HttpPipeline.class); + SipRoutingClient sipRoutingClient = this.setupBuilderWithHttpClientWithCredential(this.clientBuilder) + .pipeline(httpPipeline) + .pipeline(httpPipeline) + .buildClient(); + assertNotNull(sipRoutingClient); + } + + @Test + public void buildClientWithPolicyPerCall() { + HttpPipelinePolicy policy = mock(HttpPipelinePolicy.class); + doAnswer(invocation -> HttpPipelinePosition.PER_CALL).when(policy).getPipelinePosition(); + SipRoutingClient sipRoutingClient = this.setupBuilderWithHttpClientWithCredential(this.clientBuilder) + .addPolicy(policy) + .buildClient(); + assertNotNull(sipRoutingClient); + } + + @Test + public void buildClientWithPolicyPerRetry() { + HttpPipelinePolicy policy = mock(HttpPipelinePolicy.class); + doAnswer(invocation -> HttpPipelinePosition.PER_RETRY).when(policy).getPipelinePosition(); + SipRoutingClient sipRoutingClient = this.setupBuilderWithHttpClientWithCredential(this.clientBuilder) + .addPolicy(policy) + .buildClient(); + assertNotNull(sipRoutingClient); + } + @Test public void buildClientWithOneAdditionalPolicy() { ClientBuilderSpyHelper spyHelper = new ClientBuilderSpyHelper(this.clientBuilder);