Skip to content

Commit 92711c7

Browse files
author
Changjian Wang
committed
Refactor Content Understanding Samples to Use Updated Environment Variables and Improve Test Patterns
- Updated environment variable names from "ENDPOINT" and "CONTENTUNDERSTANDING_API_KEY" to "CONTENTUNDERSTANDING_ENDPOINT" and "AZURE_CONTENT_UNDERSTANDING_KEY" across multiple sample test files. - Modified sample tests to load local files instead of using publicly accessible URLs for document analysis. - Enhanced assertions and logging for better clarity and debugging. - Improved API usage patterns in tests for creating, copying, and deleting analyzers, including async patterns. - Added model mappings for analyzers in relevant samples to demonstrate configuration capabilities.
1 parent cbdc2ad commit 92711c7

17 files changed

+193
-233
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void testConfigureDefaults() {
2828
// Create the Content Understanding client
2929
ContentUnderstandingClient client
3030
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
31-
.endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT"))
31+
.endpoint(Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT"))
3232
.buildClient();
3333

3434
// Step 1: Get current defaults

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class Sample01_AnalyzeBinary {
4141
@Test
4242
public void testAnalyzeBinaryAsync() throws IOException {
4343
// Create the Content Understanding client
44-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
44+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
4545
ContentUnderstandingClient client
4646
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
4747
.endpoint(endpoint)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class Sample02_AnalyzeUrl {
3737
@Test
3838
public void testAnalyzeUrlAsync() {
3939
// Create the Content Understanding client
40-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
40+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
4141
ContentUnderstandingClient client
4242
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
4343
.endpoint(endpoint)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Sample03_AnalyzeInvoice {
4040
@Test
4141
public void testAnalyzeInvoiceAsync() {
4242
// Create the Content Understanding client
43-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
43+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
4444
ContentUnderstandingClient client
4545
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
4646
.endpoint(endpoint)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class Sample04_CreateAnalyzer {
5151
public void cleanup() {
5252
if (createdAnalyzerId != null) {
5353
try {
54-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
54+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
5555
ContentUnderstandingClient client
5656
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
5757
.endpoint(endpoint)
@@ -67,7 +67,7 @@ public void cleanup() {
6767
@Test
6868
public void testCreateAnalyzerAsync() {
6969
// Create the Content Understanding client
70-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
70+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
7171
ContentUnderstandingClient client
7272
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
7373
.endpoint(endpoint)
@@ -271,7 +271,7 @@ public void testCreateAnalyzerAsync() {
271271
@Test
272272
public void testUseCustomAnalyzerAsync() {
273273
// Create the Content Understanding client
274-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
274+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
275275
ContentUnderstandingClient client
276276
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
277277
.endpoint(endpoint)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class Sample05_CreateClassifier {
3939
public void cleanup() {
4040
if (createdAnalyzerId != null) {
4141
try {
42-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
42+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
4343
ContentUnderstandingClient client
4444
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
4545
.endpoint(endpoint)
@@ -55,7 +55,7 @@ public void cleanup() {
5555
@Test
5656
public void testCreateClassifierAsync() {
5757
// Create the Content Understanding client
58-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
58+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
5959
ContentUnderstandingClient client
6060
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
6161
.endpoint(endpoint)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class Sample06_GetAnalyzer {
2525
@Test
2626
public void testGetAnalyzerAsync() {
2727
// Create the Content Understanding client
28-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
28+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
2929
ContentUnderstandingClient client
3030
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
3131
.endpoint(endpoint)
@@ -130,7 +130,7 @@ public void testGetAnalyzerAsync() {
130130
@Test
131131
public void testGetPrebuiltDocumentAnalyzerAsync() {
132132
// Create the Content Understanding client
133-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
133+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
134134
ContentUnderstandingClient client
135135
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
136136
.endpoint(endpoint)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class Sample07_ListAnalyzers {
2626
@Test
2727
public void testListAnalyzersAsync() {
2828
// Create the Content Understanding client
29-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
29+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
3030
ContentUnderstandingClient client
3131
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
3232
.endpoint(endpoint)
@@ -129,7 +129,7 @@ public void testListAnalyzersAsync() {
129129
@Test
130130
public void testListReadyAnalyzersAsync() {
131131
// Create the Content Understanding client
132-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
132+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
133133
ContentUnderstandingClient client
134134
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
135135
.endpoint(endpoint)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class Sample08_UpdateAnalyzer {
3939

4040
@BeforeEach
4141
public void setup() {
42-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
42+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
4343
client = new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
4444
.endpoint(endpoint)
4545
.buildClient();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class Sample09_DeleteAnalyzer {
3434
@Test
3535
public void testDeleteAnalyzerAsync() {
3636
// Create the Content Understanding client
37-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
37+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
3838
ContentUnderstandingClient client
3939
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
4040
.endpoint(endpoint)
@@ -111,7 +111,7 @@ public void testDeleteAnalyzerAsync() {
111111
@Test
112112
public void testDeleteNonExistentAnalyzerAsync() {
113113
// Create the Content Understanding client
114-
String endpoint = Configuration.getGlobalConfiguration().get("ENDPOINT");
114+
String endpoint = Configuration.getGlobalConfiguration().get("CONTENTUNDERSTANDING_ENDPOINT");
115115
ContentUnderstandingClient client
116116
= new ContentUnderstandingClientBuilder().credential(new DefaultAzureCredentialBuilder().build())
117117
.endpoint(endpoint)

0 commit comments

Comments
 (0)