Search in sources :

Example 16 with ChatErrorResponseException

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

the class ChatThreadAsyncClientTest method cannotAddSingleParticipantWithResponseWithInvalidUser.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void cannotAddSingleParticipantWithResponseWithInvalidUser(HttpClient httpClient) throws InterruptedException, ExecutionException {
    setupTest(httpClient);
    ExecutionException executionException = assertThrows(ExecutionException.class, () -> {
        this.chatThreadClient.addParticipantWithResponse(generateParticipant("8:acs:invalidUserId", "name"), 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 : 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 17 with ChatErrorResponseException

use of com.azure.android.communication.chat.models.ChatErrorResponseException 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 18 with ChatErrorResponseException

use of com.azure.android.communication.chat.models.ChatErrorResponseException 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)

Example 19 with ChatErrorResponseException

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

the class ChatAsyncClientTest method cannotDeleteChatThreadWithInvalidThreadId.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void cannotDeleteChatThreadWithInvalidThreadId(HttpClient httpClient) {
    setupTest(httpClient);
    final String invalidChatThreadId = "invalid_chat_thread_id";
    ExecutionException executionException = assertThrows(ExecutionException.class, () -> {
        client.deleteChatThread(invalidChatThreadId).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 : 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

ChatErrorResponseException (com.azure.android.communication.chat.models.ChatErrorResponseException)19 ExecutionException (java.util.concurrent.ExecutionException)18 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)18 MethodSource (org.junit.jupiter.params.provider.MethodSource)18 ChatParticipant (com.azure.android.communication.chat.models.ChatParticipant)2 CreateChatThreadOptions (com.azure.android.communication.chat.models.CreateChatThreadOptions)2 UpdateChatMessageOptions (com.azure.android.communication.chat.models.UpdateChatMessageOptions)2 CommunicationUserIdentifier (com.azure.android.communication.common.CommunicationUserIdentifier)2 CommunicationErrorResponseException (com.azure.android.communication.chat.implementation.models.CommunicationErrorResponseException)1 ChatError (com.azure.android.communication.chat.models.ChatError)1 ChatThreadProperties (com.azure.android.communication.chat.models.ChatThreadProperties)1 Response (com.azure.android.core.rest.Response)1