Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Communication - email] Migrate test recordings to assets repo #35805

Merged
merged 3 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions sdk/communication/azure-communication-email/assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/communication/azure-communication-email",
"Tag": "java/communication/azure-communication-email_e70471d340"
}
5 changes: 4 additions & 1 deletion sdk/communication/azure-communication-email/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<jacoco.min.linecoverage>0.70</jacoco.min.linecoverage>
<jacoco.min.branchcoverage>0.45</jacoco.min.branchcoverage>
<jacoco.skip>true</jacoco.skip>
<javaModulesSurefireArgLine>
--add-opens com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED
</javaModulesSurefireArgLine>
</properties>

<dependencies>
Expand Down Expand Up @@ -107,10 +110,10 @@
<configuration>
<codesnippetGlob>**/src/samples/java/**/*.java</codesnippetGlob>
<codesnippetRootDirectory>${project.basedir}/src/samples/java</codesnippetRootDirectory>
<readmePath>${project.basedir}/README.md</readmePath>
<sourceGlob>**/src/main/java/**/*.java</sourceGlob>
<sourceRootDirectory>${project.basedir}/src/main/java</sourceRootDirectory>
<includeSource>true</includeSource>
<readmePath>${project.basedir}/README.md</readmePath>
<includeReadme>true</includeReadme>
<maxLineLength>120</maxLineLength>
<skip>false</skip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@

import com.azure.core.http.HttpClient;
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.test.TestBase;
import com.azure.core.test.TestMode;
import com.azure.core.test.TestProxyTestBase;
import com.azure.core.test.models.CustomMatcher;
import com.azure.core.util.Configuration;
import org.junit.jupiter.params.provider.Arguments;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.stream.Stream;


public class EmailTestBase extends TestBase {
protected static final TestMode TEST_MODE = initializeTestMode();

public class EmailTestBase extends TestProxyTestBase {

protected static final String CONNECTION_STRING = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_CONNECTION_STRING_EMAIL", "endpoint=https://REDACTED.communication.azure.com/;accesskey=QWNjZXNzS2V5");
Expand All @@ -44,7 +43,11 @@ private EmailClientBuilder getEmailClientBuilder(HttpClient httpClient) {
EmailClientBuilder emailClientBuilder = new EmailClientBuilder()
.connectionString(CONNECTION_STRING)
.httpClient(getHttpClientOrUsePlayback(httpClient));

if (interceptorManager.isPlaybackMode()) {
interceptorManager.addMatchers(Arrays.asList(new CustomMatcher()
.setHeadersKeyOnlyMatch(Arrays.asList("x-ms-content-sha256", "x-ms-hmac-string-to-sign-base64"))
.setComparingBodies(false)));
}
if (getTestMode() == TestMode.RECORD) {
HttpPipelinePolicy recordPolicy = interceptorManager.getRecordPolicy();
emailClientBuilder.addPolicy(recordPolicy);
Expand All @@ -53,20 +56,6 @@ private EmailClientBuilder getEmailClientBuilder(HttpClient httpClient) {
return emailClientBuilder;
}

private static TestMode initializeTestMode() {
String azureTestMode = Configuration.getGlobalConfiguration().get("AZURE_TEST_MODE");
if (azureTestMode != null) {
System.out.println("azureTestMode: " + azureTestMode);
try {
return TestMode.valueOf(azureTestMode.toUpperCase(Locale.US));
} catch (IllegalArgumentException var3) {
return TestMode.PLAYBACK;
}
} else {
return TestMode.PLAYBACK;
}
}

static Stream<Arguments> getTestParameters() {
// When this issues is closed, the newer version of junit will have better support for cartesian product of
// arguments - https://github.com/junit-team/junit5/issues/1427
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.