Search in sources :

Example 6 with SendChatMessageOptions

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

Example 7 with SendChatMessageOptions

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

the class ChatThreadAsyncClientTest method canSendReadReceipt.

@Disabled("Unreliable test")
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canSendReadReceipt(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    SendChatMessageOptions messageRequest = super.sendMessageOptions();
    String messageId = this.chatThreadClient.sendMessage(messageRequest).get().getId();
    this.chatThreadClient.sendReadReceipt(messageId).get();
}
Also used : SendChatMessageOptions(com.azure.android.communication.chat.models.SendChatMessageOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) Disabled(org.junit.jupiter.api.Disabled)

Example 8 with SendChatMessageOptions

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

the class ChatClientTestBase method sendMessageOptions.

public static SendChatMessageOptions sendMessageOptions() {
    SendChatMessageOptions options = new SendChatMessageOptions();
    options.setContent("Content");
    options.setSenderDisplayName("Tester");
    options.setType(ChatMessageType.TEXT);
    options.setMetadata(new HashMap<String, String>() {

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

Example 9 with SendChatMessageOptions

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

the class ChatThreadAsyncClientTest method canSendReadReceiptWithResponse.

@Disabled("Unreliable test")
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canSendReadReceiptWithResponse(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    SendChatMessageOptions messageRequest = super.sendMessageOptions();
    String messageId = this.chatThreadClient.sendMessage(messageRequest).get().getId();
    CompletableFuture<Response<Void>> completableFuture = this.chatThreadClient.sendReadReceiptWithResponse(messageId, null);
    Response<Void> response = completableFuture.get();
    assertNotNull(response);
    assertEquals(200, response.getStatusCode());
}
Also used : Response(com.azure.android.core.rest.Response) SendChatMessageOptions(com.azure.android.communication.chat.models.SendChatMessageOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) Disabled(org.junit.jupiter.api.Disabled)

Example 10 with SendChatMessageOptions

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

the class ChatThreadAsyncClientTest method canSendThenGetMessage.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canSendThenGetMessage(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    SendChatMessageOptions messageRequest = super.sendMessageOptions();
    final String messageId = this.chatThreadClient.sendMessage(messageRequest).get().getId();
    final ChatMessage message = this.chatThreadClient.getMessage(messageId).get();
    assertEquals(message.getContent().getMessage(), messageRequest.getContent());
    assertEquals(message.getType(), messageRequest.getType());
    assertEquals(message.getSenderDisplayName(), messageRequest.getSenderDisplayName());
    assertEquals(message.getMetadata(), messageRequest.getMetadata());
}
Also used : 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)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 MethodSource (org.junit.jupiter.params.provider.MethodSource)11 ChatMessage (com.azure.android.communication.chat.models.ChatMessage)7 Response (com.azure.android.core.rest.Response)4 SendChatMessageResult (com.azure.android.communication.chat.models.SendChatMessageResult)3 ListChatMessagesOptions (com.azure.android.communication.chat.models.ListChatMessagesOptions)2 UpdateChatMessageOptions (com.azure.android.communication.chat.models.UpdateChatMessageOptions)2 ArrayList (java.util.ArrayList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Disabled (org.junit.jupiter.api.Disabled)2 ExecutionException (java.util.concurrent.ExecutionException)1