PersonalityInsights extends BaseService { public ServiceCall<Profile> profile(ProfileOptions profileOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(profileOptions, "profileOptions cannot be null"); String[] pathSegments = {"v3/profile"}; RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); builder.query("version", versionDate); Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("personality_insights", "v3", "profile"); for (Entry<String, String> header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); if (profileOptions.contentType() != null) { builder.header("Content-Type", profileOptions.contentType()); } if (profileOptions.contentLanguage() != null) { builder.header("Content-Language", profileOptions.contentLanguage()); } if (profileOptions.acceptLanguage() != null) { builder.header("Accept-Language", profileOptions.acceptLanguage()); } if (profileOptions.rawScores() != null) { builder.query("raw_scores", String.valueOf(profileOptions.rawScores())); } if (profileOptions.csvHeaders() != null) { builder.query("csv_headers", String.valueOf(profileOptions.csvHeaders())); } if (profileOptions.consumptionPreferences() != null) { builder.query( "consumption_preferences", String.valueOf(profileOptions.consumptionPreferences())); } builder.bodyContent( profileOptions.contentType(), profileOptions.content(), null, profileOptions.body()); ResponseConverter<Profile> responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken<Profile>() {}.getType()); return createServiceCall(builder.build(), responseConverter); } PersonalityInsights(String versionDate);  PersonalityInsights(String versionDate, Authenticator authenticator);  PersonalityInsights(String versionDate, String serviceName);  PersonalityInsights(String versionDate, String serviceName, Authenticator authenticator); ServiceCall<Profile> profile(ProfileOptions profileOptions); ServiceCall<InputStream> profileAsCsv(ProfileOptions profileOptions);  }
@Test public void testGetProfileWithContent() throws InterruptedException { final Content content = new Content.Builder().addContentItem(contentItem).build(); final ProfileOptions options = new ProfileOptions.Builder().content(content).build(); server.enqueue(jsonResponse(profile)); final Profile profile = service.profile(options).execute().getResult(); final RecordedRequest request = server.takeRequest(); assertEquals(PROFILE_PATH + "?version=2017-10-13", request.getPath()); assertEquals("POST", request.getMethod()); assertNotNull(profile); assertEquals(this.profile, profile); }
@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().getResult(); final RecordedRequest request = server.takeRequest(); assertEquals(PROFILE_PATH + "?version=2017-10-13", request.getPath()); assertEquals("POST", request.getMethod()); assertEquals("en", request.getHeader(HttpHeaders.CONTENT_LANGUAGE)); assertEquals(HttpMediaType.TEXT_PLAIN, request.getHeader(HttpHeaders.CONTENT_TYPE)); assertEquals(text, request.getBody().readUtf8()); assertNotNull(profile); assertEquals(this.profile, profile); }
@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().getResult(); final RecordedRequest request = server.takeRequest(); assertEquals( PROFILE_PATH + "?version=2017-10-13&raw_scores=true&consumption_preferences=true", request.getPath()); assertEquals("POST", request.getMethod()); assertEquals("es", request.getHeader(HttpHeaders.CONTENT_LANGUAGE)); assertEquals(HttpMediaType.TEXT_PLAIN, request.getHeader(HttpHeaders.CONTENT_TYPE)); assertEquals(text, request.getBody().readUtf8()); assertNotNull(profile); assertEquals(profile, this.profile); }