Search in sources :

Example 11 with Profile

use of com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile in project java-sdk by watson-developer-cloud.

the class PersonalityInsightsTest method testGetProfileWithEnglishText.

/**
 * Test get profile with English text.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void testGetProfileWithEnglishText() throws InterruptedException {
    final ProfileOptions options = new ProfileOptions.Builder().text(text).contentLanguage(ProfileOptions.ContentLanguage.EN).build();
    server.enqueue(jsonResponse(profile));
    final Profile profile = service.profile(options).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals(PROFILE_PATH + "?version=2016-10-19", request.getPath());
    assertEquals("POST", request.getMethod());
    assertEquals("en", request.getHeader(HttpHeaders.CONTENT_LANGUAGE));
    assertEquals(HttpMediaType.TEXT.toString(), request.getHeader(HttpHeaders.CONTENT_TYPE));
    assertEquals(text, request.getBody().readUtf8());
    assertNotNull(profile);
    assertEquals(this.profile, profile);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ProfileOptions(com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions) Profile(com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile) Test(org.junit.Test) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest)

Example 12 with Profile

use of com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile in project java-sdk by watson-developer-cloud.

the class PersonalityInsightsTest method testGetProfileWithSpanishText.

/**
 * Test get profile with spanish text.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void testGetProfileWithSpanishText() throws InterruptedException {
    final ProfileOptions options = new ProfileOptions.Builder().text(text).contentLanguage(ProfileOptions.ContentLanguage.ES).consumptionPreferences(true).rawScores(true).build();
    server.enqueue(jsonResponse(profile));
    final Profile profile = service.profile(options).execute();
    final RecordedRequest request = server.takeRequest();
    assertEquals(PROFILE_PATH + "?version=2016-10-19&raw_scores=true&consumption_preferences=true", request.getPath());
    assertEquals("POST", request.getMethod());
    assertEquals("es", request.getHeader(HttpHeaders.CONTENT_LANGUAGE));
    assertEquals(HttpMediaType.TEXT.toString(), request.getHeader(HttpHeaders.CONTENT_TYPE));
    assertEquals(text, request.getBody().readUtf8());
    assertNotNull(profile);
    assertEquals(profile, this.profile);
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) ProfileOptions(com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions) Profile(com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile) Test(org.junit.Test) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest)

Example 13 with Profile

use of com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile in project java-sdk by watson-developer-cloud.

the class PersonalityInsightsTest method testProfileBuilders.

/**
 * Test profile options builders.
 */
@Test
public void testProfileBuilders() {
    final ProfileOptions options = new ProfileOptions.Builder().html(text).contentLanguage(ProfileOptions.ContentLanguage.ES).acceptLanguage(ProfileOptions.AcceptLanguage.EN).build();
    final ProfileOptions newOptions = options.newBuilder().build();
    assertEquals(newOptions.body(), text);
    assertEquals(newOptions.contentLanguage(), ProfileOptions.ContentLanguage.ES);
    assertEquals(newOptions.acceptLanguage(), ProfileOptions.AcceptLanguage.EN);
}
Also used : ProfileOptions(com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions) Test(org.junit.Test) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest)

Aggregations

ProfileOptions (com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions)12 Test (org.junit.Test)11 Profile (com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile)10 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)7 File (java.io.File)5 FileInputStream (java.io.FileInputStream)5 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)4 Content (com.ibm.watson.developer_cloud.personality_insights.v3.model.Content)4 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)3 ContentItem (com.ibm.watson.developer_cloud.personality_insights.v3.model.ContentItem)2 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 PersonalityInsights (com.ibm.watson.developer_cloud.personality_insights.v3.PersonalityInsights)1 ConsumptionPreferences (com.ibm.watson.developer_cloud.personality_insights.v3.model.ConsumptionPreferences)1 Date (java.util.Date)1