ToneAnalyzer extends BaseService { public ServiceCall<UtteranceAnalyses> toneChat(ToneChatOptions toneChatOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( toneChatOptions, "toneChatOptions cannot be null"); String[] pathSegments = {"v3/tone_chat"}; RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); builder.query("version", versionDate); Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("tone_analyzer", "v3", "toneChat"); for (Entry<String, String> header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); if (toneChatOptions.contentLanguage() != null) { builder.header("Content-Language", toneChatOptions.contentLanguage()); } if (toneChatOptions.acceptLanguage() != null) { builder.header("Accept-Language", toneChatOptions.acceptLanguage()); } final JsonObject contentJson = new JsonObject(); contentJson.add( "utterances", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() .toJsonTree(toneChatOptions.utterances())); builder.bodyJson(contentJson); ResponseConverter<UtteranceAnalyses> responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken<UtteranceAnalyses>() {}.getType()); return createServiceCall(builder.build(), responseConverter); } ToneAnalyzer(String versionDate);  ToneAnalyzer(String versionDate, Authenticator authenticator);  ToneAnalyzer(String versionDate, String serviceName);  ToneAnalyzer(String versionDate, String serviceName, Authenticator authenticator); ServiceCall<ToneAnalysis> tone(ToneOptions toneOptions); ServiceCall<UtteranceAnalyses> toneChat(ToneChatOptions toneChatOptions);  }
@Test public void testGetChatTones() throws IOException, InterruptedException { String[] users = {"customer", "agent", "customer", "agent"}; String[] texts = { "My charger isn't working.", "Thanks for reaching out. Can you give me some more detail about the issue?", "I put my charger in my tablet to charge it up last night and it keeps saying it isn't" + " charging. The charging icon comes on, but it stays on even when I take the charger out. " + "Which is ridiculous, it's brand new.", "I'm sorry you're having issues with charging. What kind of charger are you using?" }; List<Utterance> utterances = new ArrayList<>(); for (int i = 0; i < texts.length; i++) { Utterance utterance = new Utterance.Builder().text(texts[i]).user(users[i]).build(); utterances.add(utterance); } ToneChatOptions toneChatOptions = new ToneChatOptions.Builder().utterances(utterances).build(); UtteranceAnalyses mockResponse = loadFixture(CHAT_FIXTURE, UtteranceAnalyses.class); server.enqueue(jsonResponse(mockResponse)); server.enqueue(jsonResponse(mockResponse)); server.enqueue(jsonResponse(mockResponse)); UtteranceAnalyses serviceResponse = service.toneChat(toneChatOptions).execute().getResult(); RecordedRequest request = server.takeRequest(); String path = StringUtils.join(CHAT_TONE_PATH, "?", VERSION_DATE, "=", VERSION_DATE_VALUE); assertEquals(path, request.getPath()); assertEquals(serviceResponse, mockResponse); assertEquals(HttpMediaType.APPLICATION_JSON, request.getHeader(HttpHeaders.ACCEPT)); }