Search in sources :

Example 1 with SendChatMessageResult

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

the class ChatThreadAsyncClientTest method canDeleteExistingMessage.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canDeleteExistingMessage(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    SendChatMessageOptions messageRequest = super.sendMessageOptions();
    CompletableFuture<SendChatMessageResult> completableFuture1 = this.chatThreadClient.sendMessage(messageRequest);
    String messageId = completableFuture1.get().getId();
    assertNotNull(messageId);
    CompletableFuture<Void> completableFuture2 = this.chatThreadClient.deleteMessage(messageId);
    completableFuture2.get();
}
Also used : SendChatMessageResult(com.azure.android.communication.chat.models.SendChatMessageResult) SendChatMessageOptions(com.azure.android.communication.chat.models.SendChatMessageOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with SendChatMessageResult

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

the class ChatThreadAsyncClientTest method canUpdateExistingMessageWithResponse.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canUpdateExistingMessageWithResponse(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    SendChatMessageOptions messageRequest = super.sendMessageOptions();
    UpdateChatMessageOptions updateMessageRequest = super.updateMessageOptions();
    CompletableFuture<Response<SendChatMessageResult>> completableFuture1 = this.chatThreadClient.sendMessageWithResponse(messageRequest, null);
    Response<SendChatMessageResult> sendResponse = completableFuture1.get();
    assertNotNull(sendResponse);
    final String messageId = sendResponse.getValue().getId();
    assertNotNull(messageId);
    CompletableFuture<Response<Void>> completableFuture2 = this.chatThreadClient.updateMessageWithResponse(messageId, updateMessageRequest, null);
    Response<Void> updateResponse = completableFuture2.get();
    assertNotNull(updateResponse);
    assertEquals(204, updateResponse.getStatusCode());
    CompletableFuture<Response<ChatMessage>> completableFuture3 = chatThreadClient.getMessageWithResponse(messageId, null);
    Response<ChatMessage> getResponse = completableFuture3.get();
    assertNotNull(getResponse);
    ChatMessage message = getResponse.getValue();
    assertEquals(message.getContent().getMessage(), updateMessageRequest.getContent());
    assertEquals(message.getMetadata().containsKey("tags"), false);
    assertEquals(message.getMetadata().get("deliveryMode"), updateMessageRequest.getMetadata().get("deliveryMode"));
    assertEquals(message.getMetadata().get("onedriveReferences"), updateMessageRequest.getMetadata().get("onedriveReferences"));
    assertEquals(message.getMetadata().get("amsreferences"), messageRequest.getMetadata().get("amsreferences"));
    assertEquals(message.getMetadata().get("key"), messageRequest.getMetadata().get("key"));
}
Also used : SendChatMessageResult(com.azure.android.communication.chat.models.SendChatMessageResult) UpdateChatMessageOptions(com.azure.android.communication.chat.models.UpdateChatMessageOptions) ChatMessage(com.azure.android.communication.chat.models.ChatMessage) SendChatMessageOptions(com.azure.android.communication.chat.models.SendChatMessageOptions) Response(com.azure.android.core.rest.Response) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with SendChatMessageResult

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

the class ChatThreadAsyncClientTest method canSendThenGetMessageWithResponse.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canSendThenGetMessageWithResponse(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    SendChatMessageOptions messageRequest = super.sendMessageOptions();
    CompletableFuture<Response<SendChatMessageResult>> completableFuture1 = this.chatThreadClient.sendMessageWithResponse(messageRequest, null);
    Response<SendChatMessageResult> response1 = completableFuture1.get();
    assertNotNull(response1);
    final String messageId = response1.getValue().getId();
    CompletableFuture<Response<ChatMessage>> completableFuture2 = this.chatThreadClient.getMessageWithResponse(messageId, null);
    Response<ChatMessage> response2 = completableFuture2.get();
    assertNotNull(response2);
    final ChatMessage message = response2.getValue();
    assertEquals(message.getContent().getMessage(), messageRequest.getContent());
    assertEquals(message.getType(), messageRequest.getType());
    assertEquals(message.getSenderDisplayName(), messageRequest.getSenderDisplayName());
    assertEquals(message.getMetadata(), messageRequest.getMetadata());
}
Also used : Response(com.azure.android.core.rest.Response) SendChatMessageResult(com.azure.android.communication.chat.models.SendChatMessageResult) ChatMessage(com.azure.android.communication.chat.models.ChatMessage) SendChatMessageOptions(com.azure.android.communication.chat.models.SendChatMessageOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

SendChatMessageOptions (com.azure.android.communication.chat.models.SendChatMessageOptions)3 SendChatMessageResult (com.azure.android.communication.chat.models.SendChatMessageResult)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 ChatMessage (com.azure.android.communication.chat.models.ChatMessage)2 Response (com.azure.android.core.rest.Response)2 UpdateChatMessageOptions (com.azure.android.communication.chat.models.UpdateChatMessageOptions)1