use of com.ibm.watson.developer_cloud.personality_insights.v3.model.ConsumptionPreferences in project java-sdk by watson-developer-cloud.
the class PersonalityInsightsIT method getProfileWithContentItems.
/**
* Gets the profile from a list of content items.
*
* @throws Exception the exception
*/
@Test
public void getProfileWithContentItems() throws Exception {
final Content content = loadFixture(RESOURCE + "v3-contentItems.json", Content.class);
ProfileOptions options = new ProfileOptions.Builder().content(content).consumptionPreferences(true).rawScores(true).build();
Profile profile = service.profile(options).execute();
assertProfile(profile);
}
use of com.ibm.watson.developer_cloud.personality_insights.v3.model.ConsumptionPreferences in project java-sdk by watson-developer-cloud.
the class PersonalityInsightsIT method getProfileWithASingleSpanishContentItem.
/**
* Gets the profile from a single content item in Spanish.
*
* @throws Exception the exception
*/
@Test
public void getProfileWithASingleSpanishContentItem() throws Exception {
File file = new File(RESOURCE + "es.txt");
String englishText = getStringFromInputStream(new FileInputStream(file));
ContentItem cItem = new ContentItem.Builder(englishText).language(ContentItem.Language.ES).build();
Content content = new Content.Builder().contentItems(Arrays.asList(cItem)).build();
ProfileOptions options = new ProfileOptions.Builder().content(content).consumptionPreferences(true).rawScores(true).build();
Profile profile = service.profile(options).execute();
assertProfile(profile);
}
use of com.ibm.watson.developer_cloud.personality_insights.v3.model.ConsumptionPreferences in project java-sdk by watson-developer-cloud.
the class PersonalityInsightsIT method getProfileWithASingleContentItem.
/**
* Gets the profile from a single content item.
*
* @throws Exception the exception
*/
@Test
public void getProfileWithASingleContentItem() throws Exception {
File file = new File(RESOURCE + "en.txt");
String englishText = getStringFromInputStream(new FileInputStream(file));
Long now = new Date().getTime();
ContentItem cItem = new ContentItem.Builder(englishText).language(ContentItem.Language.EN).contenttype("text/plain").created(now).updated(now).id(UUID.randomUUID().toString()).forward(false).reply(false).parentid(null).build();
Content content = new Content.Builder(Arrays.asList(cItem)).build();
ProfileOptions options = new ProfileOptions.Builder().content(content).consumptionPreferences(true).acceptLanguage(ProfileOptions.AcceptLanguage.EN).rawScores(true).build();
Profile profile = service.profile(options).execute();
assertProfile(profile);
Assert.assertTrue(profile.getValues().size() > 0);
Assert.assertNotNull(profile.getValues().get(0).getCategory());
Assert.assertNotNull(profile.getValues().get(0).getName());
Assert.assertNotNull(profile.getValues().get(0).getTraitId());
// Assert.assertNotNull(profile.getValues().get(0).getChildren());
Assert.assertNotNull(profile.getValues().get(0).getPercentile());
Assert.assertNotNull(profile.getValues().get(0).getRawScore());
Assert.assertNotNull(profile.getBehavior());
Assert.assertTrue(profile.getBehavior().size() > 0);
Assert.assertNotNull(profile.getBehavior().get(0).getCategory());
Assert.assertNotNull(profile.getBehavior().get(0).getName());
Assert.assertNotNull(profile.getBehavior().get(0).getTraitId());
Assert.assertNotNull(profile.getBehavior().get(0).getPercentage());
Assert.assertTrue(profile.getConsumptionPreferences().size() > 0);
Assert.assertNotNull(profile.getConsumptionPreferences().get(0).getName());
Assert.assertNotNull(profile.getConsumptionPreferences().get(0).getConsumptionPreferenceCategoryId());
Assert.assertNotNull(profile.getConsumptionPreferences().get(0).getConsumptionPreferences());
Assert.assertTrue(profile.getConsumptionPreferences().get(0).getConsumptionPreferences().size() > 0);
ConsumptionPreferences preference = profile.getConsumptionPreferences().get(0).getConsumptionPreferences().get(0);
Assert.assertNotNull(preference.getConsumptionPreferenceId());
Assert.assertNotNull(preference.getName());
Assert.assertNotNull(preference.getScore());
}
use of com.ibm.watson.developer_cloud.personality_insights.v3.model.ConsumptionPreferences 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);
}
Aggregations