use of com.azure.android.communication.chat.models.ChatErrorResponseException in project azure-sdk-for-android by Azure.
the class ChatAsyncClientTest method cannotCreateThreadWithInvalidUser.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void cannotCreateThreadWithInvalidUser(HttpClient httpClient) {
setupTest(httpClient);
final CreateChatThreadOptions threadRequest = createThreadOptions("8:acs:invalidUserId", secondThreadParticipant.getId());
ExecutionException executionException = assertThrows(ExecutionException.class, () -> {
client.createChatThread(threadRequest).get();
});
Throwable cause = executionException.getCause();
assertNotNull(cause);
assertTrue(cause instanceof ChatErrorResponseException);
ChatErrorResponseException exception = (ChatErrorResponseException) cause;
assertNotNull(exception.getResponse());
assertEquals(400, exception.getResponse().getStatusCode());
}
use of com.azure.android.communication.chat.models.ChatErrorResponseException in project azure-sdk-for-android by Azure.
the class ChatThreadAsyncClientTest method cannotAddParticipantsWithInvalidUser.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void cannotAddParticipantsWithInvalidUser(HttpClient httpClient) throws InterruptedException, ExecutionException {
setupTest(httpClient);
Iterable<ChatParticipant> participants = addParticipants("8:acs:invalidUserId", this.secondThreadParticipant.getId());
ExecutionException executionException = assertThrows(ExecutionException.class, () -> {
this.chatThreadClient.addParticipants(participants).get();
});
Throwable cause = executionException.getCause();
assertNotNull(cause);
assertTrue(cause instanceof ChatErrorResponseException);
ChatErrorResponseException exception = (ChatErrorResponseException) cause;
assertNotNull(exception.getResponse());
assertEquals(400, exception.getResponse().getStatusCode());
}
use of com.azure.android.communication.chat.models.ChatErrorResponseException in project azure-sdk-for-android by Azure.
the class ChatThreadAsyncClientTest method cannotGetMessageWithResponseWithInvalidId.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void cannotGetMessageWithResponseWithInvalidId(HttpClient httpClient) throws ExecutionException, InterruptedException {
setupTest(httpClient);
ExecutionException executionException = assertThrows(ExecutionException.class, () -> {
this.chatThreadClient.getMessageWithResponse("invalid_chat_message_id", null).get();
});
Throwable cause = executionException.getCause();
assertNotNull(cause);
assertTrue(cause instanceof ChatErrorResponseException);
ChatErrorResponseException exception = (ChatErrorResponseException) cause;
assertNotNull(exception.getResponse());
assertEquals(400, exception.getResponse().getStatusCode());
}
use of com.azure.android.communication.chat.models.ChatErrorResponseException in project azure-sdk-for-android by Azure.
the class ChatThreadAsyncClientTest method getNotFoundOnNonExistingChatThreadWithResponse.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void getNotFoundOnNonExistingChatThreadWithResponse(HttpClient httpClient) throws ExecutionException, InterruptedException {
setupTest(httpClient);
ExecutionException executionException = assertThrows(ExecutionException.class, () -> {
CompletableFuture<Response<ChatThreadProperties>> completableFuture = client.getChatThreadClient("19:00000000000000000000000000000000@thread.v2").getPropertiesWithResponse(null);
completableFuture.get();
});
Throwable cause = executionException.getCause();
assertNotNull(cause);
assertTrue(cause instanceof ChatErrorResponseException);
ChatErrorResponseException exception = (ChatErrorResponseException) cause;
assertNotNull(exception.getResponse());
assertEquals(404, exception.getResponse().getStatusCode());
}
use of com.azure.android.communication.chat.models.ChatErrorResponseException in project azure-sdk-for-android by Azure.
the class ChatThreadAsyncClientTest method cannotRemoveParticipantWithResponseWithInvalidUser.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void cannotRemoveParticipantWithResponseWithInvalidUser(HttpClient httpClient) throws ExecutionException, InterruptedException {
setupTest(httpClient);
ExecutionException executionException = assertThrows(ExecutionException.class, () -> {
this.chatThreadClient.removeParticipantWithResponse(new CommunicationUserIdentifier("8:acs:invalidUserId"), null).get();
});
Throwable cause = executionException.getCause();
assertNotNull(cause);
assertTrue(cause instanceof ChatErrorResponseException);
ChatErrorResponseException exception = (ChatErrorResponseException) cause;
assertNotNull(exception.getResponse());
assertEquals(400, exception.getResponse().getStatusCode());
}
Aggregations