Search in sources :

Example 16 with RestClient

use of com.microsoft.rest.RestClient in project autorest.java by Azure.

the class LROsTests method setup.

@BeforeClass
public static void setup() {
    RestClient restClient = new RestClient.Builder().withBaseUrl("http://localhost:3000").withSerializerAdapter(new AzureJacksonAdapter()).withResponseBuilderFactory(new AzureResponseBuilder.Factory()).build();
    client = new AutoRestLongRunningOperationTestServiceImpl(restClient);
    client.getAzureClient().setLongRunningOperationRetryTimeout(0);
}
Also used : AzureResponseBuilder(com.microsoft.azure.AzureResponseBuilder) AzureJacksonAdapter(com.microsoft.azure.serializer.AzureJacksonAdapter) RestClient(com.microsoft.rest.RestClient) AutoRestLongRunningOperationTestServiceImpl(fixtures.lro.implementation.AutoRestLongRunningOperationTestServiceImpl) BeforeClass(org.junit.BeforeClass)

Example 17 with RestClient

use of com.microsoft.rest.RestClient in project azure-tools-for-java by Microsoft.

the class IntegrationTestBase method createRestClient.

private RestClient createRestClient(ApplicationTokenCredentials credentials) throws Exception {
    RestClient restClient;
    if (IS_MOCKED) {
        credentials = new TestCredentials();
        restClient = new RestClient.Builder().withBaseUrl(MOCK_URI + "/").withSerializerAdapter(new AzureJacksonAdapter()).withResponseBuilderFactory(new AzureResponseBuilder.Factory()).withCredentials(credentials).withLogLevel(LogLevel.BODY_AND_HEADERS).withInterceptor(interceptor).build();
        return restClient;
    } else {
        restClient = new RestClient.Builder().withBaseUrl(GLOBAL_ENDPOINT).withSerializerAdapter(new AzureJacksonAdapter()).withResponseBuilderFactory(new AzureResponseBuilder.Factory()).withCredentials(credentials).withLogLevel(LogLevel.BODY_AND_HEADERS).withInterceptor(interceptor).build();
        return restClient;
    }
}
Also used : AzureResponseBuilder(com.microsoft.azure.AzureResponseBuilder) MappingBuilder(com.github.tomakehurst.wiremock.client.MappingBuilder) ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) AzureJacksonAdapter(com.microsoft.azure.serializer.AzureJacksonAdapter) RestClient(com.microsoft.rest.RestClient)

Example 18 with RestClient

use of com.microsoft.rest.RestClient in project azure-tools-for-java by Microsoft.

the class IntegrationTestBase method createRestClient.

private RestClient createRestClient(ApplicationTokenCredentials credentials) {
    final RestClient client;
    ApplicationTokenCredentials cred = credentials;
    if (IS_MOCKED) {
        cred = new TestCredentials();
        client = new RestClient.Builder().withBaseUrl(MOCK_URI + "/").withSerializerAdapter(new AzureJacksonAdapter()).withResponseBuilderFactory(new AzureResponseBuilder.Factory()).withCredentials(cred).withLogLevel(LogLevel.BODY_AND_HEADERS).withInterceptor(interceptor).build();
    } else {
        client = new RestClient.Builder().withBaseUrl(GLOBAL_ENDPOINT).withSerializerAdapter(new AzureJacksonAdapter()).withResponseBuilderFactory(new AzureResponseBuilder.Factory()).withCredentials(cred).withLogLevel(LogLevel.BODY_AND_HEADERS).withInterceptor(interceptor).build();
    }
    return client;
}
Also used : AzureResponseBuilder(com.microsoft.azure.AzureResponseBuilder) MappingBuilder(com.github.tomakehurst.wiremock.client.MappingBuilder) ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) AzureJacksonAdapter(com.microsoft.azure.serializer.AzureJacksonAdapter) RestClient(com.microsoft.rest.RestClient) ApplicationTokenCredentials(com.microsoft.azure.credentials.ApplicationTokenCredentials)

Aggregations

RestClient (com.microsoft.rest.RestClient)18 AzureJacksonAdapter (com.microsoft.azure.serializer.AzureJacksonAdapter)15 AzureResponseBuilder (com.microsoft.azure.AzureResponseBuilder)11 ApplicationTokenCredentials (com.microsoft.azure.credentials.ApplicationTokenCredentials)7 File (java.io.File)6 Azure (com.microsoft.azure.management.Azure)4 RequestIdHeaderInterceptor (com.microsoft.rest.interceptors.RequestIdHeaderInterceptor)4 BeforeClass (org.junit.BeforeClass)4 IOException (java.io.IOException)3 Response (okhttp3.Response)3 MappingBuilder (com.github.tomakehurst.wiremock.client.MappingBuilder)2 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)2 AzureEnvironment (com.microsoft.azure.AzureEnvironment)2 AzureTokenCredentials (com.microsoft.azure.credentials.AzureTokenCredentials)2 TokenCredentials (com.microsoft.rest.credentials.TokenCredentials)2 AutoRestAzureSpecialParametersTestClientImpl (fixtures.azurespecials.implementation.AutoRestAzureSpecialParametersTestClientImpl)2 Interceptor (okhttp3.Interceptor)2 Request (okhttp3.Request)2 Test (org.junit.Test)2 CacheBuilder (com.google.common.cache.CacheBuilder)1