This is an automated email from the ASF dual-hosted git repository.
chengzhang 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 384a8d212bd Rename MaskAlgorithmPropertiesChecker (#30563)
384a8d212bd is described below
commit 384a8d212bde3d519772ee8665084a78c2cae158
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Mar 20 19:08:41 2024 +0800
Rename MaskAlgorithmPropertiesChecker (#30563)
* Rename MaskAlgorithmPropertiesChecker
* Rename MaskAlgorithmPropertiesChecker
---
...er.java => MaskAlgorithmPropertiesChecker.java} | 50 +++++++++++-----------
.../cover/KeepFirstNLastMMaskAlgorithm.java | 8 ++--
.../algorithm/cover/KeepFromXToYMaskAlgorithm.java | 8 ++--
.../cover/MaskAfterSpecialCharsAlgorithm.java | 6 +--
.../cover/MaskBeforeSpecialCharsAlgorithm.java | 6 +--
.../cover/MaskFirstNLastMMaskAlgorithm.java | 8 ++--
.../algorithm/cover/MaskFromXToYMaskAlgorithm.java | 8 ++--
...ava => MaskAlgorithmPropertiesCheckerTest.java} | 41 ++++++++----------
8 files changed, 63 insertions(+), 72 deletions(-)
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropertiesChecker.java
similarity index 51%
rename from
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java
rename to
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropertiesChecker.java
index 9d089514c9c..db035b4440a 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsChecker.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropertiesChecker.java
@@ -26,56 +26,54 @@ import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.util.Properties;
/**
- * Mask algorithm props checker.
+ * Mask algorithm properties checker.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class MaskAlgorithmPropsChecker {
+public final class MaskAlgorithmPropertiesChecker {
/**
- * Check single char config.
+ * Check single char.
*
- * @param props props
- * @param singleCharConfigKey single char config key
+ * @param props properties to be checked
+ * @param propKey properties key to be checked
* @param algorithm mask algorithm
*/
- public static void checkSingleCharConfiguration(final Properties props,
final String singleCharConfigKey, final MaskAlgorithm<?, ?> algorithm) {
- checkRequiredPropertyConfiguration(props, singleCharConfigKey,
algorithm);
- ShardingSpherePreconditions.checkState(1 ==
props.getProperty(singleCharConfigKey).length(),
- () -> new AlgorithmInitializationException(algorithm, "%s's
length must be one", singleCharConfigKey));
+ public static void checkSingleChar(final Properties props, final String
propKey, final MaskAlgorithm<?, ?> algorithm) {
+ checkRequiredProperty(props, propKey, algorithm);
+ ShardingSpherePreconditions.checkState(1 ==
props.getProperty(propKey).length(), () -> new
AlgorithmInitializationException(algorithm, "%s's length must be one",
propKey));
}
/**
- * Check at least one char config.
+ * Check at least one char.
*
- * @param props props
- * @param atLeastOneCharConfigKey at least one char config key
+ * @param props properties to be checked
+ * @param propKey properties key to be checked
* @param algorithm mask algorithm
*/
- public static void checkAtLeastOneCharConfiguration(final Properties
props, final String atLeastOneCharConfigKey, final MaskAlgorithm<?, ?>
algorithm) {
- checkRequiredPropertyConfiguration(props, atLeastOneCharConfigKey,
algorithm);
-
ShardingSpherePreconditions.checkState(props.getProperty(atLeastOneCharConfigKey).length()
> 0,
- () -> new AlgorithmInitializationException(algorithm, "%s's
length must be at least one", atLeastOneCharConfigKey));
+ public static void checkAtLeastOneChar(final Properties props, final
String propKey, final MaskAlgorithm<?, ?> algorithm) {
+ checkRequiredProperty(props, propKey, algorithm);
+
ShardingSpherePreconditions.checkState(props.getProperty(propKey).length() > 0,
() -> new AlgorithmInitializationException(algorithm, "%s's length must be at
least one", propKey));
}
/**
- * Check required property configuration.
+ * check positive integer.
*
- * @param props props
- * @param positiveIntegerTypeConfigKey positive integer type config key
+ * @param props properties to be checked
+ * @param propKey properties key to be checked
* @param algorithm mask algorithm
* @throws AlgorithmInitializationException algorithm initialization
exception
*/
- public static void checkPositiveIntegerConfiguration(final Properties
props, final String positiveIntegerTypeConfigKey, final MaskAlgorithm<?, ?>
algorithm) {
- checkRequiredPropertyConfiguration(props,
positiveIntegerTypeConfigKey, algorithm);
+ public static void checkPositiveInteger(final Properties props, final
String propKey, final MaskAlgorithm<?, ?> algorithm) {
+ checkRequiredProperty(props, propKey, algorithm);
try {
- int integerValue =
Integer.parseInt(props.getProperty(positiveIntegerTypeConfigKey));
- ShardingSpherePreconditions.checkState(integerValue > 0, () -> new
AlgorithmInitializationException(algorithm, "%s must be a positive integer.",
positiveIntegerTypeConfigKey));
+ int integerValue = Integer.parseInt(props.getProperty(propKey));
+ ShardingSpherePreconditions.checkState(integerValue > 0, () -> new
AlgorithmInitializationException(algorithm, "%s must be a positive integer.",
propKey));
} catch (final NumberFormatException ex) {
- throw new AlgorithmInitializationException(algorithm, "%s must be
a valid integer number", positiveIntegerTypeConfigKey);
+ throw new AlgorithmInitializationException(algorithm, "%s must be
a valid integer number", propKey);
}
}
- private static void checkRequiredPropertyConfiguration(final Properties
props, final String requiredPropertyConfigKey, final MaskAlgorithm<?, ?>
algorithm) {
-
ShardingSpherePreconditions.checkState(props.containsKey(requiredPropertyConfigKey),
() -> new AlgorithmInitializationException(algorithm, "%s is required",
requiredPropertyConfigKey));
+ private static void checkRequiredProperty(final Properties props, final
String requiredPropKey, final MaskAlgorithm<?, ?> algorithm) {
+
ShardingSpherePreconditions.checkState(props.containsKey(requiredPropKey), ()
-> new AlgorithmInitializationException(algorithm, "%s is required",
requiredPropKey));
}
}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java
index 0295c2f9c2a..2e72f280031 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFirstNLastMMaskAlgorithm.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mask.algorithm.cover;
import com.google.common.base.Strings;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropertiesChecker;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.util.Properties;
@@ -48,17 +48,17 @@ public final class KeepFirstNLastMMaskAlgorithm implements
MaskAlgorithm<Object,
}
private Integer createFirstN(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props,
FIRST_N, this);
+ MaskAlgorithmPropertiesChecker.checkPositiveInteger(props, FIRST_N,
this);
return Integer.parseInt(props.getProperty(FIRST_N));
}
private Integer createLastM(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props,
LAST_M, this);
+ MaskAlgorithmPropertiesChecker.checkPositiveInteger(props, LAST_M,
this);
return Integer.parseInt(props.getProperty(LAST_M));
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props,
REPLACE_CHAR, this);
+ MaskAlgorithmPropertiesChecker.checkSingleChar(props, REPLACE_CHAR,
this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java
index 22bd1730a6b..3be6c72b8be 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/KeepFromXToYMaskAlgorithm.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.mask.algorithm.cover;
import com.google.common.base.Strings;
import
org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropertiesChecker;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.util.Properties;
@@ -51,17 +51,17 @@ public final class KeepFromXToYMaskAlgorithm implements
MaskAlgorithm<Object, St
}
private Integer createFromX(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props,
FROM_X, this);
+ MaskAlgorithmPropertiesChecker.checkPositiveInteger(props, FROM_X,
this);
return Integer.parseInt(props.getProperty(FROM_X));
}
private Integer createToY(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props,
TO_Y, this);
+ MaskAlgorithmPropertiesChecker.checkPositiveInteger(props, TO_Y, this);
return Integer.parseInt(props.getProperty(TO_Y));
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props,
REPLACE_CHAR, this);
+ MaskAlgorithmPropertiesChecker.checkSingleChar(props, REPLACE_CHAR,
this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java
index f2317acf0b2..2443c7939bb 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mask.algorithm.cover;
import com.google.common.base.Strings;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropertiesChecker;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.util.Properties;
@@ -43,12 +43,12 @@ public final class MaskAfterSpecialCharsAlgorithm
implements MaskAlgorithm<Objec
}
private String createSpecialChars(final Properties props) {
- MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(props,
SPECIAL_CHARS, this);
+ MaskAlgorithmPropertiesChecker.checkAtLeastOneChar(props,
SPECIAL_CHARS, this);
return props.getProperty(SPECIAL_CHARS);
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props,
REPLACE_CHAR, this);
+ MaskAlgorithmPropertiesChecker.checkSingleChar(props, REPLACE_CHAR,
this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java
index 44ecf231ff9..935ba814657 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mask.algorithm.cover;
import com.google.common.base.Strings;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropertiesChecker;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.util.Properties;
@@ -43,12 +43,12 @@ public final class MaskBeforeSpecialCharsAlgorithm
implements MaskAlgorithm<Obje
}
private String createSpecialChars(final Properties props) {
- MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(props,
SPECIAL_CHARS, this);
+ MaskAlgorithmPropertiesChecker.checkAtLeastOneChar(props,
SPECIAL_CHARS, this);
return props.getProperty(SPECIAL_CHARS);
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props,
REPLACE_CHAR, this);
+ MaskAlgorithmPropertiesChecker.checkSingleChar(props, REPLACE_CHAR,
this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java
index 069dd896db5..1949a41392c 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFirstNLastMMaskAlgorithm.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.mask.algorithm.cover;
import com.google.common.base.Strings;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropertiesChecker;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.util.Properties;
@@ -48,17 +48,17 @@ public final class MaskFirstNLastMMaskAlgorithm implements
MaskAlgorithm<Object,
}
private Integer createFirstN(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props,
FIRST_N, this);
+ MaskAlgorithmPropertiesChecker.checkPositiveInteger(props, FIRST_N,
this);
return Integer.parseInt(props.getProperty(FIRST_N));
}
private Integer createLastM(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props,
LAST_M, this);
+ MaskAlgorithmPropertiesChecker.checkPositiveInteger(props, LAST_M,
this);
return Integer.parseInt(props.getProperty(LAST_M));
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props,
REPLACE_CHAR, this);
+ MaskAlgorithmPropertiesChecker.checkSingleChar(props, REPLACE_CHAR,
this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java
index db2fcf9a181..12fbb018cda 100644
---
a/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java
+++
b/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.mask.algorithm.cover;
import com.google.common.base.Strings;
import
org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException;
import
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropsChecker;
+import org.apache.shardingsphere.mask.algorithm.MaskAlgorithmPropertiesChecker;
import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
import java.util.Properties;
@@ -51,17 +51,17 @@ public final class MaskFromXToYMaskAlgorithm implements
MaskAlgorithm<Object, St
}
private Integer createFromX(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props,
FROM_X, this);
+ MaskAlgorithmPropertiesChecker.checkPositiveInteger(props, FROM_X,
this);
return Integer.parseInt(props.getProperty(FROM_X));
}
private Integer createToY(final Properties props) {
- MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(props,
TO_Y, this);
+ MaskAlgorithmPropertiesChecker.checkPositiveInteger(props, TO_Y, this);
return Integer.parseInt(props.getProperty(TO_Y));
}
private Character createReplaceChar(final Properties props) {
- MaskAlgorithmPropsChecker.checkSingleCharConfiguration(props,
REPLACE_CHAR, this);
+ MaskAlgorithmPropertiesChecker.checkSingleChar(props, REPLACE_CHAR,
this);
return props.getProperty(REPLACE_CHAR).charAt(0);
}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsCheckerTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropertiesCheckerTest.java
similarity index 53%
rename from
features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsCheckerTest.java
rename to
features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropertiesCheckerTest.java
index 4c5cb4cc47e..63b79f1bc0d 100644
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropsCheckerTest.java
+++
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/MaskAlgorithmPropertiesCheckerTest.java
@@ -25,90 +25,83 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-class MaskAlgorithmPropsCheckerTest {
+class MaskAlgorithmPropertiesCheckerTest {
@Test
void assertCheckSingleCharConfigWithLengthOne() {
-
MaskAlgorithmPropsChecker.checkSingleCharConfiguration(PropertiesBuilder.build(new
Property("singleChar", "1")), "singleChar", mockMaskAlgorithm());
+
MaskAlgorithmPropertiesChecker.checkSingleChar(PropertiesBuilder.build(new
Property("singleChar", "1")), "singleChar", mock(MaskAlgorithm.class));
}
@Test
void assertCheckSingleCharConfigWithEmptyString() {
assertThrows(AlgorithmInitializationException.class,
- () ->
MaskAlgorithmPropsChecker.checkSingleCharConfiguration(PropertiesBuilder.build(new
Property("singleChar", "")), "singleChar1", mockMaskAlgorithm()));
+ () ->
MaskAlgorithmPropertiesChecker.checkSingleChar(PropertiesBuilder.build(new
Property("singleChar", "")), "singleChar1", mock(MaskAlgorithm.class)));
}
@Test
void assertCheckSingleCharConfigWithDifferentKey() {
assertThrows(AlgorithmInitializationException.class,
- () ->
MaskAlgorithmPropsChecker.checkSingleCharConfiguration(PropertiesBuilder.build(new
Property("singleChar", "1")), "singleChar1", mockMaskAlgorithm()));
+ () ->
MaskAlgorithmPropertiesChecker.checkSingleChar(PropertiesBuilder.build(new
Property("singleChar", "1")), "singleChar1", mock(MaskAlgorithm.class)));
}
@Test
void assertCheckSingleCharConfigWithLengthMoreThanOne() {
assertThrows(AlgorithmInitializationException.class,
- () ->
MaskAlgorithmPropsChecker.checkSingleCharConfiguration(PropertiesBuilder.build(new
Property("singleChar", "123")), "singleChar", mockMaskAlgorithm()));
+ () ->
MaskAlgorithmPropertiesChecker.checkSingleChar(PropertiesBuilder.build(new
Property("singleChar", "123")), "singleChar", mock(MaskAlgorithm.class)));
}
@Test
void assertCheckSingleCharConfigWithNull() {
- assertThrows(AlgorithmInitializationException.class, () ->
MaskAlgorithmPropsChecker.checkSingleCharConfiguration(PropertiesBuilder.build(),
"singleChar", mockMaskAlgorithm()));
+ assertThrows(AlgorithmInitializationException.class, () ->
MaskAlgorithmPropertiesChecker.checkSingleChar(PropertiesBuilder.build(),
"singleChar", mock(MaskAlgorithm.class)));
}
@Test
void assertCheckAtLeastOneCharConfigWithLengthOne() {
-
MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(PropertiesBuilder.build(new
Property("AtLeastOneChar", "1")), "AtLeastOneChar", mockMaskAlgorithm());
+
MaskAlgorithmPropertiesChecker.checkAtLeastOneChar(PropertiesBuilder.build(new
Property("AtLeastOneChar", "1")), "AtLeastOneChar", mock(MaskAlgorithm.class));
}
@Test
void assertCheckAtLeastOneCharConfigWithLengthMoreThanOne() {
-
MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(PropertiesBuilder.build(new
Property("AtLeastOneChar", "1234")), "AtLeastOneChar", mockMaskAlgorithm());
+
MaskAlgorithmPropertiesChecker.checkAtLeastOneChar(PropertiesBuilder.build(new
Property("AtLeastOneChar", "1234")), "AtLeastOneChar",
mock(MaskAlgorithm.class));
}
@Test
void assertCheckAtLeastOneCharConfigWithEmptyString() {
assertThrows(AlgorithmInitializationException.class,
- () ->
MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(PropertiesBuilder.build(new
Property("AtLeastOneChar", "")), "AtLeastOneChar", mockMaskAlgorithm()));
+ () ->
MaskAlgorithmPropertiesChecker.checkAtLeastOneChar(PropertiesBuilder.build(new
Property("AtLeastOneChar", "")), "AtLeastOneChar", mock(MaskAlgorithm.class)));
}
@Test
void assertCheckAtLeastOneCharConfigWithNull() {
- assertThrows(AlgorithmInitializationException.class, () ->
MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(PropertiesBuilder.build(),
"AtLeastOneChar", mockMaskAlgorithm()));
+ assertThrows(AlgorithmInitializationException.class, () ->
MaskAlgorithmPropertiesChecker.checkAtLeastOneChar(PropertiesBuilder.build(),
"AtLeastOneChar", mock(MaskAlgorithm.class)));
}
@Test
void assertCheckAtLeastOneCharConfigWithDifferentKey() {
assertThrows(AlgorithmInitializationException.class,
- () ->
MaskAlgorithmPropsChecker.checkAtLeastOneCharConfiguration(PropertiesBuilder.build(new
Property("singleChar", "123")), "AtLeastOneChar", mockMaskAlgorithm()));
+ () ->
MaskAlgorithmPropertiesChecker.checkAtLeastOneChar(PropertiesBuilder.build(new
Property("singleChar", "123")), "AtLeastOneChar", mock(MaskAlgorithm.class)));
}
@Test
void assertCheckIntegerTypeConfigWithInteger() {
-
MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(PropertiesBuilder.build(new
Property("integerTypeConfigKey", "123")), "integerTypeConfigKey",
mockMaskAlgorithm());
+
MaskAlgorithmPropertiesChecker.checkPositiveInteger(PropertiesBuilder.build(new
Property("integerTypeConfigKey", "123")), "integerTypeConfigKey",
mock(MaskAlgorithm.class));
}
@Test
void assertCheckIntegerTypeConfigWithDifferentKey() {
- assertThrows(AlgorithmInitializationException.class,
- () ->
MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(PropertiesBuilder.build(new
Property("integerTypeConfigKey", "123")), "integerTypeConfigKey1",
mockMaskAlgorithm()));
+ assertThrows(AlgorithmInitializationException.class, () ->
MaskAlgorithmPropertiesChecker.checkPositiveInteger(
+ PropertiesBuilder.build(new Property("integerTypeConfigKey",
"123")), "integerTypeConfigKey1", mock(MaskAlgorithm.class)));
}
@Test
void assertCheckIntegerTypeConfigWithNotInteger() {
- assertThrows(AlgorithmInitializationException.class, () ->
MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(
- PropertiesBuilder.build(new Property("integerTypeConfigKey",
"123abc")), "integerTypeConfigKey", mockMaskAlgorithm()));
+ assertThrows(AlgorithmInitializationException.class, () ->
MaskAlgorithmPropertiesChecker.checkPositiveInteger(
+ PropertiesBuilder.build(new Property("integerTypeConfigKey",
"123abc")), "integerTypeConfigKey", mock(MaskAlgorithm.class)));
}
@Test
void assertCheckIntegerTypeConfigWithNull() {
- assertThrows(AlgorithmInitializationException.class, () ->
MaskAlgorithmPropsChecker.checkPositiveIntegerConfiguration(PropertiesBuilder.build(),
"integerTypeConfigKey", mockMaskAlgorithm()));
- }
-
- private MaskAlgorithm<?, ?> mockMaskAlgorithm() {
- MaskAlgorithm<?, ?> result = mock(MaskAlgorithm.class);
- when(result.getType()).thenReturn("maskType");
- return result;
+ assertThrows(AlgorithmInitializationException.class, () ->
MaskAlgorithmPropertiesChecker.checkPositiveInteger(PropertiesBuilder.build(),
"integerTypeConfigKey", mock(MaskAlgorithm.class)));
}
}