Search in sources :

Example 11 with CreateChatThreadOptions

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

the class ChatAsyncClientTest method canCreateNewThreadWithoutSettingRepeatabilityID.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canCreateNewThreadWithoutSettingRepeatabilityID(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    final CreateChatThreadOptions threadRequest1 = createThreadOptions(firstThreadParticipant.getId(), secondThreadParticipant.getId());
    CompletableFuture<Response<CreateChatThreadResult>> completableFuture1 = this.client.createChatThreadWithResponse(threadRequest1, null);
    assertNotNull(completableFuture1);
    Response<CreateChatThreadResult> response1 = completableFuture1.get();
    assertNotNull(response1);
    CreateChatThreadResult result1 = response1.getValue();
    assertNotNull(result1);
    assertNotNull(result1.getChatThreadProperties());
    assertNotNull(result1.getChatThreadProperties().getId());
    String threadId1 = response1.getValue().getChatThreadProperties().getId();
    // Create new CreateChatThreadOptions to get new RepeatabilityID.
    final CreateChatThreadOptions threadRequest2 = createThreadOptions(firstThreadParticipant.getId(), secondThreadParticipant.getId());
    CompletableFuture<Response<CreateChatThreadResult>> completableFuture2 = this.client.createChatThreadWithResponse(threadRequest2, null);
    assertNotNull(completableFuture2);
    Response<CreateChatThreadResult> response2 = completableFuture2.get();
    assertNotNull(response2);
    CreateChatThreadResult result2 = response2.getValue();
    assertNotNull(result2);
    assertNotNull(result2.getChatThreadProperties());
    assertNotNull(result2.getChatThreadProperties().getId());
    assertNotEquals(threadId1, result2.getChatThreadProperties().getId());
}
Also used : Response(com.azure.android.core.rest.Response) PagedResponse(com.azure.android.core.rest.util.paging.PagedResponse) CreateChatThreadResult(com.azure.android.communication.chat.models.CreateChatThreadResult) CreateChatThreadOptions(com.azure.android.communication.chat.models.CreateChatThreadOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 12 with CreateChatThreadOptions

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

the class ChatClientTestBase method createThreadOptions.

protected static CreateChatThreadOptions createThreadOptions(String userId1, String userId2) {
    List<ChatParticipant> participants = new ArrayList<ChatParticipant>();
    participants.add(generateParticipant(userId1, "Tester 1"));
    participants.add(generateParticipant(userId2, "Tester 2"));
    CreateChatThreadOptions options = new CreateChatThreadOptions().setTopic("Test").setParticipants(participants);
    return options;
}
Also used : ArrayList(java.util.ArrayList) ChatParticipant(com.azure.android.communication.chat.models.ChatParticipant) CreateChatThreadOptions(com.azure.android.communication.chat.models.CreateChatThreadOptions)

Example 13 with CreateChatThreadOptions

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

the class ChatThreadAsyncClientTest method setupTest.

private void setupTest(HttpClient httpClient) throws ExecutionException, InterruptedException {
    this.client = super.getChatClientBuilder(httpClient).buildAsyncClient();
    this.firstThreadParticipant = new CommunicationUserIdentifier(THREAD_PARTICIPANT_1);
    this.secondThreadParticipant = new CommunicationUserIdentifier(THREAD_PARTICIPANT_2);
    CreateChatThreadOptions threadRequest = createThreadOptions(this.firstThreadParticipant.getId(), this.secondThreadParticipant.getId());
    CreateChatThreadResult createChatThreadResult = client.createChatThread(threadRequest).get();
    this.chatThreadClient = client.getChatThreadClient(createChatThreadResult.getChatThreadProperties().getId());
    this.threadId = chatThreadClient.getChatThreadId();
}
Also used : CreateChatThreadResult(com.azure.android.communication.chat.models.CreateChatThreadResult) CreateChatThreadOptions(com.azure.android.communication.chat.models.CreateChatThreadOptions) CommunicationUserIdentifier(com.azure.android.communication.common.CommunicationUserIdentifier)

Example 14 with CreateChatThreadOptions

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

the class ChatThreadAsyncClientTest method canGetExistingChatThread.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canGetExistingChatThread(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadParticipant.getId(), secondThreadParticipant.getId());
    CompletableFuture<CreateChatThreadResult> completableFuture1 = this.client.createChatThread(threadRequest);
    assertNotNull(completableFuture1);
    CreateChatThreadResult result1 = completableFuture1.get();
    assertNotNull(result1);
    assertNotNull(result1.getChatThreadProperties());
    assertNotNull(result1.getChatThreadProperties().getId());
    String expectedThreadId = result1.getChatThreadProperties().getId();
    CompletableFuture<ChatThreadProperties> completableFuture2 = this.client.getChatThreadClient(expectedThreadId).getProperties();
    assertNotNull(completableFuture2);
    ChatThreadProperties result2 = completableFuture2.get();
    assertNotNull(result2);
    assertNotNull(result2.getId());
    assertEquals(expectedThreadId, result2.getId());
}
Also used : CreateChatThreadResult(com.azure.android.communication.chat.models.CreateChatThreadResult) ChatThreadProperties(com.azure.android.communication.chat.models.ChatThreadProperties) CreateChatThreadOptions(com.azure.android.communication.chat.models.CreateChatThreadOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 15 with CreateChatThreadOptions

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

the class ChatThreadAsyncClientTest method canGetExistingChatThreadWithResponse.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canGetExistingChatThreadWithResponse(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadParticipant.getId(), secondThreadParticipant.getId());
    CompletableFuture<Response<CreateChatThreadResult>> completableFuture1 = this.client.createChatThreadWithResponse(threadRequest, null);
    assertNotNull(completableFuture1);
    Response<CreateChatThreadResult> response1 = completableFuture1.get();
    assertNotNull(response1);
    CreateChatThreadResult result1 = response1.getValue();
    assertNotNull(result1);
    assertNotNull(result1.getChatThreadProperties());
    assertNotNull(result1.getChatThreadProperties().getId());
    String expectedThreadId = result1.getChatThreadProperties().getId();
    CompletableFuture<Response<ChatThreadProperties>> completableFuture2 = this.client.getChatThreadClient(expectedThreadId).getPropertiesWithResponse(null);
    assertNotNull(completableFuture2);
    Response<ChatThreadProperties> response2 = completableFuture2.get();
    assertNotNull(response2);
    ChatThreadProperties result2 = response2.getValue();
    assertNotNull(result2);
    assertNotNull(result2.getId());
    assertEquals(expectedThreadId, result2.getId());
}
Also used : Response(com.azure.android.core.rest.Response) CreateChatThreadResult(com.azure.android.communication.chat.models.CreateChatThreadResult) ChatThreadProperties(com.azure.android.communication.chat.models.ChatThreadProperties) CreateChatThreadOptions(com.azure.android.communication.chat.models.CreateChatThreadOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

CreateChatThreadOptions (com.azure.android.communication.chat.models.CreateChatThreadOptions)15 CreateChatThreadResult (com.azure.android.communication.chat.models.CreateChatThreadResult)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 MethodSource (org.junit.jupiter.params.provider.MethodSource)12 PagedResponse (com.azure.android.core.rest.util.paging.PagedResponse)6 Response (com.azure.android.core.rest.Response)5 ArrayList (java.util.ArrayList)4 ChatThreadProperties (com.azure.android.communication.chat.models.ChatThreadProperties)3 ExecutionException (java.util.concurrent.ExecutionException)3 ChatErrorResponseException (com.azure.android.communication.chat.models.ChatErrorResponseException)2 ChatParticipant (com.azure.android.communication.chat.models.ChatParticipant)2 ChatThreadItem (com.azure.android.communication.chat.models.ChatThreadItem)2 ListChatThreadsOptions (com.azure.android.communication.chat.models.ListChatThreadsOptions)2 CommunicationUserIdentifier (com.azure.android.communication.common.CommunicationUserIdentifier)2 List (java.util.List)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 UUID (java.util.UUID)1