Search in sources :

Example 6 with UpdateChatMessageOptions

use of com.azure.android.communication.chat.models.UpdateChatMessageOptions in project azure-sdk-for-android by Azure.

the class ChatThreadAsyncClientTest method cannotUpdateMessageWithInvalidId.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void cannotUpdateMessageWithInvalidId(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    UpdateChatMessageOptions updateMessageRequest = super.updateMessageOptions();
    ExecutionException executionException = assertThrows(ExecutionException.class, () -> {
        this.chatThreadClient.updateMessage("invalid_chat_message_id", updateMessageRequest).get();
    });
    Throwable cause = executionException.getCause();
    assertNotNull(cause);
    assertTrue(cause instanceof ChatErrorResponseException);
    ChatErrorResponseException exception = (ChatErrorResponseException) cause;
    assertNotNull(exception.getResponse());
    assertEquals(400, exception.getResponse().getStatusCode());
}
Also used : UpdateChatMessageOptions(com.azure.android.communication.chat.models.UpdateChatMessageOptions) ChatErrorResponseException(com.azure.android.communication.chat.models.ChatErrorResponseException) ExecutionException(java.util.concurrent.ExecutionException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 7 with UpdateChatMessageOptions

use of com.azure.android.communication.chat.models.UpdateChatMessageOptions in project azure-sdk-for-android by Azure.

the class ChatThreadAsyncClientTest method cannotUpdateMessageWithResponseWithInvalidId.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void cannotUpdateMessageWithResponseWithInvalidId(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    UpdateChatMessageOptions updateMessageRequest = super.updateMessageOptions();
    ExecutionException executionException = assertThrows(ExecutionException.class, () -> {
        this.chatThreadClient.updateMessageWithResponse("invalid_chat_message_id", updateMessageRequest, null).get();
    });
    Throwable cause = executionException.getCause();
    assertNotNull(cause);
    assertTrue(cause instanceof ChatErrorResponseException);
    ChatErrorResponseException exception = (ChatErrorResponseException) cause;
    assertNotNull(exception.getResponse());
    assertEquals(400, exception.getResponse().getStatusCode());
}
Also used : UpdateChatMessageOptions(com.azure.android.communication.chat.models.UpdateChatMessageOptions) ChatErrorResponseException(com.azure.android.communication.chat.models.ChatErrorResponseException) ExecutionException(java.util.concurrent.ExecutionException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

UpdateChatMessageOptions (com.azure.android.communication.chat.models.UpdateChatMessageOptions)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 MethodSource (org.junit.jupiter.params.provider.MethodSource)6 ExecutionException (java.util.concurrent.ExecutionException)4 ChatErrorResponseException (com.azure.android.communication.chat.models.ChatErrorResponseException)2 ChatMessage (com.azure.android.communication.chat.models.ChatMessage)2 SendChatMessageOptions (com.azure.android.communication.chat.models.SendChatMessageOptions)2 SendChatMessageResult (com.azure.android.communication.chat.models.SendChatMessageResult)1 Response (com.azure.android.core.rest.Response)1