Search in sources :

Example 51 with Response

use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.

the class ChatAsyncImplClientTest method canRepeatCreateThread.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canRepeatCreateThread(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    UUID uuid = UUID.randomUUID();
    final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadMember.getId(), secondThreadMember.getId());
    CompletableFuture<Response<CreateChatThreadResult>> completableFuture1 = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, uuid.toString());
    assertNotNull(completableFuture1);
    Response<CreateChatThreadResult> response1 = completableFuture1.get();
    assertNotNull(response1);
    CreateChatThreadResult result1 = response1.getValue();
    assertNotNull(result1);
    assertNotNull(result1.getChatThread());
    assertNotNull(result1.getChatThread().getId());
    String expectedThreadId = response1.getValue().getChatThread().getId();
    CompletableFuture<Response<CreateChatThreadResult>> completableFuture2 = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, uuid.toString());
    assertNotNull(completableFuture2);
    Response<CreateChatThreadResult> response2 = completableFuture2.get();
    assertNotNull(response2);
    CreateChatThreadResult result2 = response2.getValue();
    assertNotNull(result2);
    assertNotNull(result2.getChatThread());
    assertNotNull(result2.getChatThread().getId());
    assertEquals(expectedThreadId, result2.getChatThread().getId());
    CompletableFuture<Response<CreateChatThreadResult>> completableFuture3 = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, UUID.randomUUID().toString());
    assertNotNull(completableFuture3);
    Response<CreateChatThreadResult> response3 = completableFuture3.get();
    assertNotNull(response3);
    CreateChatThreadResult result3 = response3.getValue();
    assertNotNull(result3);
    assertNotNull(result3.getChatThread());
    assertNotNull(result3.getChatThread().getId());
    assertNotEquals(expectedThreadId, result3.getChatThread().getId());
}
Also used : Response(com.azure.android.core.rest.Response) PagedResponse(com.azure.android.core.rest.util.paging.PagedResponse) CreateChatThreadResult(com.azure.android.communication.chat.implementation.models.CreateChatThreadResult) UUID(java.util.UUID) CreateChatThreadOptions(com.azure.android.communication.chat.implementation.models.CreateChatThreadOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 52 with Response

use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.

the class ChatAsyncImplClientTest method canDeleteChatThreadWithResponse.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canDeleteChatThreadWithResponse(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadMember.getId(), secondThreadMember.getId());
    CompletableFuture<Response<CreateChatThreadResult>> completableFuture1 = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, null);
    assertNotNull(completableFuture1);
    Response<CreateChatThreadResult> response1 = completableFuture1.get();
    assertNotNull(response1);
    CreateChatThreadResult result1 = response1.getValue();
    assertNotNull(result1);
    assertNotNull(result1.getChatThread());
    assertNotNull(result1.getChatThread().getId());
    CompletableFuture<Response<Void>> completableFuture2 = this.client.getChatClient().deleteChatThreadWithResponseAsync(result1.getChatThread().getId());
    assertNotNull(completableFuture2);
    Response<Void> response2 = completableFuture2.get();
    assertNotNull(response2);
    Void result2 = response2.getValue();
    assertNull(result2);
}
Also used : Response(com.azure.android.core.rest.Response) PagedResponse(com.azure.android.core.rest.util.paging.PagedResponse) CreateChatThreadResult(com.azure.android.communication.chat.implementation.models.CreateChatThreadResult) CreateChatThreadOptions(com.azure.android.communication.chat.implementation.models.CreateChatThreadOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 53 with Response

use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.

the class ChatAsyncImplClientTest method canCreateThreadWithResponse.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canCreateThreadWithResponse(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadMember.getId(), secondThreadMember.getId());
    CompletableFuture<Response<CreateChatThreadResult>> completableFuture = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, null);
    assertNotNull(completableFuture);
    Response<CreateChatThreadResult> response = completableFuture.get();
    assertNotNull(response);
    CreateChatThreadResult result = response.getValue();
    assertNotNull(result);
    assertNotNull(result.getChatThread());
    assertNotNull(result.getChatThread().getId());
}
Also used : Response(com.azure.android.core.rest.Response) PagedResponse(com.azure.android.core.rest.util.paging.PagedResponse) CreateChatThreadResult(com.azure.android.communication.chat.implementation.models.CreateChatThreadResult) CreateChatThreadOptions(com.azure.android.communication.chat.implementation.models.CreateChatThreadOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 54 with Response

use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.

the class RestProxyTests method service19PutWithHeaderApplicationOctetStreamContentTypeAndByteArrayBodyWithEmptyBody.

@Test
public void service19PutWithHeaderApplicationOctetStreamContentTypeAndByteArrayBodyWithEmptyBody() {
    CountDownLatch latch = new CountDownLatch(1);
    CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
    createService(Service19.class).putWithHeaderApplicationOctetStreamContentTypeAndByteArrayBody(new byte[0], new Callback<Response<HttpBinJSON>>() {

        @Override
        public void onSuccess(Response<HttpBinJSON> response) {
            cbResult.response = response;
            latch.countDown();
        }

        @Override
        public void onFailure(Throwable error) {
            cbResult.error = error;
            latch.countDown();
        }
    });
    awaitOnLatch(latch, "service19PutWithHeaderApplicationOctetStreamContentTypeAndByteArrayBodyWithEmptyBody");
    if (cbResult.error != null) {
        Assertions.fail(cbResult.error);
    } else {
        final Response<HttpBinJSON> response = cbResult.response;
        HttpBinJSON json = response.getValue();
        Assertions.assertNotNull(json);
        assertEquals("", json.data());
    }
}
Also used : Response(com.azure.android.core.rest.Response) StreamResponse(com.azure.android.core.rest.StreamResponse) CountDownLatch(java.util.concurrent.CountDownLatch) HttpBinJSON(com.azure.android.core.test.implementation.entities.HttpBinJSON) Test(org.junit.jupiter.api.Test)

Example 55 with Response

use of com.azure.android.core.rest.Response in project azure-sdk-for-android by Azure.

the class RestProxyTests method service19PutWithHeaderApplicationOctetStreamContentTypeAndStringBodyWithNullBody.

@Test
public void service19PutWithHeaderApplicationOctetStreamContentTypeAndStringBodyWithNullBody() {
    CountDownLatch latch = new CountDownLatch(1);
    CallbackResult<HttpBinJSON> cbResult = new CallbackResult<>();
    createService(Service19.class).putWithHeaderApplicationOctetStreamContentTypeAndStringBody(null, new Callback<Response<HttpBinJSON>>() {

        @Override
        public void onSuccess(Response<HttpBinJSON> response) {
            cbResult.response = response;
            latch.countDown();
        }

        @Override
        public void onFailure(Throwable error) {
            cbResult.error = error;
            latch.countDown();
        }
    });
    awaitOnLatch(latch, "service19PutWithHeaderApplicationOctetStreamContentTypeAndStringBodyWithNullBody");
    if (cbResult.error != null) {
        Assertions.fail(cbResult.error);
    } else {
        final Response<HttpBinJSON> response = cbResult.response;
        HttpBinJSON json = response.getValue();
        Assertions.assertNotNull(json);
        assertEquals("", json.data());
    }
}
Also used : Response(com.azure.android.core.rest.Response) StreamResponse(com.azure.android.core.rest.StreamResponse) CountDownLatch(java.util.concurrent.CountDownLatch) HttpBinJSON(com.azure.android.core.test.implementation.entities.HttpBinJSON) Test(org.junit.jupiter.api.Test)

Aggregations

Response (com.azure.android.core.rest.Response)105 StreamResponse (com.azure.android.core.rest.StreamResponse)88 CountDownLatch (java.util.concurrent.CountDownLatch)88 Test (org.junit.jupiter.api.Test)88 HttpBinJSON (com.azure.android.core.test.implementation.entities.HttpBinJSON)67 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)17 MethodSource (org.junit.jupiter.params.provider.MethodSource)17 PagedResponse (com.azure.android.core.rest.util.paging.PagedResponse)10 CreateChatThreadOptions (com.azure.android.communication.chat.implementation.models.CreateChatThreadOptions)5 CreateChatThreadResult (com.azure.android.communication.chat.implementation.models.CreateChatThreadResult)5 CreateChatThreadOptions (com.azure.android.communication.chat.models.CreateChatThreadOptions)5 CreateChatThreadResult (com.azure.android.communication.chat.models.CreateChatThreadResult)5 HttpHeaders (com.azure.android.core.http.HttpHeaders)5 HttpResponseException (com.azure.android.core.http.exception.HttpResponseException)5 SendChatMessageOptions (com.azure.android.communication.chat.models.SendChatMessageOptions)4 MyRestException (com.azure.android.core.test.MyRestException)3 LinkedHashMap (java.util.LinkedHashMap)3 UUID (java.util.UUID)3 ChatMessage (com.azure.android.communication.chat.models.ChatMessage)2 SendChatMessageResult (com.azure.android.communication.chat.models.SendChatMessageResult)2