Skip to content

Commit aad4f2e

Browse files
author
Changjian Wang
committed
Refactor Content Understanding Samples to Use Single Line for Client Builder Initialization
1 parent 651ce86 commit aad4f2e

17 files changed

+31
-55
lines changed

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/Sample00_ConfigureDefaults.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public void testConfigureDefaults() {
3333
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
3434

3535
// Build the client with appropriate authentication
36-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
37-
.endpoint(endpoint);
36+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
3837

3938
ContentUnderstandingClient client;
4039
if (key != null && !key.trim().isEmpty()) {

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/Sample01_AnalyzeBinary.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public void testAnalyzeBinaryAsync() throws IOException {
4848
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
4949

5050
// Build the client with appropriate authentication
51-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
52-
.endpoint(endpoint);
51+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
5352

5453
ContentUnderstandingClient client;
5554
if (key != null && !key.trim().isEmpty()) {
@@ -178,7 +177,7 @@ public void testAnalyzeBinaryAsync() throws IOException {
178177
}
179178
} else {
180179
// Content is not DocumentContent - verify it's MediaContent
181-
Assertions.assertTrue(content instanceof MediaContent,
180+
Assertions.assertTrue(content instanceof MediaContent,
182181
"Content should be MediaContent when not DocumentContent");
183182
System.out.println("Content is MediaContent (not document-specific), skipping document properties");
184183
}

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/Sample02_AnalyzeUrl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public void testAnalyzeUrlAsync() {
4444
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
4545

4646
// Build the client with appropriate authentication
47-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
48-
.endpoint(endpoint);
47+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
4948

5049
ContentUnderstandingClient client;
5150
if (key != null && !key.trim().isEmpty()) {

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/Sample03_AnalyzeInvoice.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ public void testAnalyzeInvoiceAsync() {
4747
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
4848

4949
// Build the client with appropriate authentication
50-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
51-
.endpoint(endpoint);
50+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
5251

5352
ContentUnderstandingClient client;
5453
if (key != null && !key.trim().isEmpty()) {

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/Sample04_CreateAnalyzer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@
2222
import com.azure.ai.contentunderstanding.models.GenerationMethod;
2323
import com.azure.ai.contentunderstanding.models.NumberField;
2424
import com.azure.ai.contentunderstanding.models.StringField;
25+
import com.azure.core.credential.AzureKeyCredential;
2526
import com.azure.core.util.Configuration;
2627
import com.azure.core.util.polling.SyncPoller;
2728
import com.azure.identity.DefaultAzureCredentialBuilder;
2829
import org.junit.jupiter.api.AfterEach;
2930
import org.junit.jupiter.api.Assertions;
3031
import org.junit.jupiter.api.Test;
3132

33+
import static org.junit.jupiter.api.Assertions.*;
34+
3235
import java.util.Arrays;
3336
import java.util.HashMap;
3437
import java.util.List;
@@ -54,8 +57,7 @@ public void cleanup() {
5457
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
5558
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
5659

57-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
58-
.endpoint(endpoint);
60+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
5961

6062
ContentUnderstandingClient client;
6163
if (key != null && !key.trim().isEmpty()) {
@@ -79,8 +81,7 @@ public void testCreateAnalyzerAsync() {
7981
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
8082

8183
// Build the client with appropriate authentication
82-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
83-
.endpoint(endpoint);
84+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
8485

8586
ContentUnderstandingClient client;
8687
if (key != null && !key.trim().isEmpty()) {
@@ -298,8 +299,7 @@ public void testUseCustomAnalyzerAsync() {
298299
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
299300
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
300301

301-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
302-
.endpoint(endpoint);
302+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
303303

304304
ContentUnderstandingClient client;
305305
if (key != null && !key.trim().isEmpty()) {

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/Sample05_CreateClassifier.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public void cleanup() {
4545
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
4646
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
4747

48-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
49-
.endpoint(endpoint);
48+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
5049

5150
ContentUnderstandingClient client;
5251
if (key != null && !key.trim().isEmpty()) {
@@ -70,8 +69,7 @@ public void testCreateClassifierAsync() {
7069
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
7170

7271
// Build the client with appropriate authentication
73-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
74-
.endpoint(endpoint);
72+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
7573

7674
ContentUnderstandingClient client;
7775
if (key != null && !key.trim().isEmpty()) {

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/Sample06_GetAnalyzer.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public void testGetAnalyzerAsync() {
3232
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
3333

3434
// Build the client with appropriate authentication
35-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
36-
.endpoint(endpoint);
35+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
3736

3837
ContentUnderstandingClient client;
3938
if (key != null && !key.trim().isEmpty()) {
@@ -152,8 +151,7 @@ public void testGetAnalyzerNotFoundAsync() {
152151
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
153152
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
154153

155-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
156-
.endpoint(endpoint);
154+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
157155

158156
ContentUnderstandingClient client;
159157
if (key != null && !key.trim().isEmpty()) {

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/Sample07_ListAnalyzers.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public void testListAnalyzersAsync() {
3333
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
3434

3535
// Build the client with appropriate authentication
36-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
37-
.endpoint(endpoint);
36+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
3837

3938
ContentUnderstandingClient client;
4039
if (key != null && !key.trim().isEmpty()) {
@@ -151,8 +150,7 @@ public void testListAnalyzersWithMaxResultsAsync() {
151150
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
152151
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
153152

154-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
155-
.endpoint(endpoint);
153+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
156154

157155
ContentUnderstandingClient client;
158156
if (key != null && !key.trim().isEmpty()) {

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/Sample08_UpdateAnalyzer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public void setup() {
4545
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
4646
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
4747

48-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
49-
.endpoint(endpoint);
48+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
5049

5150
if (key != null && !key.trim().isEmpty()) {
5251
client = builder.credential(new AzureKeyCredential(key)).buildClient();

sdk/contentunderstanding/azure-ai-contentunderstanding/src/test/java/com/azure/ai/contentunderstanding/generated/Sample09_DeleteAnalyzer.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public void testDeleteAnalyzerAsync() {
4141
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
4242

4343
// Build the client with appropriate authentication
44-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
45-
.endpoint(endpoint);
44+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
4645

4746
ContentUnderstandingClient client;
4847
if (key != null && !key.trim().isEmpty()) {
@@ -133,8 +132,7 @@ public void testDeleteNonexistentAnalyzerAsync() {
133132
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
134133
String key = System.getenv("AZURE_CONTENT_UNDERSTANDING_KEY");
135134

136-
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder()
137-
.endpoint(endpoint);
135+
ContentUnderstandingClientBuilder builder = new ContentUnderstandingClientBuilder().endpoint(endpoint);
138136

139137
ContentUnderstandingClient client;
140138
if (key != null && !key.trim().isEmpty()) {

0 commit comments

Comments
 (0)