Skip to content

Commit 845120a

Browse files
committed
test(Personality Insights): Update tests
1 parent 59a7d94 commit 845120a

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsIT.java

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

1515
import com.google.common.io.CharStreams;
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.WatsonServiceTest;
1818
import com.ibm.watson.personality_insights.v3.model.ConsumptionPreferences;
1919
import com.ibm.watson.personality_insights.v3.model.Content;
@@ -29,7 +29,7 @@
2929
import java.io.FileInputStream;
3030
import java.io.InputStream;
3131
import java.io.InputStreamReader;
32-
import java.util.Arrays;
32+
import java.util.Collections;
3333
import java.util.Date;
3434
import java.util.UUID;
3535

@@ -56,12 +56,9 @@ public void setUp() throws Exception {
5656

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

59-
service = new PersonalityInsights(VERSION_DATE_2016_10_19);
59+
IamAuthenticator authenticator = new IamAuthenticator(apiKey);
60+
service = new PersonalityInsights(VERSION_DATE_2016_10_19, authenticator);
6061
service.setEndPoint(getProperty("personality_insights.url"));
61-
IamOptions iamOptions = new IamOptions.Builder()
62-
.apiKey(apiKey)
63-
.build();
64-
service.setIamCredentials(iamOptions);
6562
service.setDefaultHeaders(getDefaultHeaders());
6663
}
6764

@@ -190,7 +187,7 @@ public void getProfileWithASingleContentItem() throws Exception {
190187
.reply(false)
191188
.parentid(null)
192189
.build();
193-
Content content = new Content.Builder(Arrays.asList(cItem)).build();
190+
Content content = new Content.Builder(Collections.singletonList(cItem)).build();
194191
ProfileOptions options = new ProfileOptions.Builder()
195192
.content(content)
196193
.consumptionPreferences(true)
@@ -205,7 +202,6 @@ public void getProfileWithASingleContentItem() throws Exception {
205202
Assert.assertNotNull(profile.getValues().get(0).getCategory());
206203
Assert.assertNotNull(profile.getValues().get(0).getName());
207204
Assert.assertNotNull(profile.getValues().get(0).getTraitId());
208-
//Assert.assertNotNull(profile.getValues().get(0).getChildren());
209205
Assert.assertNotNull(profile.getValues().get(0).getPercentile());
210206
Assert.assertNotNull(profile.getValues().get(0).getRawScore());
211207

@@ -241,7 +237,7 @@ public void getProfileWithASingleSpanishContentItem() throws Exception {
241237
.language(ContentItem.Language.ES)
242238
.build();
243239
Content content = new Content.Builder()
244-
.contentItems(Arrays.asList(cItem))
240+
.contentItems(Collections.singletonList(cItem))
245241
.build();
246242
ProfileOptions options = new ProfileOptions.Builder()
247243
.content(content)

personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsTest.java

Lines changed: 4 additions & 8 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.watson.common.WatsonServiceUnitTest;
1919
import com.ibm.watson.personality_insights.v3.model.Content;
2020
import com.ibm.watson.personality_insights.v3.model.ContentItem;
@@ -65,11 +65,7 @@ public PersonalityInsightsTest() throws FileNotFoundException {
6565
@Before
6666
public void setUp() throws Exception {
6767
super.setUp();
68-
BasicAuthConfig authConfig = new BasicAuthConfig.Builder()
69-
.username("")
70-
.password("")
71-
.build();
72-
service = new PersonalityInsights(VERSION_DATE_2016_10_19, authConfig);
68+
service = new PersonalityInsights(VERSION_DATE_2016_10_19, new NoAuthAuthenticator());
7369
service.setEndPoint(getMockWebServerUrl());
7470
}
7571

@@ -78,15 +74,15 @@ public void setUp() throws Exception {
7874
*/
7975
@Test(expected = IllegalArgumentException.class)
8076
public void testConstructorWithNullVersionDate() {
81-
new PersonalityInsights(null);
77+
new PersonalityInsights(null, new NoAuthAuthenticator());
8278
}
8379

8480
/**
8581
* Negative - Test constructor with empty version date.
8682
*/
8783
@Test(expected = IllegalArgumentException.class)
8884
public void testConstructorWithEmptyVersionDate() {
89-
new PersonalityInsights("");
85+
new PersonalityInsights("", new NoAuthAuthenticator());
9086
}
9187

9288
/**

0 commit comments

Comments
 (0)