Search in sources :

Example 11 with IamAuthenticator

use of com.ibm.cloud.sdk.core.security.IamAuthenticator in project java-sdk by watson-developer-cloud.

the class NaturalLanguageUnderstandingIT method setUp.

/**
 * Sets up the tests.
 *
 * @throws Exception the exception
 */
/*
   * (non-Javadoc)
   * @see com.ibm.watson.common.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    String apiKey = System.getenv("NATURAL_LANGUAGE_UNDERSTANDING_APIKEY");
    String serviceUrl = System.getenv("NATURAL_LANGUAGE_UNDERSTANDING_URL");
    if (apiKey == null) {
        apiKey = getProperty("natural_language_understanding.apikey");
        serviceUrl = getProperty("natural_language_understanding.url");
    }
    assertNotNull("NATURAL_LANGUAGE_UNDERSTANDING_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey);
    Authenticator authenticator = new IamAuthenticator(apiKey);
    service = new NaturalLanguageUnderstanding("2019-07-12", authenticator);
    service.setDefaultHeaders(getDefaultHeaders());
    service.setServiceUrl(serviceUrl);
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) Before(org.junit.Before)

Example 12 with IamAuthenticator

use of com.ibm.cloud.sdk.core.security.IamAuthenticator in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceIT method setup.

/**
 * Setup.
 *
 * @throws Exception the exception
 */
@Before
public void setup() throws Exception {
    super.setUp();
    String apiKey = System.getenv("DISCOVERY_APIKEY");
    String serviceUrl = System.getenv("DISCOVERY_URL");
    if (apiKey == null) {
        apiKey = getProperty("discovery.apikey");
        serviceUrl = getProperty("discovery.url");
    }
    Authenticator authenticator = new IamAuthenticator(apiKey);
    discovery = new Discovery("2019-04-30", authenticator);
    discovery.setServiceUrl(serviceUrl);
    discovery.setDefaultHeaders(getDefaultHeaders());
    uniqueName = UUID.randomUUID().toString();
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) BasicAuthenticator(com.ibm.cloud.sdk.core.security.BasicAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) BearerTokenAuthenticator(com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator) Before(org.junit.Before)

Example 13 with IamAuthenticator

use of com.ibm.cloud.sdk.core.security.IamAuthenticator in project java-sdk by watson-developer-cloud.

the class SpeechToTextIT method setUp.

/**
 * Sets up the tests.
 *
 * @throws Exception the exception
 */
/*
   * (non-Javadoc)
   *
   * @see com.ibm.watson.common.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    this.customizationId = System.getenv("SPEECH_TO_TEXT_CUSTOM_ID");
    this.acousticCustomizationId = System.getenv("SPEECH_TO_TEXT_ACOUSTIC_CUSTOM_ID");
    String apiKey = System.getenv("SPEECH_TO_TEXT_APIKEY");
    String serviceUrl = System.getenv("SPEECH_TO_TEXT_URL");
    if (apiKey == null) {
        apiKey = getProperty("speech_to_text.apikey");
        this.customizationId = getProperty("speech_to_text.customization_id");
        this.acousticCustomizationId = getProperty("speech_to_text.acoustic_customization_id");
        serviceUrl = getProperty("speech_to_text.url");
    }
    assertNotNull("SPEECH_TO_TEXT_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey);
    Authenticator authenticator = new IamAuthenticator(apiKey);
    service = new SpeechToText(authenticator);
    service.setServiceUrl(serviceUrl);
    service.setDefaultHeaders(getDefaultHeaders());
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) Before(org.junit.Before)

Example 14 with IamAuthenticator

use of com.ibm.cloud.sdk.core.security.IamAuthenticator in project java-sdk by watson-developer-cloud.

the class CustomizationsIT method setUp.

/*
   * (non-Javadoc)
   * @see com.ibm.watson.common.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    String apiKey = System.getenv("TEXT_TO_SPEECH_APIKEY");
    String serviceUrl = System.getenv("TEXT_TO_SPEECH_URL");
    if (apiKey == null) {
        apiKey = getProperty("text_to_speech.apikey");
        serviceUrl = getProperty("text_to_speech.url");
    }
    assertNotNull("TEXT_TO_SPEECH_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey);
    Authenticator authenticator = new IamAuthenticator(apiKey);
    service = new TextToSpeech(authenticator);
    service.setServiceUrl(serviceUrl);
    service.setDefaultHeaders(getDefaultHeaders());
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) Before(org.junit.Before)

Example 15 with IamAuthenticator

use of com.ibm.cloud.sdk.core.security.IamAuthenticator in project java-sdk by watson-developer-cloud.

the class TextToSpeechIT method setUp.

/**
 * Sets up the tests.
 *
 * @throws Exception the exception
 */
/*
   * (non-Javadoc)
   * @see com.ibm.watson.common.WatsonServiceTest#setUp()
   */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    String apiKey = System.getenv("TEXT_TO_SPEECH_APIKEY");
    String serviceUrl = System.getenv("TEXT_TO_SPEECH_URL");
    if (apiKey == null) {
        apiKey = getProperty("text_to_speech.apikey");
        serviceUrl = getProperty("text_to_speech.url");
    }
    assertNotNull("TEXT_TO_SPEECH_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey);
    Authenticator authenticator = new IamAuthenticator(apiKey);
    service = new TextToSpeech(authenticator);
    service.setServiceUrl(serviceUrl);
    service.setDefaultHeaders(getDefaultHeaders());
    voiceName = "en-US_MichaelVoice";
    byteArrayOutputStream = new ByteArrayOutputStream();
    returnedTimings = new ArrayList<>();
    returnedMarks = new ArrayList<>();
}
Also used : IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IamAuthenticator(com.ibm.cloud.sdk.core.security.IamAuthenticator) Authenticator(com.ibm.cloud.sdk.core.security.Authenticator) Before(org.junit.Before)

Aggregations

IamAuthenticator (com.ibm.cloud.sdk.core.security.IamAuthenticator)32 Authenticator (com.ibm.cloud.sdk.core.security.Authenticator)30 Before (org.junit.Before)15 SpeechRecognitionResults (com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults)5 File (java.io.File)4 Response (com.ibm.cloud.sdk.core.http.Response)2 MessageInput (com.ibm.watson.assistant.v1.model.MessageInput)2 MessageOptions (com.ibm.watson.assistant.v1.model.MessageOptions)2 MessageResponse (com.ibm.watson.assistant.v1.model.MessageResponse)2 TranslateOptions (com.ibm.watson.language_translator.v3.model.TranslateOptions)2 TranslationResult (com.ibm.watson.language_translator.v3.model.TranslationResult)2 RecognizeWithWebsocketsOptions (com.ibm.watson.speech_to_text.v1.model.RecognizeWithWebsocketsOptions)2 BaseRecognizeCallback (com.ibm.watson.speech_to_text.v1.websocket.BaseRecognizeCallback)2 ToneAnalysis (com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis)2 ToneOptions (com.ibm.watson.tone_analyzer.v3.model.ToneOptions)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 JsonObject (com.google.gson.JsonObject)1 HttpConfigOptions (com.ibm.cloud.sdk.core.http.HttpConfigOptions)1 ServiceCallback (com.ibm.cloud.sdk.core.http.ServiceCallback)1