Search in sources :

Example 1 with CreateChatThreadResult

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

the class ChatAsyncImplClientTest method canListChatThreadsWithMaxPage.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canListChatThreadsWithMaxPage(HttpClient httpClient) throws InterruptedException, ExecutionException {
    setupTest(httpClient);
    final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadMember.getId(), secondThreadMember.getId());
    CompletableFuture<CreateChatThreadResult> completableFuture1 = this.client.getChatClient().createChatThreadAsync(threadRequest);
    assertNotNull(completableFuture1);
    CreateChatThreadResult result1 = completableFuture1.get();
    assertNotNull(result1);
    assertNotNull(result1.getChatThread());
    assertNotNull(result1.getChatThread().getId());
    CompletableFuture<CreateChatThreadResult> completableFuture2 = this.client.getChatClient().createChatThreadAsync(threadRequest);
    assertNotNull(completableFuture2);
    CreateChatThreadResult result2 = completableFuture1.get();
    assertNotNull(result2);
    assertNotNull(result2.getChatThread());
    assertNotNull(result2.getChatThread().getId());
    CompletableFuture<PagedResponse<ChatThreadItem>> completableFuture = this.client.getChatClient().listChatThreadsSinglePageAsync(2, null);
    String nextLink;
    List<ChatThreadItem> returnedThreads = new ArrayList<ChatThreadItem>();
    do {
        PagedResponse<ChatThreadItem> response = completableFuture.get();
        assertNotNull(response);
        List<ChatThreadItem> threadsInPage = response.getValue();
        assertNotNull(threadsInPage);
        for (ChatThreadItem thread : threadsInPage) {
            returnedThreads.add(thread);
        }
        nextLink = response.getContinuationToken();
        if (nextLink != null) {
            completableFuture = this.client.getChatClient().listChatThreadsNextSinglePageAsync(nextLink);
        }
    } while (nextLink != null);
