Skip to content

Commit 5756e6e

Browse files
[dialog] Added integration test to check that the updateProfile method
works. #201
1 parent 503bbc9 commit 5756e6e

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

src/main/java/com/ibm/watson/developer_cloud/dialog/v1/DialogService.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import java.util.Map;
2424
import java.util.logging.Logger;
2525

26-
import com.google.gson.Gson;
27-
import com.google.gson.GsonBuilder;
2826
import com.google.gson.JsonObject;
2927
import com.google.gson.reflect.TypeToken;
3028
import com.ibm.watson.developer_cloud.dialog.v1.model.Conversation;
@@ -300,15 +298,10 @@ public List<ConversationData> getConversationData(final Map<String, Object> para
300298
final Response response = execute(request);
301299
final JsonObject jsonObject = ResponseUtil.getJsonObject(response);
302300
final List<ConversationData> conversationDataList =
303-
getGson().fromJson(jsonObject.get(CONVERSATIONS), listConversationDataType);
301+
GsonSingleton.getGsonWithoutPrettyPrinting().fromJson(jsonObject.get(CONVERSATIONS), listConversationDataType);
304302
return conversationDataList;
305303
}
306304

307-
private Gson getGson() {
308-
return new GsonBuilder().setDateFormat(CONVERSATION_DATE_FORMAT).create();
309-
}
310-
311-
312305
/**
313306
* Retrieves the list of Dialogs for the user.
314307
*

src/test/java/com/ibm/watson/developer_cloud/dialog/v1/DialogServiceIT.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
package com.ibm.watson.developer_cloud.dialog.v1;
1515

16+
import static org.junit.Assert.assertEquals;
1617
import static org.junit.Assert.assertFalse;
1718
import static org.junit.Assert.assertNotNull;
1819

@@ -101,12 +102,16 @@ public void testConverseAndGetConversationData() throws ParseException, Interrup
101102
assertFalse(dialogContent.isEmpty());
102103
assertNotNull(dialogContent.get(0));
103104

104-
final Map<String, String> profile = service.getProfile(dialogId, c.getClientId());
105+
Map<String, String> profile = service.getProfile(dialogId, c.getClientId());
106+
105107
// update profile
106-
profile.put(profile.keySet().iterator().next(), "foo");
107-
108+
String variable = profile.keySet().iterator().next();
109+
profile.put(variable, "foo");
108110
service.updateProfile(dialogId, c.getClientId(), profile);
109111

112+
assertEquals(service.getProfile(dialogId, c.getClientId()).get(variable), "foo");
113+
assertEquals(service.getProfile(dialogId, c.getClientId(), variable).get(variable), "foo");
114+
110115
final Map<String, Object> params = new HashMap<String,Object>();
111116
params.put(DialogService.DATE_FROM, DateUtils.addDays(new Date(), -10));
112117
params.put(DialogService.DATE_TO, new Date());

0 commit comments

Comments
 (0)