use of com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis in project java-sdk by watson-developer-cloud.
the class ToneAnalyzerIT method testtoneFromHtml.
/**
* Test get tone from html.
*/
@Test
public void testtoneFromHtml() {
ToneOptions options = new ToneOptions.Builder().html(text).build();
ToneAnalysis tone = service.tone(options).execute();
assertToneAnalysis(tone);
}
use of com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis in project java-sdk by watson-developer-cloud.
the class ToneAnalyzerIT method testtoneFromText.
/**
* Test get tone from text.
*/
@Test
public void testtoneFromText() {
ToneOptions options = new ToneOptions.Builder().text(text).addTone(ToneOptions.Tone.EMOTION).addTone(ToneOptions.Tone.LANGUAGE).addTone(ToneOptions.Tone.SOCIAL).build();
ToneAnalysis tone = service.tone(options).execute();
assertToneAnalysis(tone);
}
use of com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis in project java-sdk by watson-developer-cloud.
the class ToneAnalyzerTest method testtones.
/**
* Test get tones.
*
* @throws InterruptedException the interrupted exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@Test
public void testtones() throws InterruptedException, IOException {
String text = "I know the times are difficult! Our sales have been " + "disappointing for the past three quarters for our data analytics " + "product suite. We have a competitive data analytics product " + "suite in the industry. But we need to do our job selling it! ";
ToneAnalysis mockResponse = loadFixture(FIXTURE, ToneAnalysis.class);
server.enqueue(jsonResponse(mockResponse));
server.enqueue(jsonResponse(mockResponse));
server.enqueue(jsonResponse(mockResponse));
// execute request
ToneOptions toneOptions = new ToneOptions.Builder().html(text).build();
ToneAnalysis serviceResponse = service.tone(toneOptions).execute();
// first request
RecordedRequest request = server.takeRequest();
String path = StringUtils.join(TONE_PATH, "?", VERSION_DATE, "=", VERSION_DATE_VALUE);
assertEquals(path, request.getPath());
assertNotNull(request.getHeader(HttpHeaders.AUTHORIZATION));
assertEquals(serviceResponse, mockResponse);
assertEquals(HttpMediaType.APPLICATION_JSON, request.getHeader(HttpHeaders.ACCEPT));
// second request
serviceResponse = service.tone(new ToneOptions.Builder().html(text).build()).execute();
request = server.takeRequest();
assertEquals(path, request.getPath());
assertTrue(request.getHeader(HttpHeaders.CONTENT_TYPE).startsWith(HttpMediaType.TEXT_HTML));
// third request
ToneOptions toneOptions1 = new ToneOptions.Builder().html(text).addTone(ToneOptions.Tone.EMOTION).addTone(ToneOptions.Tone.LANGUAGE).addTone(ToneOptions.Tone.SOCIAL).build();
serviceResponse = service.tone(toneOptions1).execute();
request = server.takeRequest();
path = path + "&tones=emotion,language,social";
assertEquals(path, request.getPath());
}
use of com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis in project java-sdk by watson-developer-cloud.
the class ToneAnalyzerTest method testReadme.
/**
* Test README.
*/
@Test
public void testReadme() throws InterruptedException, IOException {
ToneAnalyzer service = new ToneAnalyzer(VERSION_DATE);
service.setUsernameAndPassword("<username>", "<password>");
// exclude
service.setEndPoint(getMockWebServerUrl());
// exclude
ToneAnalysis mockResponse = loadFixture(FIXTURE, ToneAnalysis.class);
// exclude
server.enqueue(jsonResponse(mockResponse));
String text = "I know the times are difficult! Our sales have been " + "disappointing for the past three quarters for our data analytics " + "product suite. We have a competitive data analytics product " + "suite in the industry. But we need to do our job selling it! " + "We need to acknowledge and fix our sales challenges. " + "We can’t blame the economy for our lack of execution! " + "We are missing critical sales opportunities. " + "Our product is in no way inferior to the competitor products. " + "Our clients are hungry for analytical tools to improve their " + "business outcomes. Economy has nothing to do with it.";
// Call the service and get the tone
ToneOptions toneOptions = new ToneOptions.Builder().html(text).build();
ToneAnalysis tone = service.tone(toneOptions).execute();
System.out.println(tone);
}
Aggregations