This is an automated email from the ASF dual-hosted git repository.
wuweijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 4be828d51f9 Refactor MaskAlgorithmAssertions (#30590)
4be828d51f9 is described below
commit 4be828d51f9bd84ebfdba59c3f07a82aedefa87b
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Mar 21 23:08:37 2024 +0800
Refactor MaskAlgorithmAssertions (#30590)
---
.../cover/KeepFirstNLastMMaskAlgorithmTest.java | 78 +++++++++++++--------
.../cover/KeepFromXToYMaskAlgorithmTest.java | 80 +++++++++++++---------
.../cover/MaskAfterSpecialCharsAlgorithmTest.java | 39 ++++++-----
.../cover/MaskBeforeSpecialCharsAlgorithmTest.java | 35 +++++-----
.../cover/MaskFirstNLastMMaskAlgorithmTest.java | 78 +++++++++++++--------
.../cover/MaskFromXToYMaskAlgorithmTest.java | 76 ++++++++++++--------
.../mask/algorithm/hash/MD5MaskAlgorithmTest.java | 40 +++++++----
.../MaskAlgorithmExecuteArgumentsProvider.java} | 11 +--
.../MaskAlgorithmExecuteCaseAssert.java} | 12 +---
.../MaskAlgorithmInitArgumentsProvider.java} | 8 +--
.../MaskAlgorithmInitCaseAssert.java} | 12 +---
11 files changed, 273 insertions(+), 196 deletions(-)
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithmTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithmTest.java
index a9ff481ae81..948972ca0b1 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithmTest.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithmTest.java
@@ -18,8 +18,10 @@
package org.apache.shardingsphere.mask.algorithm.cover;
import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmAssertions;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmCaseAssert;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitCaseAssert;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.params.ParameterizedTest;
@@ -38,53 +40,69 @@ class KeepFirstNLastMMaskAlgorithmTest {
}
@ParameterizedTest(name = "{0}: {1}")
- @ArgumentsSource(AlgorithmMaskArgumentsProvider.class)
+ @ArgumentsSource(AlgorithmMaskExecuteArgumentsProvider.class)
void assertMask(final String type, @SuppressWarnings("unused") final
String name, final Properties props, final Object plainValue, final Object
maskedValue) {
MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
}
- private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ @ParameterizedTest(name = "{0}: {1}")
+ @ArgumentsSource(AlgorithmMaskExecuteWithSameNMArgumentsProvider.class)
+ void assertMaskWithSameNM(final String type, @SuppressWarnings("unused")
final String name, final Properties props, final Object plainValue, final
Object maskedValue) {
+ MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
+ }
+
+ private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmInitArgumentsProvider {
AlgorithmInitArgumentsProvider() {
super("KEEP_FIRST_N_LAST_M");
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
+ protected Collection<MaskAlgorithmInitCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("empty_first_N",
PropertiesBuilder.build(new Property("first-n", ""), new Property("last-m",
"5"), new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("empty_last_N",
PropertiesBuilder.build(new Property("first-n", "2"), new Property("last-m",
""), new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("empty_replace_char",
PropertiesBuilder.build(new Property("first-n", "2"), new Property("last-m",
"5"), new Property("replace-char", ""))));
+ new MaskAlgorithmInitCaseAssert("empty_first_N",
PropertiesBuilder.build(new Property("first-n", ""), new Property("last-m",
"5"), new Property("replace-char", "*"))),
+ new MaskAlgorithmInitCaseAssert("empty_last_N",
PropertiesBuilder.build(new Property("first-n", "2"), new Property("last-m",
""), new Property("replace-char", "*"))),
+ new MaskAlgorithmInitCaseAssert("empty_replace_char",
PropertiesBuilder.build(new Property("first-n", "2"), new Property("last-m",
"5"), new Property("replace-char", ""))));
}
}
- private static class AlgorithmMaskArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ private static class AlgorithmMaskExecuteArgumentsProvider extends
MaskAlgorithmExecuteArgumentsProvider {
- AlgorithmMaskArgumentsProvider() {
- super("KEEP_FIRST_N_LAST_M");
+ AlgorithmMaskExecuteArgumentsProvider() {
+ super("KEEP_FIRST_N_LAST_M", PropertiesBuilder.build(new
Property("first-n", "3"), new Property("last-m", "5"), new
Property("replace-char", "*")));
+ }
+
+ @Override
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
+ return Arrays.asList(
+ new MaskAlgorithmExecuteCaseAssert("null_value", null,
null),
+ new MaskAlgorithmExecuteCaseAssert("empty_string", "", ""),
+ new MaskAlgorithmExecuteCaseAssert("normal_with_diff",
"abc123456", "abc*23456"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_first_n_with_diff", "ab",
"ab"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_first_n_with_diff", "abc", "abc"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_last_m_with_diff", "abc1",
"abc1"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_last_m_with_diff", "abc12",
"abc12"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_first_n_plus_last_m_with_diff",
"abc1234", "abc1234"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_first_n_plus_last_m_with_diff",
"abc12345", "abc12345"));
+ }
+ }
+
+ private static class AlgorithmMaskExecuteWithSameNMArgumentsProvider
extends MaskAlgorithmExecuteArgumentsProvider {
+
+ AlgorithmMaskExecuteWithSameNMArgumentsProvider() {
+ super("KEEP_FIRST_N_LAST_M", PropertiesBuilder.build(new
Property("first-n", "5"), new Property("last-m", "5"), new
Property("replace-char", "*")));
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
- Properties diffProps = PropertiesBuilder.build(new
Property("first-n", "3"), new Property("last-m", "5"), new
Property("replace-char", "*"));
- Properties sameProps = PropertiesBuilder.build(new
Property("first-n", "5"), new Property("last-m", "5"), new
Property("replace-char", "*"));
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("null_value", diffProps, null,
null),
- new MaskAlgorithmCaseAssert("empty_string", diffProps, "",
""),
- new MaskAlgorithmCaseAssert("normal_with_diff", diffProps,
"abc123456", "abc*23456"),
- new MaskAlgorithmCaseAssert("normal_with_same", sameProps,
"abc123456789", "abc12**56789"),
- new
MaskAlgorithmCaseAssert("plain_value_length_less_than_first_n_with_diff",
diffProps, "ab", "ab"),
- new
MaskAlgorithmCaseAssert("plain_value_length_less_than_first_n_with_same",
sameProps, "abc", "abc"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_first_n_with_diff",
diffProps, "abc", "abc"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_first_n_with_same",
sameProps, "abc12", "abc12"),
- new
MaskAlgorithmCaseAssert("plain_value_length_less_than_last_m_with_diff",
diffProps, "abc1", "abc1"),
- new
MaskAlgorithmCaseAssert("plain_value_length_less_than_last_m_with_same",
sameProps, "abc1", "abc1"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_last_m_with_diff",
diffProps, "abc12", "abc12"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_last_m_with_same",
sameProps, "abc12", "abc12"),
- new
MaskAlgorithmCaseAssert("plain_value_length_less_than_first_n_plus_last_m_with_diff",
diffProps, "abc1234", "abc1234"),
- new
MaskAlgorithmCaseAssert("plain_value_length_less_than_first_n_plus_last_m_with_same",
sameProps, "abc123456", "abc123456"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_first_n_plus_last_m_with_diff",
diffProps, "abc12345", "abc12345"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_first_n_plus_last_m_with_same",
sameProps, "abc1234567", "abc1234567"));
+ new MaskAlgorithmExecuteCaseAssert("normal_with_same",
"abc123456789", "abc12**56789"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_first_n_with_same", "abc",
"abc"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_first_n_with_same", "abc12",
"abc12"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_last_m_with_same", "abc1",
"abc1"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_last_m_with_same", "abc12",
"abc12"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_first_n_plus_last_m_with_same",
"abc123456", "abc123456"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_first_n_plus_last_m_with_same",
"abc1234567", "abc1234567"));
}
}
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithmTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithmTest.java
index 4329994bbfd..00b79e6669b 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithmTest.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithmTest.java
@@ -17,9 +17,11 @@
package org.apache.shardingsphere.mask.algorithm.cover;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteArgumentsProvider;
import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmAssertions;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitCaseAssert;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.params.ParameterizedTest;
@@ -38,54 +40,70 @@ class KeepFromXToYMaskAlgorithmTest {
}
@ParameterizedTest(name = "{0}: {1}")
- @ArgumentsSource(AlgorithmMaskArgumentsProvider.class)
+ @ArgumentsSource(AlgorithmMaskExecuteArgumentsProvider.class)
void assertMask(final String type, @SuppressWarnings("unused") final
String name, final Properties props, final Object plainValue, final Object
maskedValue) {
MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
}
- private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ @ParameterizedTest(name = "{0}: {1}")
+ @ArgumentsSource(AlgorithmMaskExecuteWithSameXYArgumentsProvider.class)
+ void assertMaskWithSameXY(final String type, @SuppressWarnings("unused")
final String name, final Properties props, final Object plainValue, final
Object maskedValue) {
+ MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
+ }
+
+ private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmInitArgumentsProvider {
AlgorithmInitArgumentsProvider() {
super("KEEP_FROM_X_TO_Y");
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
+ protected Collection<MaskAlgorithmInitCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("from_x_is_empty",
PropertiesBuilder.build(new Property("from-x", ""), new Property("to-y", "5"),
new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("to_y_is_empty",
PropertiesBuilder.build(new Property("from-x", "2"), new Property("to-y", ""),
new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("replace_char_is_empty",
PropertiesBuilder.build(new Property("from-x", "2"), new Property("to-y", "5"),
new Property("replace-char", ""))),
- new MaskAlgorithmCaseAssert("from_x_is_not_positive",
PropertiesBuilder.build(new Property("from-x", "-3"), new Property("to-y",
"5"), new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("to_y_is_not_positive",
PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y",
"-5"), new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("from_x_greater_than_to_y",
PropertiesBuilder.build(new Property("from-x", "5"), new Property("to-y", "2"),
new Property("replace-char", ""))));
+ new MaskAlgorithmInitCaseAssert("empty_from_X",
PropertiesBuilder.build(new Property("from-x", ""), new Property("to-y", "5"),
new Property("replace-char", "*"))),
+ new MaskAlgorithmInitCaseAssert("empty_to_Y",
PropertiesBuilder.build(new Property("from-x", "2"), new Property("to-y", ""),
new Property("replace-char", "*"))),
+ new MaskAlgorithmInitCaseAssert("empty_replace_char",
PropertiesBuilder.build(new Property("from-x", "2"), new Property("to-y", "5"),
new Property("replace-char", ""))),
+ new MaskAlgorithmInitCaseAssert("negative_from_X",
PropertiesBuilder.build(new Property("from-x", "-3"), new Property("to-y",
"5"), new Property("replace-char", "*"))),
+ new MaskAlgorithmInitCaseAssert("negative_to_Y",
PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y",
"-5"), new Property("replace-char", "*"))),
+ new
MaskAlgorithmInitCaseAssert("from_X_greater_than_to_Y",
PropertiesBuilder.build(new Property("from-x", "5"), new Property("to-y", "2"),
new Property("replace-char", ""))));
}
}
- private static class AlgorithmMaskArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ private static class AlgorithmMaskExecuteArgumentsProvider extends
MaskAlgorithmExecuteArgumentsProvider {
- AlgorithmMaskArgumentsProvider() {
- super("KEEP_FROM_X_TO_Y");
+ AlgorithmMaskExecuteArgumentsProvider() {
+ super("KEEP_FROM_X_TO_Y", PropertiesBuilder.build(new
Property("from-x", "3"), new Property("to-y", "5"), new
Property("replace-char", "*")));
+ }
+
+ @Override
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
+ return Arrays.asList(
+ new MaskAlgorithmExecuteCaseAssert("null_value", null,
null),
+ new MaskAlgorithmExecuteCaseAssert("empty_string", "", ""),
+ new MaskAlgorithmExecuteCaseAssert("normal_with_diff",
"abc123456", "***123***"),
+ new
MaskAlgorithmExecuteCaseAssert("plain_value_length_less_than_from_X_plus_one_with_diff",
"abc", "***"),
+ new
MaskAlgorithmExecuteCaseAssert("plain_value_length_equals_from_X_plus_one_with_diff",
"abc1", "***1"),
+ new
MaskAlgorithmExecuteCaseAssert("plain_value_length_equals_from_X_plus_one_with_diff",
"abc1", "***1"),
+ new
MaskAlgorithmExecuteCaseAssert("plain_value_length_less_than_to_Y_plus_one_with_diff",
"abc12", "***12"),
+ new
MaskAlgorithmExecuteCaseAssert("plain_value_length_equals_to_Y_plus_one_with_diff",
"abc123", "***123"));
+ }
+ }
+
+ private static class AlgorithmMaskExecuteWithSameXYArgumentsProvider
extends MaskAlgorithmExecuteArgumentsProvider {
+
+ AlgorithmMaskExecuteWithSameXYArgumentsProvider() {
+ super("KEEP_FROM_X_TO_Y", PropertiesBuilder.build(new
Property("from-x", "5"), new Property("to-y", "5"), new
Property("replace-char", "*")));
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
- Properties diffProps = PropertiesBuilder.build(new
Property("from-x", "3"), new Property("to-y", "5"), new
Property("replace-char", "*"));
- Properties sameProps = PropertiesBuilder.build(new
Property("from-x", "5"), new Property("to-y", "5"), new
Property("replace-char", "*"));
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("null_value", diffProps, null,
null),
- new MaskAlgorithmCaseAssert("empty_string", diffProps, "",
""),
- new MaskAlgorithmCaseAssert("normal_with_diff", diffProps,
"abc123456", "***123***"),
- new MaskAlgorithmCaseAssert("normal_with_same", sameProps,
"abc123456", "*****3***"),
- new
MaskAlgorithmCaseAssert("plain_value_length_less_than_from_X_plus_one_with_diff",
diffProps, "abc", "***"),
- new
MaskAlgorithmCaseAssert("plain_value_length_less_than_from_X_plus_one_with_same",
sameProps, "abc", "***"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_from_X_plus_one_with_diff",
diffProps, "abc1", "***1"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_from_X_plus_one_with_same",
sameProps, "abc123", "*****3"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_from_X_plus_one_with_diff",
diffProps, "abc1", "***1"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_from_X_plus_one_with_same",
sameProps, "abc123", "*****3"),
- new
MaskAlgorithmCaseAssert("plain_value_length_less_than_to_Y_plus_one_with_diff",
diffProps, "abc12", "***12"),
- new
MaskAlgorithmCaseAssert("plain_value_length_less_than_to_Y_plus_one_with_same",
sameProps, "abc12", "*****"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_to_Y_plus_one_with_diff",
diffProps, "abc123", "***123"),
- new
MaskAlgorithmCaseAssert("plain_value_length_equals_to_Y_plus_one_with_same",
sameProps, "abc123", "*****3"));
+ new MaskAlgorithmExecuteCaseAssert("normal_with_same",
"abc123456", "*****3***"),
+ new
MaskAlgorithmExecuteCaseAssert("plain_value_length_less_than_from_X_plus_one_with_same",
"abc", "***"),
+ new
MaskAlgorithmExecuteCaseAssert("plain_value_length_equals_from_X_plus_one_with_same",
"abc123", "*****3"),
+ new
MaskAlgorithmExecuteCaseAssert("plain_value_length_equals_from_X_plus_one_with_same",
"abc123", "*****3"),
+ new
MaskAlgorithmExecuteCaseAssert("plain_value_length_less_than_to_Y_plus_one_with_same",
"abc12", "*****"),
+ new
MaskAlgorithmExecuteCaseAssert("plain_value_length_equals_to_Y_plus_one_with_same",
"abc123", "*****3"));
}
}
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithmTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithmTest.java
index ae06a185743..472c3394a43 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithmTest.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithmTest.java
@@ -17,9 +17,11 @@
package org.apache.shardingsphere.mask.algorithm.cover;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmArgumentsProvider;
import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmAssertions;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitCaseAssert;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.params.ParameterizedTest;
@@ -38,42 +40,41 @@ class MaskAfterSpecialCharsAlgorithmTest {
}
@ParameterizedTest(name = "{0}: {1}")
- @ArgumentsSource(AlgorithmMaskArgumentsProvider.class)
+ @ArgumentsSource(AlgorithmMaskExecuteArgumentsProvider.class)
void assertMask(final String type, @SuppressWarnings("unused") final
String name, final Properties props, final Object plainValue, final Object
maskedValue) {
MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
}
- private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmInitArgumentsProvider {
AlgorithmInitArgumentsProvider() {
super("MASK_AFTER_SPECIAL_CHARS");
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
+ protected Collection<MaskAlgorithmInitCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("empty_properties", new
Properties()),
- new MaskAlgorithmCaseAssert("empty_special_char",
PropertiesBuilder.build(new Property("special-chars", ""))),
- new MaskAlgorithmCaseAssert("empty_replace_char",
PropertiesBuilder.build(new Property("special-chars", "d1"), new
Property("replace-char", ""))),
- new MaskAlgorithmCaseAssert("missing_replace_char",
PropertiesBuilder.build(new Property("special-chars", "d1"))));
+ new MaskAlgorithmInitCaseAssert("empty_properties", new
Properties()),
+ new MaskAlgorithmInitCaseAssert("empty_special_char",
PropertiesBuilder.build(new Property("special-chars", ""))),
+ new MaskAlgorithmInitCaseAssert("empty_replace_char",
PropertiesBuilder.build(new Property("special-chars", "d1"), new
Property("replace-char", ""))),
+ new MaskAlgorithmInitCaseAssert("missing_replace_char",
PropertiesBuilder.build(new Property("special-chars", "d1"))));
}
}
- private static class AlgorithmMaskArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ private static class AlgorithmMaskExecuteArgumentsProvider extends
MaskAlgorithmExecuteArgumentsProvider {
- AlgorithmMaskArgumentsProvider() {
- super("MASK_AFTER_SPECIAL_CHARS");
+ AlgorithmMaskExecuteArgumentsProvider() {
+ super("MASK_AFTER_SPECIAL_CHARS", PropertiesBuilder.build(new
Property("special-chars", "d1"), new Property("replace-char", "*")));
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
- Properties props = PropertiesBuilder.build(new
Property("special-chars", "d1"), new Property("replace-char", "*"));
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("null_value", props, null,
null),
- new MaskAlgorithmCaseAssert("empty_string", props, "", ""),
- new MaskAlgorithmCaseAssert("normal", props, "abcd134",
"abcd1**"),
- new
MaskAlgorithmCaseAssert("match_multiple_special_chars", props, "abcd1234d1234",
"abcd1********"),
- new MaskAlgorithmCaseAssert("not_match_special_chars",
props, "abcd234", "abcd234"));
+ new MaskAlgorithmExecuteCaseAssert("null_value", null,
null),
+ new MaskAlgorithmExecuteCaseAssert("empty_string", "", ""),
+ new MaskAlgorithmExecuteCaseAssert("normal", "abcd134",
"abcd1**"),
+ new
MaskAlgorithmExecuteCaseAssert("match_multiple_special_chars", "abcd1234d1234",
"abcd1********"),
+ new
MaskAlgorithmExecuteCaseAssert("not_match_special_chars", "abcd234",
"abcd234"));
}
}
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithmTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithmTest.java
index fb65aa4484d..fa8cf2cbb06 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithmTest.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithmTest.java
@@ -17,9 +17,11 @@
package org.apache.shardingsphere.mask.algorithm.cover;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteArgumentsProvider;
import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmAssertions;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitCaseAssert;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.params.ParameterizedTest;
@@ -38,40 +40,39 @@ class MaskBeforeSpecialCharsAlgorithmTest {
}
@ParameterizedTest(name = "{0}: {1}")
- @ArgumentsSource(AlgorithmMaskArgumentsProvider.class)
+ @ArgumentsSource(AlgorithmMaskExecuteArgumentsProvider.class)
void assertMask(final String type, @SuppressWarnings("unused") final
String name, final Properties props, final Object plainValue, final Object
maskedValue) {
MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
}
- private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmInitArgumentsProvider {
AlgorithmInitArgumentsProvider() {
super("MASK_BEFORE_SPECIAL_CHARS");
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
+ protected Collection<MaskAlgorithmInitCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("empty_special_char",
PropertiesBuilder.build(new Property("special-chars", ""))),
- new MaskAlgorithmCaseAssert("empty_replace_char",
PropertiesBuilder.build(new Property("special-chars", "d1"), new
Property("replace-char", ""))));
+ new MaskAlgorithmInitCaseAssert("empty_special_char",
PropertiesBuilder.build(new Property("special-chars", ""))),
+ new MaskAlgorithmInitCaseAssert("empty_replace_char",
PropertiesBuilder.build(new Property("special-chars", "d1"), new
Property("replace-char", ""))));
}
}
- private static class AlgorithmMaskArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ private static class AlgorithmMaskExecuteArgumentsProvider extends
MaskAlgorithmExecuteArgumentsProvider {
- AlgorithmMaskArgumentsProvider() {
- super("MASK_BEFORE_SPECIAL_CHARS");
+ AlgorithmMaskExecuteArgumentsProvider() {
+ super("MASK_BEFORE_SPECIAL_CHARS", PropertiesBuilder.build(new
Property("special-chars", "d1"), new Property("replace-char", "*")));
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
- Properties props = PropertiesBuilder.build(new
Property("special-chars", "d1"), new Property("replace-char", "*"));
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("null_value", props, null,
null),
- new MaskAlgorithmCaseAssert("empty_string", props, "", ""),
- new MaskAlgorithmCaseAssert("normal", props, "abcd134",
"***d134"),
- new
MaskAlgorithmCaseAssert("match_multiple_special_chars", props, "abcd1234d1234",
"***d1234d1234"),
- new MaskAlgorithmCaseAssert("not_match_special_chars",
props, "abcd234", "abcd234"));
+ new MaskAlgorithmExecuteCaseAssert("null_value", null,
null),
+ new MaskAlgorithmExecuteCaseAssert("empty_string", "", ""),
+ new MaskAlgorithmExecuteCaseAssert("normal", "abcd134",
"***d134"),
+ new
MaskAlgorithmExecuteCaseAssert("match_multiple_special_chars", "abcd1234d1234",
"***d1234d1234"),
+ new
MaskAlgorithmExecuteCaseAssert("not_match_special_chars", "abcd234",
"abcd234"));
}
}
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithmTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithmTest.java
index ea32beddb40..d61eeb45c19 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithmTest.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithmTest.java
@@ -17,9 +17,11 @@
package org.apache.shardingsphere.mask.algorithm.cover;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmArgumentsProvider;
import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmAssertions;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitCaseAssert;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.params.ParameterizedTest;
@@ -38,53 +40,69 @@ class MaskFirstNLastMMaskAlgorithmTest {
}
@ParameterizedTest(name = "{0}: {1}")
- @ArgumentsSource(AlgorithmMaskArgumentsProvider.class)
+ @ArgumentsSource(AlgorithmMaskExecuteArgumentsProvider.class)
void assertMask(final String type, @SuppressWarnings("unused") final
String name, final Properties props, final Object plainValue, final Object
maskedValue) {
MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
}
- private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ @ParameterizedTest(name = "{0}: {1}")
+ @ArgumentsSource(AlgorithmMaskExecuteWithSameNMArgumentsProvider.class)
+ void assertMaskWithSameNM(final String type, @SuppressWarnings("unused")
final String name, final Properties props, final Object plainValue, final
Object maskedValue) {
+ MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
+ }
+
+ private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmInitArgumentsProvider {
AlgorithmInitArgumentsProvider() {
super("MASK_FIRST_N_LAST_M");
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
+ protected Collection<MaskAlgorithmInitCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("empty_first_N",
PropertiesBuilder.build(new Property("first-n", ""), new Property("last-m",
"5"), new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("empty_last_M",
PropertiesBuilder.build(new Property("first-n", "3"), new Property("last-m",
""), new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("empty_replace_char",
PropertiesBuilder.build(new Property("first-n", "3"), new Property("last-m",
"5"), new Property("replace-char", ""))));
+ new MaskAlgorithmInitCaseAssert("empty_first_N",
PropertiesBuilder.build(new Property("first-n", ""), new Property("last-m",
"5"), new Property("replace-char", "*"))),
+ new MaskAlgorithmInitCaseAssert("empty_last_M",
PropertiesBuilder.build(new Property("first-n", "3"), new Property("last-m",
""), new Property("replace-char", "*"))),
+ new MaskAlgorithmInitCaseAssert("empty_replace_char",
PropertiesBuilder.build(new Property("first-n", "3"), new Property("last-m",
"5"), new Property("replace-char", ""))));
}
}
- private static class AlgorithmMaskArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ private static class AlgorithmMaskExecuteArgumentsProvider extends
MaskAlgorithmExecuteArgumentsProvider {
- AlgorithmMaskArgumentsProvider() {
- super("MASK_FIRST_N_LAST_M");
+ AlgorithmMaskExecuteArgumentsProvider() {
+ super("MASK_FIRST_N_LAST_M", PropertiesBuilder.build(new
Property("first-n", "3"), new Property("last-m", "5"), new
Property("replace-char", "*")));
+ }
+
+ @Override
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
+ return Arrays.asList(
+ new MaskAlgorithmExecuteCaseAssert("null_value", null,
null),
+ new MaskAlgorithmExecuteCaseAssert("empty_string", "", ""),
+ new MaskAlgorithmExecuteCaseAssert("normal_with_diff",
"abc123456", "***1*****"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_first_N_with_diff", "ab",
"**"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_first_N_with_diff", "abc", "***"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_last_M_with_diff", "abc1",
"****"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_last_M_with_diff", "abc12",
"*****"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_first_N_plus_last_M_with_diff",
"abc1234", "*******"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_first_N_plus_last_M_with_diff",
"abc12345", "********"));
+ }
+ }
+
+ private static class AlgorithmMaskExecuteWithSameNMArgumentsProvider
extends MaskAlgorithmExecuteArgumentsProvider {
+
+ AlgorithmMaskExecuteWithSameNMArgumentsProvider() {
+ super("MASK_FIRST_N_LAST_M", PropertiesBuilder.build(new
Property("first-n", "5"), new Property("last-m", "5"), new
Property("replace-char", "*")));
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
- Properties diffProps = PropertiesBuilder.build(new
Property("first-n", "3"), new Property("last-m", "5"), new
Property("replace-char", "*"));
- Properties sameProps = PropertiesBuilder.build(new
Property("first-n", "5"), new Property("last-m", "5"), new
Property("replace-char", "*"));
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("null_value", diffProps, null,
null),
- new MaskAlgorithmCaseAssert("empty_string", diffProps, "",
""),
- new MaskAlgorithmCaseAssert("normal_with_diff", diffProps,
"abc123456", "***1*****"),
- new MaskAlgorithmCaseAssert("normal_with_same", sameProps,
"abc123456789", "*****34*****"),
- new
MaskAlgorithmCaseAssert("length_less_than_first_N_with_diff", diffProps, "ab",
"**"),
- new
MaskAlgorithmCaseAssert("length_less_than_first_N_with_same", sameProps, "abc",
"***"),
- new
MaskAlgorithmCaseAssert("length_equals_first_N_with_diff", diffProps, "abc",
"***"),
- new
MaskAlgorithmCaseAssert("length_equals_first_N_with_same", sameProps, "abc12",
"*****"),
- new
MaskAlgorithmCaseAssert("length_less_than_last_M_with_diff", diffProps, "abc1",
"****"),
- new
MaskAlgorithmCaseAssert("length_less_than_last_M_with_same", sameProps, "abc1",
"****"),
- new
MaskAlgorithmCaseAssert("length_equals_last_M_with_diff", diffProps, "abc12",
"*****"),
- new
MaskAlgorithmCaseAssert("length_equals_last_M_with_same", sameProps, "abc12",
"*****"),
- new
MaskAlgorithmCaseAssert("length_less_than_first_N_plus_last_M_with_diff",
diffProps, "abc1234", "*******"),
- new
MaskAlgorithmCaseAssert("length_less_than_first_N_plus_last_M_with_same",
sameProps, "abc123456", "*********"),
- new
MaskAlgorithmCaseAssert("length_equals_first_N_plus_last_M_with_diff",
diffProps, "abc12345", "********"),
- new
MaskAlgorithmCaseAssert("length_equals_first_N_plus_last_M_with_same",
sameProps, "abc1234567", "**********"));
+ new MaskAlgorithmExecuteCaseAssert("normal_with_same",
"abc123456789", "*****34*****"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_first_N_with_same", "abc",
"***"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_first_N_with_same", "abc12",
"*****"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_last_M_with_same", "abc1",
"****"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_last_M_with_same", "abc12",
"*****"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_first_N_plus_last_M_with_same",
"abc123456", "*********"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_first_N_plus_last_M_with_same",
"abc1234567", "**********"));
}
}
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithmTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithmTest.java
index 937717beb83..c96e9c14257 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithmTest.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithmTest.java
@@ -17,9 +17,11 @@
package org.apache.shardingsphere.mask.algorithm.cover;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmArgumentsProvider;
import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmAssertions;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.init.MaskAlgorithmInitCaseAssert;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.params.ParameterizedTest;
@@ -38,52 +40,68 @@ class MaskFromXToYMaskAlgorithmTest {
}
@ParameterizedTest(name = "{0}: {1}")
- @ArgumentsSource(AlgorithmMaskArgumentsProvider.class)
+ @ArgumentsSource(AlgorithmMaskExecuteArgumentsProvider.class)
void assertMask(final String type, @SuppressWarnings("unused") final
String name, final Properties props, final Object plainValue, final Object
maskedValue) {
MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
}
- private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ @ParameterizedTest(name = "{0}: {1}")
+ @ArgumentsSource(AlgorithmMaskExecuteWithSameXYArgumentsProvider.class)
+ void assertMaskWithSameXY(final String type, @SuppressWarnings("unused")
final String name, final Properties props, final Object plainValue, final
Object maskedValue) {
+ MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
+ }
+
+ private static class AlgorithmInitArgumentsProvider extends
MaskAlgorithmInitArgumentsProvider {
AlgorithmInitArgumentsProvider() {
super("MASK_FROM_X_TO_Y");
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
+ protected Collection<MaskAlgorithmInitCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("empty_from_X",
PropertiesBuilder.build(new Property("from-x", ""), new Property("to-y", "5"),
new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("empty_to_Y",
PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y", ""),
new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("empty_replace_char",
PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y", "5"),
new Property("replace-char", ""))),
- new MaskAlgorithmCaseAssert("negative_from_X",
PropertiesBuilder.build(new Property("from-x", "-3"), new Property("to-y",
"5"), new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("negative_to_Y",
PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y",
"-5"), new Property("replace-char", "*"))),
- new MaskAlgorithmCaseAssert("from_X_greater_than_to_Y",
PropertiesBuilder.build(new Property("from-x", "5"), new Property("to-y", "2"),
new Property("replace-char", ""))));
+ new MaskAlgorithmInitCaseAssert("empty_from_X",
PropertiesBuilder.build(new Property("from-x", ""), new Property("to-y", "5"),
new Property("replace-char", "*"))),
+ new MaskAlgorithmInitCaseAssert("empty_to_Y",
PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y", ""),
new Property("replace-char", "*"))),
+ new MaskAlgorithmInitCaseAssert("empty_replace_char",
PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y", "5"),
new Property("replace-char", ""))),
+ new MaskAlgorithmInitCaseAssert("negative_from_X",
PropertiesBuilder.build(new Property("from-x", "-3"), new Property("to-y",
"5"), new Property("replace-char", "*"))),
+ new MaskAlgorithmInitCaseAssert("negative_to_Y",
PropertiesBuilder.build(new Property("from-x", "3"), new Property("to-y",
"-5"), new Property("replace-char", "*"))),
+ new
MaskAlgorithmInitCaseAssert("from_X_greater_than_to_Y",
PropertiesBuilder.build(new Property("from-x", "5"), new Property("to-y", "2"),
new Property("replace-char", ""))));
}
}
- private static class AlgorithmMaskArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ private static class AlgorithmMaskExecuteArgumentsProvider extends
MaskAlgorithmExecuteArgumentsProvider {
- AlgorithmMaskArgumentsProvider() {
- super("MASK_FROM_X_TO_Y");
+ AlgorithmMaskExecuteArgumentsProvider() {
+ super("MASK_FROM_X_TO_Y", PropertiesBuilder.build(new
Property("from-x", "3"), new Property("to-y", "5"), new
Property("replace-char", "*")));
+ }
+
+ @Override
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
+ return Arrays.asList(
+ new MaskAlgorithmExecuteCaseAssert("null_value", null,
null),
+ new MaskAlgorithmExecuteCaseAssert("empty_string", "", ""),
+ new MaskAlgorithmExecuteCaseAssert("normal_with_diff",
"abc123456", "abc***456"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_from_X_plus_one_with_diff",
"abc", "abc"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_from_X_plus_one_with_diff",
"abc1", "abc*"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_to_Y_plus_one_with_diff",
"abc12", "abc**"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_to_Y_plus_one_with_diff",
"abc123", "abc***"));
+ }
+ }
+
+ private static class AlgorithmMaskExecuteWithSameXYArgumentsProvider
extends MaskAlgorithmExecuteArgumentsProvider {
+
+ AlgorithmMaskExecuteWithSameXYArgumentsProvider() {
+ super("MASK_FROM_X_TO_Y", PropertiesBuilder.build(new
Property("from-x", "5"), new Property("to-y", "5"), new
Property("replace-char", "*")));
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
- Properties diffProps = PropertiesBuilder.build(new
Property("from-x", "3"), new Property("to-y", "5"), new
Property("replace-char", "*"));
- Properties sameProps = PropertiesBuilder.build(new
Property("from-x", "5"), new Property("to-y", "5"), new
Property("replace-char", "*"));
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("null_value", diffProps, null,
null),
- new MaskAlgorithmCaseAssert("empty_string", diffProps, "",
""),
- new MaskAlgorithmCaseAssert("normal_with_diff", diffProps,
"abc123456", "abc***456"),
- new MaskAlgorithmCaseAssert("normal_with_same", sameProps,
"abc123456", "abc12*456"),
- new
MaskAlgorithmCaseAssert("length_less_than_from_X_plus_one_with_diff",
diffProps, "abc", "abc"),
- new
MaskAlgorithmCaseAssert("length_less_than_from_X_plus_one_with_same",
sameProps, "abc", "abc"),
- new
MaskAlgorithmCaseAssert("length_equals_from_X_plus_one_with_diff", diffProps,
"abc1", "abc*"),
- new
MaskAlgorithmCaseAssert("length_equals_from_X_plus_one_with_same", sameProps,
"abc123", "abc12*"),
- new
MaskAlgorithmCaseAssert("length_less_than_to_Y_plus_one_with_diff", diffProps,
"abc12", "abc**"),
- new
MaskAlgorithmCaseAssert("length_less_than_to_Y_plus_one_with_same", sameProps,
"abc12", "abc12"),
- new
MaskAlgorithmCaseAssert("length_equals_to_Y_plus_one_with_diff", diffProps,
"abc123", "abc***"),
- new
MaskAlgorithmCaseAssert("length_equals_to_Y_plus_one_with_same", sameProps,
"abc123", "abc12*"));
+ new MaskAlgorithmExecuteCaseAssert("normal_with_same",
"abc123456", "abc12*456"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_from_X_plus_one_with_same",
"abc", "abc"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_from_X_plus_one_with_same",
"abc123", "abc12*"),
+ new
MaskAlgorithmExecuteCaseAssert("length_less_than_to_Y_plus_one_with_same",
"abc12", "abc12"),
+ new
MaskAlgorithmExecuteCaseAssert("length_equals_to_Y_plus_one_with_same",
"abc123", "abc12*"));
}
}
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/hash/MD5MaskAlgorithmTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/hash/MD5MaskAlgorithmTest.java
index df45960ff60..42363e015ec 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/hash/MD5MaskAlgorithmTest.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/hash/MD5MaskAlgorithmTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.mask.algorithm.hash;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmArgumentsProvider;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteArgumentsProvider;
import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmAssertions;
-import
org.apache.shardingsphere.mask.algorithm.parameterized.MaskAlgorithmCaseAssert;
+import
org.apache.shardingsphere.mask.algorithm.parameterized.execute.MaskAlgorithmExecuteCaseAssert;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.params.ParameterizedTest;
@@ -27,30 +27,46 @@ import org.junit.jupiter.params.provider.ArgumentsSource;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.Properties;
class MD5MaskAlgorithmTest {
@ParameterizedTest(name = "{0}: {1}")
- @ArgumentsSource(AlgorithmMaskArgumentsProvider.class)
+ @ArgumentsSource(AlgorithmMaskExecuteArgumentsProvider.class)
void assertMask(final String type, @SuppressWarnings("unused") final
String name, final Properties props, final Object plainValue, final Object
maskedValue) {
MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
}
- private static class AlgorithmMaskArgumentsProvider extends
MaskAlgorithmArgumentsProvider {
+ @ParameterizedTest(name = "{0}: {1}")
+ @ArgumentsSource(AlgorithmMaskExecuteWithSaltArgumentsProvider.class)
+ void assertMaskWithSalt(final String type, @SuppressWarnings("unused")
final String name, final Properties props, final Object plainValue, final
Object maskedValue) {
+ MaskAlgorithmAssertions.assertMask(type, props, plainValue,
maskedValue);
+ }
+
+ private static class AlgorithmMaskExecuteArgumentsProvider extends
MaskAlgorithmExecuteArgumentsProvider {
- AlgorithmMaskArgumentsProvider() {
- super("MD5");
+ AlgorithmMaskExecuteArgumentsProvider() {
+ super("MD5", new Properties());
}
@Override
- protected Collection<MaskAlgorithmCaseAssert> getCaseAsserts() {
- Properties propsWithoutSalt = new Properties();
- Properties propsWithSalt = PropertiesBuilder.build(new
Property("salt", "202cb962ac5907"));
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
return Arrays.asList(
- new MaskAlgorithmCaseAssert("null_value",
propsWithoutSalt, null, null),
- new MaskAlgorithmCaseAssert("without_salt",
propsWithoutSalt, "abc123456", "0659c7992e268962384eb17fafe88364"),
- new MaskAlgorithmCaseAssert("with_salt", propsWithSalt,
"abc123456", "02d44390e9354b72dd2aa78d55016f7f"));
+ new MaskAlgorithmExecuteCaseAssert("null_value", null,
null),
+ new MaskAlgorithmExecuteCaseAssert("without_salt",
"abc123456", "0659c7992e268962384eb17fafe88364"));
+ }
+ }
+
+ private static class AlgorithmMaskExecuteWithSaltArgumentsProvider extends
MaskAlgorithmExecuteArgumentsProvider {
+
+ AlgorithmMaskExecuteWithSaltArgumentsProvider() {
+ super("MD5", PropertiesBuilder.build(new Property("salt",
"202cb962ac5907")));
+ }
+
+ @Override
+ protected Collection<MaskAlgorithmExecuteCaseAssert> getCaseAsserts() {
+ return Collections.singleton(new
MaskAlgorithmExecuteCaseAssert("with_salt", "abc123456",
"02d44390e9354b72dd2aa78d55016f7f"));
}
}
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmArgumentsProvider.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/execute/MaskAlgorithmExecuteArgumentsProvider.java
similarity index 77%
copy from
features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmArgumentsProvider.java
copy to
features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/execute/MaskAlgorithmExecuteArgumentsProvider.java
index 85e926c6473..ae1d2200945 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmArgumentsProvider.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/execute/MaskAlgorithmExecuteArgumentsProvider.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mask.algorithm.parameterized;
+package org.apache.shardingsphere.mask.algorithm.parameterized.execute;
import lombok.RequiredArgsConstructor;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -23,17 +23,20 @@ import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.ArgumentsProvider;
import java.util.Collection;
+import java.util.Properties;
import java.util.stream.Stream;
@RequiredArgsConstructor
-public abstract class MaskAlgorithmArgumentsProvider implements
ArgumentsProvider {
+public abstract class MaskAlgorithmExecuteArgumentsProvider implements
ArgumentsProvider {
private final String type;
+ private final Properties props;
+
@Override
public Stream<? extends Arguments> provideArguments(final ExtensionContext
extensionContext) {
- return getCaseAsserts().stream().map(each -> Arguments.of(type,
each.getName(), each.getProps(), each.getPlainValue(), each.getMaskedValue()));
+ return getCaseAsserts().stream().map(each -> Arguments.of(type,
each.getName(), props, each.getPlainValue(), each.getMaskedValue()));
}
- protected abstract Collection<MaskAlgorithmCaseAssert> getCaseAsserts();
+ protected abstract Collection<MaskAlgorithmExecuteCaseAssert>
getCaseAsserts();
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmCaseAssert.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/execute/MaskAlgorithmExecuteCaseAssert.java
similarity index 76%
copy from
features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmCaseAssert.java
copy to
features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/execute/MaskAlgorithmExecuteCaseAssert.java
index 387746895e8..d1a2440d3d7 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmCaseAssert.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/execute/MaskAlgorithmExecuteCaseAssert.java
@@ -15,26 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mask.algorithm.parameterized;
+package org.apache.shardingsphere.mask.algorithm.parameterized.execute;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
-import java.util.Properties;
-
@RequiredArgsConstructor
@Getter
-public final class MaskAlgorithmCaseAssert {
+public final class MaskAlgorithmExecuteCaseAssert {
private final String name;
- private final Properties props;
-
private final Object plainValue;
private final Object maskedValue;
-
- public MaskAlgorithmCaseAssert(final String name, final Properties props) {
- this(name, props, null, null);
- }
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmArgumentsProvider.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/init/MaskAlgorithmInitArgumentsProvider.java
similarity index 80%
rename from
features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmArgumentsProvider.java
rename to
features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/init/MaskAlgorithmInitArgumentsProvider.java
index 85e926c6473..1e7c503cbb9 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmArgumentsProvider.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/init/MaskAlgorithmInitArgumentsProvider.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mask.algorithm.parameterized;
+package org.apache.shardingsphere.mask.algorithm.parameterized.init;
import lombok.RequiredArgsConstructor;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -26,14 +26,14 @@ import java.util.Collection;
import java.util.stream.Stream;
@RequiredArgsConstructor
-public abstract class MaskAlgorithmArgumentsProvider implements
ArgumentsProvider {
+public abstract class MaskAlgorithmInitArgumentsProvider implements
ArgumentsProvider {
private final String type;
@Override
public Stream<? extends Arguments> provideArguments(final ExtensionContext
extensionContext) {
- return getCaseAsserts().stream().map(each -> Arguments.of(type,
each.getName(), each.getProps(), each.getPlainValue(), each.getMaskedValue()));
+ return getCaseAsserts().stream().map(each -> Arguments.of(type,
each.getName(), each.getProps()));
}
- protected abstract Collection<MaskAlgorithmCaseAssert> getCaseAsserts();
+ protected abstract Collection<MaskAlgorithmInitCaseAssert>
getCaseAsserts();
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmCaseAssert.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/init/MaskAlgorithmInitCaseAssert.java
similarity index 75%
rename from
features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmCaseAssert.java
rename to
features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/init/MaskAlgorithmInitCaseAssert.java
index 387746895e8..3fbabfaec3c 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/MaskAlgorithmCaseAssert.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/parameterized/init/MaskAlgorithmInitCaseAssert.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.mask.algorithm.parameterized;
+package org.apache.shardingsphere.mask.algorithm.parameterized.init;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -24,17 +24,9 @@ import java.util.Properties;
@RequiredArgsConstructor
@Getter
-public final class MaskAlgorithmCaseAssert {
+public final class MaskAlgorithmInitCaseAssert {
private final String name;
private final Properties props;
-
- private final Object plainValue;
-
- private final Object maskedValue;
-
- public MaskAlgorithmCaseAssert(final String name, final Properties props) {
- this(name, props, null, null);
- }
}