Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@
import com.azure.communication.chat.models.*;
import com.azure.communication.common.CommunicationUserCredential;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.policy.FixedDelay;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.HttpClient;
import com.azure.core.test.TestBase;
import com.azure.core.test.TestMode;
import com.azure.core.util.Configuration;
import com.azure.core.util.logging.ClientLogger;


import java.time.Duration;
import java.time.ZonedDateTime;
import java.time.LocalDateTime;
import java.time.ZoneId;
Expand All @@ -44,8 +40,6 @@ public class ChatClientTestBase extends TestBase {
protected static final String CONNSTRING = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_SERVICES_CONNECTION_STRING", "pw==");

protected static final FixedDelay RETRY_STRATEGY = new FixedDelay(3, Duration.ofMillis(1000));

protected ChatClientBuilder getChatClientBuilder(String token, HttpClient httpClient) {
ChatClientBuilder builder = new ChatClientBuilder();

Expand All @@ -60,10 +54,7 @@ protected ChatClientBuilder getChatClientBuilder(String token, HttpClient httpCl
builder.credential(new CommunicationUserCredential(token));
}

if (interceptorManager.isLiveMode()) {
builder.addPolicy(new RetryPolicy(RETRY_STRATEGY));
}
else {
if (getTestMode() == TestMode.RECORD) {
builder.addPolicy(interceptorManager.getRecordPolicy());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand Down Expand Up @@ -176,8 +178,7 @@ public void canAddListAndRemoveMembersWithResponseAsync(HttpClient httpClient) t
}

assertTrue(returnedMembers.size() == 4);
})
.verifyComplete();
});

for (ChatThreadMember member: options.getMembers()) {
StepVerifier.create(chatThreadClient.removeMemberWithResponse(member.getUser()))
Expand Down Expand Up @@ -408,6 +409,9 @@ public void canSendTypingNotificationWithResponse(HttpClient httpClient) {

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
@DisabledIfEnvironmentVariable(
named = "SKIP_CHAT_READ_RECEIPT_LIVE_TESTS",

@angiurgiu angiurgiu Oct 23, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we make this more generic, in case we expand this to other tests as well in the future?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :) thanks

matches = "(?i)(true)")
public void canSendThenListReadReceipts(HttpClient httpClient) throws InterruptedException {
// Arrange
setupTest(httpClient);
Expand All @@ -431,16 +435,16 @@ public void canSendThenListReadReceipts(HttpClient httpClient) throws Interrupte
assertEquals(resp.getStatusCode(), 200);
resp.getItems().forEach(item -> returnedReadReceipts.add(item));
});

if (interceptorManager.isPlaybackMode()) {
assertTrue(returnedReadReceipts.size() > 0);
checkReadReceiptListContainsMessageId(returnedReadReceipts, messageResponseRef.get().getId());
}
assertTrue(returnedReadReceipts.size() > 0);
checkReadReceiptListContainsMessageId(returnedReadReceipts, messageResponseRef.get().getId());
});
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
@DisabledIfEnvironmentVariable(
named = "SKIP_CHAT_READ_RECEIPT_LIVE_TESTS",
matches = "(?i)(true)")
public void canSendThenListReadReceiptsWithResponse(HttpClient httpClient) throws InterruptedException {
// Arrange
setupTest(httpClient);
Expand All @@ -466,12 +470,9 @@ public void canSendThenListReadReceiptsWithResponse(HttpClient httpClient) throw
resp.getItems().forEach(item -> returnedReadReceipts.add(item));
});

if (interceptorManager.isPlaybackMode()) {
assertTrue(returnedReadReceipts.size() > 0);
checkReadReceiptListContainsMessageId(returnedReadReceipts, messageResponseRef.get().getId());
}
})
.verifyComplete();
assertTrue(returnedReadReceipts.size() > 0);
checkReadReceiptListContainsMessageId(returnedReadReceipts, messageResponseRef.get().getId());
});

}
}
3 changes: 2 additions & 1 deletion sdk/communication/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ jobs:
safeName: azurecommunicationadministration
- name: azure-communication-chat
groupId: com.azure
safeName: azurecommunicationchatclient
safeName: azurecommunicationchat
ServiceDirectory: communication
EnvVars:
AZURE_TEST_MODE: LIVE
SKIP_PHONENUMBER_INTEGRATION_TESTS: TRUE
SKIP_CHAT_READ_RECEIPT_LIVE_TESTS: TRUE