use of com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions 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);
}
use of com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions 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);
}
use of com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions 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);
}
Aggregations