// REVISIT: Unreliable assertion
// assertTrue(returnedThreads.size() > 0);
}
Also used : CreateChatThreadResult(com.azure.android.communication.chat.implementation.models.CreateChatThreadResult) ChatThreadItem(com.azure.android.communication.chat.models.ChatThreadItem) ArrayList(java.util.ArrayList) PagedResponse(com.azure.android.core.rest.util.paging.PagedResponse) CreateChatThreadOptions(com.azure.android.communication.chat.implementation.models.CreateChatThreadOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with CreateChatThreadResult

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

the class ChatAsyncImplClientTest method canListChatThreads.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canListChatThreads(HttpClient httpClient) throws InterruptedException, ExecutionException {
    setupTest(httpClient);
    final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadMember.getId(), secondThreadMember.getId());
    CompletableFuture<CreateChatThreadResult> completableFuture1 = this.client.getChatClient().createChatThreadAsync(threadRequest);
    assertNotNull(completableFuture1);
    CreateChatThreadResult result1 = completableFuture1.get();
    assertNotNull(result1);
    assertNotNull(result1.getChatThread());
    assertNotNull(result1.getChatThread().getId());
    CompletableFuture<CreateChatThreadResult> completableFuture2 = this.client.getChatClient().createChatThreadAsync(threadRequest);
    assertNotNull(completableFuture2);
    CreateChatThreadResult result2 = completableFuture1.get();
    assertNotNull(result2);
    assertNotNull(result2.getChatThread());
    assertNotNull(result2.getChatThread().getId());
    CompletableFuture<PagedResponse<ChatThreadItem>> completableFuture = this.client.getChatClient().listChatThreadsSinglePageAsync(null, null);
    String nextLink;
    List<ChatThreadItem> returnedThreads = new ArrayList<ChatThreadItem>();
    do {
        PagedResponse<ChatThreadItem> response = completableFuture.get();
        assertNotNull(response);
        List<ChatThreadItem> threadsInPage = response.getValue();
        assertNotNull(threadsInPage);
        for (ChatThreadItem thread : threadsInPage) {
            returnedThreads.add(thread);
        }
        nextLink = response.getContinuationToken();
        if (nextLink != null) {
            completableFuture = this.client.getChatClient().listChatThreadsNextSinglePageAsync(nextLink);
        }
    } while (nextLink != null);
// REVISIT: Unreliable assertion
// assertTrue(returnedThreads.size() > 0);
}
Also used : CreateChatThreadResult(com.azure.android.communication.chat.implementation.models.CreateChatThreadResult) ChatThreadItem(com.azure.android.communication.chat.models.ChatThreadItem) ArrayList(java.util.ArrayList) PagedResponse(com.azure.android.core.rest.util.paging.PagedResponse) CreateChatThreadOptions(com.azure.android.communication.chat.implementation.models.CreateChatThreadOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with CreateChatThreadResult

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

the class ChatAsyncImplClientTest method canCreateThread.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canCreateThread(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadMember.getId(), secondThreadMember.getId());
    CompletableFuture<CreateChatThreadResult> completableFuture = this.client.getChatClient().createChatThreadAsync(threadRequest);
    assertNotNull(completableFuture);
    CreateChatThreadResult result = completableFuture.get();
    assertNotNull(result);
    assertNotNull(result.getChatThread());
    assertNotNull(result.getChatThread().getId());
}
Also used : CreateChatThreadResult(com.azure.android.communication.chat.implementation.models.CreateChatThreadResult) CreateChatThreadOptions(com.azure.android.communication.chat.implementation.models.CreateChatThreadOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with CreateChatThreadResult

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

the class ChatAsyncImplClientTest method canRepeatCreateThread.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canRepeatCreateThread(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    UUID uuid = UUID.randomUUID();
    final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadMember.getId(), secondThreadMember.getId());
    CompletableFuture<Response<CreateChatThreadResult>> completableFuture1 = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, uuid.toString());
    assertNotNull(completableFuture1);
    Response<CreateChatThreadResult> response1 = completableFuture1.get();
    assertNotNull(response1);
    CreateChatThreadResult result1 = response1.getValue();
    assertNotNull(result1);
    assertNotNull(result1.getChatThread());
    assertNotNull(result1.getChatThread().getId());
    String expectedThreadId = response1.getValue().getChatThread().getId();
    CompletableFuture<Response<CreateChatThreadResult>> completableFuture2 = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, uuid.toString());
    assertNotNull(completableFuture2);
    Response<CreateChatThreadResult> response2 = completableFuture2.get();
    assertNotNull(response2);
    CreateChatThreadResult result2 = response2.getValue();
    assertNotNull(result2);
    assertNotNull(result2.getChatThread());
    assertNotNull(result2.getChatThread().getId());
    assertEquals(expectedThreadId, result2.getChatThread().getId());
    CompletableFuture<Response<CreateChatThreadResult>> completableFuture3 = this.client.getChatClient().createChatThreadWithResponseAsync(threadRequest, UUID.randomUUID().toString());
    assertNotNull(completableFuture3);
    Response<CreateChatThreadResult> response3 = completableFuture3.get();
    assertNotNull(response3);
    CreateChatThreadResult result3 = response3.getValue();
    assertNotNull(result3);
    assertNotNull(result3.getChatThread());
    assertNotNull(result3.getChatThread().getId());
    assertNotEquals(expectedThreadId, result3.getChatThread().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.implementation.models.CreateChatThreadResult) UUID(java.util.UUID) CreateChatThreadOptions(com.azure.android.communication.chat.implementation.models.CreateChatThreadOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 5 with CreateChatThreadResult

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

the class ChatAsyncImplClientTest method canDeleteChatThread.

@ParameterizedTest
@MethodSource("com.azure.android.core.test.TestBase#getHttpClients")
public void canDeleteChatThread(HttpClient httpClient) throws ExecutionException, InterruptedException {
    setupTest(httpClient);
    final CreateChatThreadOptions threadRequest = createThreadOptions(firstThreadMember.getId(), secondThreadMember.getId());
    CompletableFuture<CreateChatThreadResult> completableFuture1 = this.client.getChatClient().createChatThreadAsync(threadRequest);
    assertNotNull(completableFuture1);
    CreateChatThreadResult result1 = completableFuture1.get();
    assertNotNull(result1);
    assertNotNull(result1.getChatThread());
    assertNotNull(result1.getChatThread().getId());
    CompletableFuture<Void> completableFuture2 = this.client.getChatClient().deleteChatThreadAsync(result1.getChatThread().getId());
    assertNotNull(completableFuture2);
    Void result2 = completableFuture2.get();
    assertNull(result2);
}
Also used : CreateChatThreadResult(com.azure.android.communication.chat.implementation.models.CreateChatThreadResult) CreateChatThreadOptions(com.azure.android.communication.chat.implementation.models.CreateChatThreadOptions) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

CreateChatThreadOptions (com.azure.android.communication.chat.implementation.models.CreateChatThreadOptions)10 CreateChatThreadResult (com.azure.android.communication.chat.implementation.models.CreateChatThreadResult)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 MethodSource (org.junit.jupiter.params.provider.MethodSource)10 PagedResponse (com.azure.android.core.rest.util.paging.PagedResponse)7 Response (com.azure.android.core.rest.Response)5 ChatThreadProperties (com.azure.android.communication.chat.implementation.models.ChatThreadProperties)2 ChatThreadItem (com.azure.android.communication.chat.models.ChatThreadItem)2 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2