Search in sources :

Example 1 with UpdateChatMessageOptions

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

the class ChatThreadAsyncClientTest method canUpdateExistingMessage.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canUpdateExistingMessage(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    SendChatMessageOptions messageRequest = super.sendMessageOptions();
    UpdateChatMessageOptions updateMessageRequest = super.updateMessageOptions();
    final String messageId = this.chatThreadClient.sendMessage(messageRequest).get().getId();
    this.chatThreadClient.updateMessage(messageId, updateMessageRequest).get();
    final ChatMessage message = chatThreadClient.getMessage(messageId).get();
    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 : UpdateChatMessageOptions(com.azure.android.communication.chat.models.UpdateChatMessageOptions) 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)

Example 2 with UpdateChatMessageOptions

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

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

the class ChatThreadAsyncClientTest method cannotUpdateMessageNullId.

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

Example 4 with UpdateChatMessageOptions

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

the class ChatClientTestBase method updateMessageOptions.

public static UpdateChatMessageOptions updateMessageOptions() {
    UpdateChatMessageOptions options = new UpdateChatMessageOptions();
    options.setContent("Update Test");
    options.setMetadata(new HashMap<String, String>() {

        {
            put("tags", "");
            put("deliveryMode", "deliveryMode value - updated");
            put("onedriveReferences", "onedriveReferences - updated");
            put("amsreferences", "[\\\"test url file 3\\\"]");
        }
    });
    return options;
}
Also used : UpdateChatMessageOptions(com.azure.android.communication.chat.models.UpdateChatMessageOptions)

Example 5 with UpdateChatMessageOptions

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

the class ChatThreadAsyncClientTest method cannotUpdateMessageWithResponseNullId.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void cannotUpdateMessageWithResponseNullId(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    UpdateChatMessageOptions updateMessageRequest = super.updateMessageOptions();
    ExecutionException executionException = assertThrows(ExecutionException.class, () -> {
        this.chatThreadClient.updateMessageWithResponse(null, updateMessageRequest, null).get();
    });
    assertNotNull(executionException.getCause());
    assertTrue(executionException.getCause() instanceof NullPointerException);
}
Also used : UpdateChatMessageOptions(com.azure.android.communication.chat.models.UpdateChatMessageOptions) 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