Skip to content

Commit 1db8776

Browse files
committed
test(Tone Analyzer): Update tests
1 parent 873369f commit 1db8776

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerIT.java

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

1515

16-
import com.ibm.cloud.sdk.core.service.security.IamOptions;
16+
import com.ibm.cloud.sdk.core.security.Authenticator;
17+
import com.ibm.cloud.sdk.core.security.IamAuthenticator;
1718
import com.ibm.watson.common.RetryRunner;
1819
import com.ibm.watson.common.WatsonServiceTest;
1920
import com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis;
@@ -65,11 +66,8 @@ public void setUp() throws Exception {
6566

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

68-
service = new ToneAnalyzer(VERSION_DATE_VALUE);
69-
IamOptions iamOptions = new IamOptions.Builder()
70-
.apiKey(apiKey)
71-
.build();
72-
service.setIamCredentials(iamOptions);
69+
Authenticator authenticator = new IamAuthenticator(apiKey);
70+
service = new ToneAnalyzer(VERSION_DATE_VALUE, authenticator);
7371
service.setEndPoint(getProperty("tone_analyzer.url"));
7472
service.setDefaultHeaders(getDefaultHeaders());
7573

tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerTest.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import com.ibm.cloud.sdk.core.http.HttpHeaders;
1616
import com.ibm.cloud.sdk.core.http.HttpMediaType;
17-
import com.ibm.cloud.sdk.core.security.basicauth.BasicAuthConfig;
17+
import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator;
1818
import com.ibm.cloud.sdk.core.util.RequestUtils;
1919
import com.ibm.watson.common.WatsonServiceUnitTest;
2020
import com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis;
@@ -58,11 +58,7 @@ public class ToneAnalyzerTest extends WatsonServiceUnitTest {
5858
@Before
5959
public void setUp() throws Exception {
6060
super.setUp();
61-
BasicAuthConfig authConfig = new BasicAuthConfig.Builder()
62-
.username("")
63-
.password("")
64-
.build();
65-
service = new ToneAnalyzer(VERSION_DATE_VALUE, authConfig);
61+
service = new ToneAnalyzer(VERSION_DATE_VALUE, new NoAuthAuthenticator());
6662
service.setEndPoint(getMockWebServerUrl());
6763

6864
}
@@ -73,8 +69,7 @@ public void setUp() throws Exception {
7369
@Test
7470
public void testReadme() throws InterruptedException, IOException {
7571

76-
ToneAnalyzer service = new ToneAnalyzer(VERSION_DATE);
77-
service.setUsernameAndPassword("<username>", "<password>");
72+
ToneAnalyzer service = new ToneAnalyzer(VERSION_DATE, new NoAuthAuthenticator());
7873

7974
service.setEndPoint(getMockWebServerUrl()); // exclude
8075
ToneAnalysis mockResponse = loadFixture(FIXTURE, ToneAnalysis.class); // exclude
@@ -132,7 +127,6 @@ public void testtones() throws InterruptedException, IOException {
132127

133128
String path = StringUtils.join(TONE_PATH, "?", VERSION_DATE, "=", VERSION_DATE_VALUE);
134129
assertEquals(path, request.getPath());
135-
assertNotNull(request.getHeader(HttpHeaders.AUTHORIZATION));
136130
assertEquals(serviceResponse, mockResponse);
137131
assertEquals(HttpMediaType.APPLICATION_JSON, request.getHeader(HttpHeaders.ACCEPT));
138132

@@ -201,7 +195,6 @@ public void testGetChatTones() throws IOException, InterruptedException {
201195

202196
String path = StringUtils.join(CHAT_TONE_PATH, "?", VERSION_DATE, "=", VERSION_DATE_VALUE);
203197
assertEquals(path, request.getPath());
204-
assertNotNull(request.getHeader(HttpHeaders.AUTHORIZATION));
205198
assertEquals(serviceResponse, mockResponse);
206199
assertEquals(HttpMediaType.APPLICATION_JSON, request.getHeader(HttpHeaders.ACCEPT));
207200
}

0 commit comments

Comments
 (0)