Skip to content

Commit 7e8d676

Browse files
🐓 add tests to personality insights v3
1 parent 65b1679 commit 7e8d676

File tree

3 files changed

+65
-30
lines changed

3 files changed

+65
-30
lines changed

src/test/java/com/ibm/watson/developer_cloud/util/DateDeserializerTest.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,20 @@ public void testGetProfileWithContent() throws InterruptedException {
9393
}
9494

9595
/**
96-
* Test get profile with english text.
96+
* Test load a content from a file.
97+
*
98+
* @throws InterruptedException the interrupted exception
99+
* @throws FileNotFoundException the file not found exception
100+
*/
101+
@Test
102+
public void testLoadAContentFromAFile() throws InterruptedException, FileNotFoundException {
103+
final Content content = loadFixture(RESOURCE + "/v3-contentItems.json", Content.class);
104+
assertNotNull(content);
105+
}
106+
107+
108+
/**
109+
* Test get profile with English text.
97110
*
98111
* @throws InterruptedException the interrupted exception
99112
*/
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package com.ibm.watson.developer_cloud.util;
15+
16+
import static org.junit.Assert.assertTrue;
17+
18+
import org.apache.commons.lang3.StringUtils;
19+
import org.junit.Test;
20+
21+
import com.google.gson.JsonElement;
22+
import com.google.gson.JsonParser;
23+
24+
/**
25+
* The Class DateDeserializerTest.
26+
*/
27+
public class DateDeserializerTest {
28+
29+
/**
30+
* Test deserialize.
31+
*/
32+
@Test
33+
public void testDeserialize() {
34+
String[] dateStrings = {
35+
"2016-06-20T04:25:16.218+0000",
36+
"2016-06-20T04:25:16",
37+
"2016-06-20T04:25:16.218Z",
38+
"2015-05-28T18:01:57Z",
39+
"2016-06-20T04:25:16.218+0000"
40+
};
41+
42+
String jsonStr = "[\"" + StringUtils.join(dateStrings, "\",\"") + "\"]";
43+
JsonParser parser = new JsonParser();
44+
JsonElement element = parser.parse(jsonStr);
45+
DateDeserializer deserializer = new DateDeserializer();
46+
for (int i = 0; i < 5; i++) {
47+
System.out.println(deserializer.deserialize(element.getAsJsonArray().get(i), null, null));
48+
assertTrue(deserializer.deserialize(element.getAsJsonArray().get(i), null, null) != null);
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)