use of com.azure.android.communication.chat.models.SendChatMessageOptions in project azure-sdk-for-android by Azure.
the class ChatThreadAsyncClientTest method canDeleteExistingMessageWithResponse.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canDeleteExistingMessageWithResponse(HttpClient httpClient) throws ExecutionException, InterruptedException {
setupTest(httpClient);
SendChatMessageOptions messageRequest = super.sendMessageOptions();
String messageId = this.chatThreadClient.sendMessage(messageRequest).get().getId();
CompletableFuture<Response<Void>> completableFuture = chatThreadClient.deleteMessageWithResponse(messageId, null);
Response<Void> deleteResponse = completableFuture.get();
assertEquals(deleteResponse.getStatusCode(), 204);
}
use of com.azure.android.communication.chat.models.SendChatMessageOptions in project azure-sdk-for-android by Azure.
the class ChatThreadAsyncClientTest method canListMessages.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canListMessages(HttpClient httpClient) throws ExecutionException, InterruptedException {
setupTest(httpClient);
SendChatMessageOptions messageRequest = super.sendMessageOptions();
this.chatThreadClient.sendMessage(messageRequest).get();
this.chatThreadClient.sendMessage(messageRequest).get();
PagedAsyncStream<ChatMessage> messagePagedAsyncStream = this.chatThreadClient.listMessages(new ListChatMessagesOptions(), null);
CountDownLatch latch = new CountDownLatch(1);
List<ChatMessage> returnedMessages = new ArrayList<ChatMessage>();
messagePagedAsyncStream.forEach(new AsyncStreamHandler<ChatMessage>() {
@Override
public void onNext(ChatMessage message) {
if (message.getType().equals(ChatMessageType.TEXT)) {
returnedMessages.add(message);
}
}
@Override
public void onError(Throwable throwable) {
latch.countDown();
}
@Override
public void onComplete() {
latch.countDown();
}
});
awaitOnLatch(latch, "canListMessages");
assertTrue(returnedMessages.size() > 0);
}
use of com.azure.android.communication.chat.models.SendChatMessageOptions in project azure-sdk-for-android by Azure.
the class ChatThreadAsyncClientTest method canSendThenGetHtmlMessage.
@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canSendThenGetHtmlMessage(HttpClient httpClient) throws ExecutionException, InterruptedException {
setupTest(httpClient);
SendChatMessageOptions messageRequest = new SendChatMessageOptions().setType(ChatMessageType.HTML).setSenderDisplayName("John").setContent("<div>test</div>").setMetadata(new HashMap<String, String>() {
{
put("tags", "");
put("deliveryMode", "deliveryMode value - updated");
put("onedriveReferences", "onedriveReferences - updated");
put("amsreferences", "[\\\"test url file 3\\\"]");
}
});
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());
}
Aggregations