Search in sources :

Example 1 with HttpConfigOptions

use of com.ibm.cloud.sdk.core.http.HttpConfigOptions in project cloudant-java-sdk by IBM.

the class CouchDbSessionAuthenticatorTest method setHttpConfigOptions.

/**
 * Test that options set on the client apply to the token request
 */
@Test
void setHttpConfigOptions() {
    CouchDbSessionAuthenticator a = Mockito.spy(testAuthenticator);
    TestCloudantService testCloudantService = new TestCloudantService("test", a);
    HttpConfigOptions options = new HttpConfigOptions.Builder().build();
    testCloudantService.configureClient(options);
    // Verify the setter was called
    Mockito.verify(a).setHttpConfigOptions(options);
}
Also used : TestCloudantService(com.ibm.cloud.cloudant.internal.TestCloudantService) HttpConfigOptions(com.ibm.cloud.sdk.core.http.HttpConfigOptions) Test(org.testng.annotations.Test)

Example 2 with HttpConfigOptions

use of com.ibm.cloud.sdk.core.http.HttpConfigOptions in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceIT method testGetAutocompletion.

/**
 * This only works on a Cloud Pak for Data instance, so ignoring to just run manually.
 */
@Test
@Ignore
public void testGetAutocompletion() {
    // fill in
    Authenticator authenticator = new BearerTokenAuthenticator("");
    Discovery service = new Discovery("2019-10-03", authenticator);
    service.setServiceUrl("");
    HttpConfigOptions configOptions = new HttpConfigOptions.Builder().disableSslVerification(true).build();
    service.configureClient(configOptions);
    GetAutocompletionOptions options = new GetAutocompletionOptions.Builder().environmentId(// fill in
    "").collectionId(// fill in
    "").prefix("Ba").count(10L).build();
    Completions response = service.getAutocompletion(options).execute().getResult();
// System.out.println(response);
}
Also used : HttpConfigOptions(com.ibm.cloud.sdk.core.http.HttpConfigOptions) BearerTokenAuthenticator(com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator) 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) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 3 with HttpConfigOptions

use of com.ibm.cloud.sdk.core.http.HttpConfigOptions in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceIT method testQueryWithSpellingSuggestions.

/**
 * This only works on a Cloud Pak for Data instance, so ignoring to just run manually.
 */
@Test
@Ignore
public void testQueryWithSpellingSuggestions() {
    // fill in
    Authenticator authenticator = new BearerTokenAuthenticator("");
    Discovery service = new Discovery("2019-10-03", authenticator);
    service.setServiceUrl("");
    HttpConfigOptions configOptions = new HttpConfigOptions.Builder().disableSslVerification(true).build();
    service.configureClient(configOptions);
    QueryOptions options = new QueryOptions.Builder().naturalLanguageQuery("cluod").spellingSuggestions(true).environmentId(// fill in
    "").collectionId(// fill in
    "").build();
    QueryResponse response = service.query(options).execute().getResult();
// System.out.println(response);
}
Also used : HttpConfigOptions(com.ibm.cloud.sdk.core.http.HttpConfigOptions) BearerTokenAuthenticator(com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator) 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) Ignore(org.junit.Ignore) WatsonServiceTest(com.ibm.watson.common.WatsonServiceTest) Test(org.junit.Test)

Example 4 with HttpConfigOptions

use of com.ibm.cloud.sdk.core.http.HttpConfigOptions in project java-sdk by watson-developer-cloud.

the class DiscoveryIT 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("DISCOVERY_V2_APIKEY");
    String serviceUrl = System.getenv("DISCOVERY_V2_URL");
    if (apiKey == null) {
        apiKey = getProperty("discovery_v2.apikey");
        serviceUrl = getProperty("discovery_v2.url");
    }
    assertNotNull("DISCOVERY_V2_APIKEY is not defined and config.properties doesn't have valid credentials.", apiKey);
    Authenticator authenticator = new IamAuthenticator(apiKey);
    service = new Discovery(VERSION, authenticator);
    service.setDefaultHeaders(getDefaultHeaders());
    service.setServiceUrl(serviceUrl);
    HttpConfigOptions configOptions = new HttpConfigOptions.Builder().disableSslVerification(true).build();
    service.configureClient(configOptions);
}
Also used : HttpConfigOptions(com.ibm.cloud.sdk.core.http.HttpConfigOptions) 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)

Aggregations

HttpConfigOptions (com.ibm.cloud.sdk.core.http.HttpConfigOptions)4 Authenticator (com.ibm.cloud.sdk.core.security.Authenticator)3 IamAuthenticator (com.ibm.cloud.sdk.core.security.IamAuthenticator)3 BasicAuthenticator (com.ibm.cloud.sdk.core.security.BasicAuthenticator)2 BearerTokenAuthenticator (com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator)2 WatsonServiceTest (com.ibm.watson.common.WatsonServiceTest)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 TestCloudantService (com.ibm.cloud.cloudant.internal.TestCloudantService)1 Before (org.junit.Before)1 Test (org.testng.annotations.Test)1