Search in sources :

Example 1 with IdentifiableLanguages

use of com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguages in project java-sdk by watson-developer-cloud.

the class LanguageTranslator method listIdentifiableLanguages.

/**
 * List identifiable languages.
 *
 * Lists the languages that the service can identify. Returns the language code (for example, `en` for English or `es`
 * for Spanish) and name of each language.
 *
 * @param listIdentifiableLanguagesOptions the {@link ListIdentifiableLanguagesOptions} containing the options for the
 *          call
 * @return a {@link ServiceCall} with a response type of {@link IdentifiableLanguages}
 */
public ServiceCall<IdentifiableLanguages> listIdentifiableLanguages(ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptions) {
    String[] pathSegments = { "v2/identifiable_languages" };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
    if (listIdentifiableLanguagesOptions != null) {
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IdentifiableLanguages.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) IdentifiableLanguages(com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguages)

Example 2 with IdentifiableLanguages

use of com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguages in project java-sdk by watson-developer-cloud.

the class LanguageTranslatorTest method testGetIdentifiableLanguages.

/**
 * Test Get Identifiable languages.
 *
 * @throws InterruptedException the interrupted exception
 */
@Test
public void testGetIdentifiableLanguages() throws InterruptedException {
    server.enqueue(jsonResponse(identifiableLanguages));
    final List<IdentifiableLanguage> languages = service.listIdentifiableLanguages().execute().getLanguages();
    final RecordedRequest request = server.takeRequest();
    assertEquals(IDENTIFIABLE_LANGUAGES_PATH, request.getPath());
    assertEquals(GSON.toJson(languages), GSON.toJson(identifiableLanguages.get("languages")));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) IdentifiableLanguage(com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguage) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 3 with IdentifiableLanguages

use of com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguages in project java-sdk by watson-developer-cloud.

the class LanguageTranslatorTest method setUp.

/*
   * (non-Javadoc)
   * @see com.ibm.watson.developercloud.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    service = new LanguageTranslator();
    service.setApiKey("");
    service.setEndPoint(getMockWebServerUrl());
    // fixtures
    String jsonString = getStringFromInputStream(new FileInputStream(RESOURCE + "identifiable_languages.json"));
    identifiableLanguages = GSON.fromJson(jsonString, TYPE_IDENTIFIED_LANGUAGES);
    model = loadFixture(RESOURCE + "model.json", TranslationModel.class);
    models = loadFixture(RESOURCE + "models.json", TranslationModels.class);
    identifiedLanguages = loadFixture(RESOURCE + "identify_response.json", IdentifiedLanguages.class);
    singleTranslation = loadFixture(RESOURCE + "single_translation.json", TranslationResult.class);
    multipleTranslations = loadFixture(RESOURCE + "multiple_translations.json", TranslationResult.class);
}
Also used : TranslationModel(com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel) IdentifiedLanguages(com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiedLanguages) TranslationModels(com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModels) TranslationResult(com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationResult) FileInputStream(java.io.FileInputStream) Before(org.junit.Before)

Aggregations

WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)1 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)1 IdentifiableLanguage (com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguage)1 IdentifiableLanguages (com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguages)1 IdentifiedLanguages (com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiedLanguages)1 TranslationModel (com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel)1 TranslationModels (com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModels)1 TranslationResult (com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationResult)1 FileInputStream (java.io.FileInputStream)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Before (org.junit.Before)1 Test (org.junit.Test)1