Skip to content

Commit 59a7d94

Browse files
committed
test(Natural Language Understanding): Update tests
1 parent b33ce86 commit 59a7d94

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
package com.ibm.watson.natural_language_understanding.v1;
1414

1515

16-
import com.ibm.cloud.sdk.core.service.security.IamOptions;
16+
import com.ibm.cloud.sdk.core.security.IamAuthenticator;
1717
import com.ibm.watson.common.RetryRunner;
1818
import com.ibm.watson.common.WatsonServiceTest;
1919
import com.ibm.watson.natural_language_understanding.v1.model.AnalysisResults;
@@ -77,12 +77,9 @@ public void setUp() throws Exception {
7777

7878
Assume.assumeFalse("config.properties doesn't have valid credentials.", apiKey == null);
7979

80-
service = new NaturalLanguageUnderstanding("2018-11-16");
80+
IamAuthenticator authenticator = new IamAuthenticator(apiKey);
81+
service = new NaturalLanguageUnderstanding("2018-11-16", authenticator);
8182
service.setDefaultHeaders(getDefaultHeaders());
82-
IamOptions iamOptions = new IamOptions.Builder()
83-
.apiKey(apiKey)
84-
.build();
85-
service.setIamCredentials(iamOptions);
8683
service.setEndPoint(getProperty("natural_language_understanding.url"));
8784
}
8885

@@ -340,7 +337,7 @@ public void analyzeHtmlForMetadataIsSuccessful() throws Exception {
340337
String fileDate = "2016-05-23T20:13:00";
341338
String fileAuthor = "Annalee Newitz";
342339
Features features = new Features.Builder()
343-
.metadata(new MetadataOptions())
340+
.metadata(new MetadataOptions.Builder().build())
344341
.build();
345342
AnalyzeOptions parameters = new AnalyzeOptions.Builder()
346343
.html(html)

natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
package com.ibm.watson.natural_language_understanding.v1;
1414

1515

16-
import com.ibm.cloud.sdk.core.security.basicauth.BasicAuthConfig;
16+
import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator;
1717
import com.ibm.watson.common.WatsonServiceUnitTest;
1818
import com.ibm.watson.natural_language_understanding.v1.model.AnalysisResults;
1919
import com.ibm.watson.natural_language_understanding.v1.model.AnalyzeOptions;
@@ -68,11 +68,7 @@ public class NaturalLanguageUnderstandingTest extends WatsonServiceUnitTest {
6868
@Before
6969
public void setUp() throws Exception {
7070
super.setUp();
71-
BasicAuthConfig authConfig = new BasicAuthConfig.Builder()
72-
.username("")
73-
.password("")
74-
.build();
75-
service = new NaturalLanguageUnderstanding("2018-11-16", authConfig);
71+
service = new NaturalLanguageUnderstanding("2018-11-16", new NoAuthAuthenticator());
7672
service.setEndPoint(getMockWebServerUrl());
7773

7874
modelId = "foo";
@@ -152,7 +148,7 @@ public void testModelOptions() throws InterruptedException {
152148
keywordsOptions.newBuilder();
153149

154150
// MetadataOptions
155-
MetadataOptions metadataOptions = new MetadataOptions();
151+
MetadataOptions metadataOptions = new MetadataOptions.Builder().build();
156152
assertNotNull(metadataOptions);
157153

158154
// RelationsOptions
@@ -298,7 +294,7 @@ public void testNullModelId() {
298294
@Test(expected = IllegalArgumentException.class)
299295
public void testNullVersion() {
300296
@SuppressWarnings("unused")
301-
NaturalLanguageUnderstanding service2 = new NaturalLanguageUnderstanding(null);
297+
NaturalLanguageUnderstanding service2 = new NaturalLanguageUnderstanding(null, new NoAuthAuthenticator());
302298
}
303299

304300
}

0 commit comments

Comments
 (0)