From 131360716b16b184cca4c9825d62ccb2daf310ee Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sat, 28 Oct 2023 19:43:46 +0800 Subject: [PATCH 1/4] Rename PropertiesPreconditions --- ...alkJobErrorHandlerPropertiesValidator.java | 8 ++-- ...ailJobErrorHandlerPropertiesValidator.java | 16 ++++---- ...hatJobErrorHandlerPropertiesValidator.java | 8 ++-- ...Rule.java => PropertiesPreconditions.java} | 39 ++++++++++--------- ....java => PropertiesPreconditionsTest.java} | 14 +++---- 5 files changed, 43 insertions(+), 42 deletions(-) rename infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/validate/{JobPropertiesValidateRule.java => PropertiesPreconditions.java} (52%) rename infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/validate/{JobPropertiesValidateRuleTest.java => PropertiesPreconditionsTest.java} (82%) diff --git a/ecosystem/error-handler/type/dingtalk/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java b/ecosystem/error-handler/type/dingtalk/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java index a652779f07..d84789f4fc 100644 --- a/ecosystem/error-handler/type/dingtalk/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java +++ b/ecosystem/error-handler/type/dingtalk/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.elasticjob.error.handler.dingtalk; import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator; -import org.apache.shardingsphere.elasticjob.infra.validate.JobPropertiesValidateRule; +import org.apache.shardingsphere.elasticjob.infra.validate.PropertiesPreconditions; import java.util.Properties; @@ -29,9 +29,9 @@ public final class DingtalkJobErrorHandlerPropertiesValidator implements JobErro @Override public void validate(final Properties props) { - JobPropertiesValidateRule.validateIsRequired(props, DingtalkPropertiesConstants.WEBHOOK); - JobPropertiesValidateRule.validateIsPositiveInteger(props, DingtalkPropertiesConstants.CONNECT_TIMEOUT_MILLISECONDS); - JobPropertiesValidateRule.validateIsPositiveInteger(props, DingtalkPropertiesConstants.READ_TIMEOUT_MILLISECONDS); + PropertiesPreconditions.checkRequired(props, DingtalkPropertiesConstants.WEBHOOK); + PropertiesPreconditions.checkPositiveInteger(props, DingtalkPropertiesConstants.CONNECT_TIMEOUT_MILLISECONDS); + PropertiesPreconditions.checkPositiveInteger(props, DingtalkPropertiesConstants.READ_TIMEOUT_MILLISECONDS); } @Override diff --git a/ecosystem/error-handler/type/email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidator.java b/ecosystem/error-handler/type/email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidator.java index 3b0fa050ad..6fb8a21918 100644 --- a/ecosystem/error-handler/type/email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidator.java +++ b/ecosystem/error-handler/type/email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidator.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.elasticjob.error.handler.email; import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator; -import org.apache.shardingsphere.elasticjob.infra.validate.JobPropertiesValidateRule; +import org.apache.shardingsphere.elasticjob.infra.validate.PropertiesPreconditions; import java.util.Properties; @@ -29,13 +29,13 @@ public final class EmailJobErrorHandlerPropertiesValidator implements JobErrorHa @Override public void validate(final Properties props) { - JobPropertiesValidateRule.validateIsRequired(props, EmailPropertiesConstants.HOST); - JobPropertiesValidateRule.validateIsRequired(props, EmailPropertiesConstants.PORT); - JobPropertiesValidateRule.validateIsPositiveInteger(props, EmailPropertiesConstants.PORT); - JobPropertiesValidateRule.validateIsRequired(props, EmailPropertiesConstants.USERNAME); - JobPropertiesValidateRule.validateIsRequired(props, EmailPropertiesConstants.PASSWORD); - JobPropertiesValidateRule.validateIsRequired(props, EmailPropertiesConstants.FROM); - JobPropertiesValidateRule.validateIsRequired(props, EmailPropertiesConstants.TO); + PropertiesPreconditions.checkRequired(props, EmailPropertiesConstants.HOST); + PropertiesPreconditions.checkRequired(props, EmailPropertiesConstants.PORT); + PropertiesPreconditions.checkPositiveInteger(props, EmailPropertiesConstants.PORT); + PropertiesPreconditions.checkRequired(props, EmailPropertiesConstants.USERNAME); + PropertiesPreconditions.checkRequired(props, EmailPropertiesConstants.PASSWORD); + PropertiesPreconditions.checkRequired(props, EmailPropertiesConstants.FROM); + PropertiesPreconditions.checkRequired(props, EmailPropertiesConstants.TO); } @Override diff --git a/ecosystem/error-handler/type/wechat/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidator.java b/ecosystem/error-handler/type/wechat/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidator.java index b0b07ff544..00a47bc25a 100644 --- a/ecosystem/error-handler/type/wechat/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidator.java +++ b/ecosystem/error-handler/type/wechat/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidator.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.elasticjob.error.handler.wechat; import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator; -import org.apache.shardingsphere.elasticjob.infra.validate.JobPropertiesValidateRule; +import org.apache.shardingsphere.elasticjob.infra.validate.PropertiesPreconditions; import java.util.Properties; @@ -29,9 +29,9 @@ public final class WechatJobErrorHandlerPropertiesValidator implements JobErrorH @Override public void validate(final Properties props) { - JobPropertiesValidateRule.validateIsRequired(props, WechatPropertiesConstants.WEBHOOK); - JobPropertiesValidateRule.validateIsPositiveInteger(props, WechatPropertiesConstants.CONNECT_TIMEOUT_MILLISECONDS); - JobPropertiesValidateRule.validateIsPositiveInteger(props, WechatPropertiesConstants.READ_TIMEOUT_MILLISECONDS); + PropertiesPreconditions.checkRequired(props, WechatPropertiesConstants.WEBHOOK); + PropertiesPreconditions.checkPositiveInteger(props, WechatPropertiesConstants.CONNECT_TIMEOUT_MILLISECONDS); + PropertiesPreconditions.checkPositiveInteger(props, WechatPropertiesConstants.READ_TIMEOUT_MILLISECONDS); } @Override diff --git a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/validate/JobPropertiesValidateRule.java b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditions.java similarity index 52% rename from infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/validate/JobPropertiesValidateRule.java rename to infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditions.java index a13d04ad03..79b175e0b1 100644 --- a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/validate/JobPropertiesValidateRule.java +++ b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditions.java @@ -24,37 +24,38 @@ import java.util.Properties; /** - * Job properties validate rule. + * Properties preconditions. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) -public final class JobPropertiesValidateRule { +public final class PropertiesPreconditions { /** - * Validate property value is required. + * Check property value is required. * - * @param props properties to be validated - * @param key property key to be validated + * @param props properties to be checked + * @param key property key to be checked */ - public static void validateIsRequired(final Properties props, final String key) { - Preconditions.checkNotNull(props.getProperty(key), "The property `%s` is required.", key); + public static void checkRequired(final Properties props, final String key) { + Preconditions.checkState(props.containsKey(key), "The property `%s` is required.", key); } /** - * Validate property value is positive integer. + * Check property value is positive integer. * - * @param props properties to be validated - * @param key property key to be validated + * @param props properties to be checked + * @param key property key to be checked */ - public static void validateIsPositiveInteger(final Properties props, final String key) { + public static void checkPositiveInteger(final Properties props, final String key) { String propertyValue = props.getProperty(key); - if (null != propertyValue) { - int integerValue; - try { - integerValue = Integer.parseInt(propertyValue); - } catch (final NumberFormatException ignored) { - throw new IllegalArgumentException(String.format("The property `%s` should be integer.", key)); - } - Preconditions.checkArgument(integerValue > 0, "The property `%s` should be positive.", key); + if (null == propertyValue) { + return; } + int integerValue; + try { + integerValue = Integer.parseInt(propertyValue); + } catch (final NumberFormatException ignored) { + throw new IllegalArgumentException(String.format("The property `%s` should be integer.", key)); + } + Preconditions.checkArgument(integerValue > 0, "The property `%s` should be positive.", key); } } diff --git a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/validate/JobPropertiesValidateRuleTest.java b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditionsTest.java similarity index 82% rename from infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/validate/JobPropertiesValidateRuleTest.java rename to infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditionsTest.java index aed6124fec..a42204efe3 100644 --- a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/validate/JobPropertiesValidateRuleTest.java +++ b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditionsTest.java @@ -24,12 +24,12 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -class JobPropertiesValidateRuleTest { +class PropertiesPreconditionsTest { @Test void assertValidateIsRequiredWithValidateError() { try { - JobPropertiesValidateRule.validateIsRequired(new Properties(), "key"); + PropertiesPreconditions.checkRequired(new Properties(), "key"); } catch (NullPointerException ex) { assertThat(ex.getMessage(), is(String.format("The property `%s` is required.", "key"))); } @@ -39,19 +39,19 @@ void assertValidateIsRequiredWithValidateError() { void assertValidateIsRequiredWithNormal() { Properties props = new Properties(); props.setProperty("key", "value"); - JobPropertiesValidateRule.validateIsRequired(props, "key"); + PropertiesPreconditions.checkRequired(props, "key"); } @Test void assertValidateIsPositiveIntegerWithValueNoExist() { - JobPropertiesValidateRule.validateIsPositiveInteger(new Properties(), "key"); + PropertiesPreconditions.checkPositiveInteger(new Properties(), "key"); } @Test void assertValidateIsPositiveIntegerWithNormal() { Properties props = new Properties(); props.setProperty("key", "1"); - JobPropertiesValidateRule.validateIsPositiveInteger(props, "key"); + PropertiesPreconditions.checkPositiveInteger(props, "key"); } @Test @@ -59,7 +59,7 @@ void assertValidateIsPositiveIntegerWithWrongString() { Properties props = new Properties(); props.setProperty("key", "wrong_value"); try { - JobPropertiesValidateRule.validateIsPositiveInteger(props, "key"); + PropertiesPreconditions.checkPositiveInteger(props, "key"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage(), is(String.format("The property `%s` should be integer.", "key"))); } @@ -70,7 +70,7 @@ void assertValidateIsPositiveIntegerWithNegativeNumber() { Properties props = new Properties(); props.setProperty("key", "-1"); try { - JobPropertiesValidateRule.validateIsPositiveInteger(props, "key"); + PropertiesPreconditions.checkPositiveInteger(props, "key"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage(), is(String.format("The property `%s` should be positive.", "key"))); } From 5d6a48fa02daf30b492fb3f19967aa0435d9b196 Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sat, 28 Oct 2023 19:46:06 +0800 Subject: [PATCH 2/4] Rename PropertiesPreconditions --- .../dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java | 2 +- .../handler/email/EmailJobErrorHandlerPropertiesValidator.java | 2 +- .../wechat/WechatJobErrorHandlerPropertiesValidator.java | 2 +- .../infra/{validate => exception}/PropertiesPreconditions.java | 2 +- .../{validate => exception}/PropertiesPreconditionsTest.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/{validate => exception}/PropertiesPreconditions.java (97%) rename infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/{validate => exception}/PropertiesPreconditionsTest.java (97%) diff --git a/ecosystem/error-handler/type/dingtalk/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java b/ecosystem/error-handler/type/dingtalk/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java index d84789f4fc..de97f1bb88 100644 --- a/ecosystem/error-handler/type/dingtalk/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java +++ b/ecosystem/error-handler/type/dingtalk/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidator.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.elasticjob.error.handler.dingtalk; import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator; -import org.apache.shardingsphere.elasticjob.infra.validate.PropertiesPreconditions; +import org.apache.shardingsphere.elasticjob.infra.exception.PropertiesPreconditions; import java.util.Properties; diff --git a/ecosystem/error-handler/type/email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidator.java b/ecosystem/error-handler/type/email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidator.java index 6fb8a21918..a48e20c50f 100644 --- a/ecosystem/error-handler/type/email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidator.java +++ b/ecosystem/error-handler/type/email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidator.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.elasticjob.error.handler.email; import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator; -import org.apache.shardingsphere.elasticjob.infra.validate.PropertiesPreconditions; +import org.apache.shardingsphere.elasticjob.infra.exception.PropertiesPreconditions; import java.util.Properties; diff --git a/ecosystem/error-handler/type/wechat/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidator.java b/ecosystem/error-handler/type/wechat/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidator.java index 00a47bc25a..c2a6947c60 100644 --- a/ecosystem/error-handler/type/wechat/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidator.java +++ b/ecosystem/error-handler/type/wechat/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidator.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.elasticjob.error.handler.wechat; import org.apache.shardingsphere.elasticjob.error.handler.JobErrorHandlerPropertiesValidator; -import org.apache.shardingsphere.elasticjob.infra.validate.PropertiesPreconditions; +import org.apache.shardingsphere.elasticjob.infra.exception.PropertiesPreconditions; import java.util.Properties; diff --git a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditions.java b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditions.java similarity index 97% rename from infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditions.java rename to infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditions.java index 79b175e0b1..160b44493a 100644 --- a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditions.java +++ b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditions.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.elasticjob.infra.validate; +package org.apache.shardingsphere.elasticjob.infra.exception; import com.google.common.base.Preconditions; import lombok.AccessLevel; diff --git a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditionsTest.java b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditionsTest.java similarity index 97% rename from infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditionsTest.java rename to infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditionsTest.java index a42204efe3..4d81e2b7ce 100644 --- a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/validate/PropertiesPreconditionsTest.java +++ b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditionsTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.shardingsphere.elasticjob.infra.validate; +package org.apache.shardingsphere.elasticjob.infra.exception; import org.junit.jupiter.api.Test; From 2f76bf1ef7daf37b7389670f96b57cc674413a6d Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sat, 28 Oct 2023 19:51:55 +0800 Subject: [PATCH 3/4] Fix test cases --- .../elasticjob/infra/exception/PropertiesPreconditions.java | 2 +- .../elasticjob/infra/exception/PropertiesPreconditionsTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditions.java b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditions.java index 160b44493a..60aaecde66 100644 --- a/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditions.java +++ b/infra/src/main/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditions.java @@ -36,7 +36,7 @@ public final class PropertiesPreconditions { * @param key property key to be checked */ public static void checkRequired(final Properties props, final String key) { - Preconditions.checkState(props.containsKey(key), "The property `%s` is required.", key); + Preconditions.checkArgument(props.containsKey(key), "The property `%s` is required.", key); } /** diff --git a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditionsTest.java b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditionsTest.java index 4d81e2b7ce..7500c99b92 100644 --- a/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditionsTest.java +++ b/infra/src/test/java/org/apache/shardingsphere/elasticjob/infra/exception/PropertiesPreconditionsTest.java @@ -30,7 +30,7 @@ class PropertiesPreconditionsTest { void assertValidateIsRequiredWithValidateError() { try { PropertiesPreconditions.checkRequired(new Properties(), "key"); - } catch (NullPointerException ex) { + } catch (IllegalArgumentException ex) { assertThat(ex.getMessage(), is(String.format("The property `%s` is required.", "key"))); } } From d7631ec8417c6b27ead83d17f5d6b19ff3ac077b Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sat, 28 Oct 2023 19:56:47 +0800 Subject: [PATCH 4/4] Fix test cases --- .../DingtalkJobErrorHandlerPropertiesValidatorTest.java | 2 +- .../email/EmailJobErrorHandlerPropertiesValidatorTest.java | 2 +- .../wechat/WechatJobErrorHandlerPropertiesValidatorTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ecosystem/error-handler/type/dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidatorTest.java b/ecosystem/error-handler/type/dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidatorTest.java index 4ee20ef25d..55ddddf94a 100644 --- a/ecosystem/error-handler/type/dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidatorTest.java +++ b/ecosystem/error-handler/type/dingtalk/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/dingtalk/DingtalkJobErrorHandlerPropertiesValidatorTest.java @@ -47,7 +47,7 @@ void assertValidateWithPropsIsNull() { void assertValidateWithWebhookIsNull() { try { TypedSPILoader.getService(JobErrorHandlerPropertiesValidator.class, "DINGTALK").validate(new Properties()); - } catch (final NullPointerException ex) { + } catch (final IllegalArgumentException ex) { assertThat(ex.getMessage(), is(String.format("The property `%s` is required.", DingtalkPropertiesConstants.WEBHOOK))); } } diff --git a/ecosystem/error-handler/type/email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java b/ecosystem/error-handler/type/email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java index b4d614b9dc..34e7dd76ab 100644 --- a/ecosystem/error-handler/type/email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java +++ b/ecosystem/error-handler/type/email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailJobErrorHandlerPropertiesValidatorTest.java @@ -51,7 +51,7 @@ void assertValidateWithPropsIsNull() { void assertValidateWithHostIsNull() { try { TypedSPILoader.getService(JobErrorHandlerPropertiesValidator.class, "EMAIL").validate(new Properties()); - } catch (final NullPointerException ex) { + } catch (final IllegalArgumentException ex) { assertThat(ex.getMessage(), is(String.format("The property `%s` is required.", EmailPropertiesConstants.HOST))); } } diff --git a/ecosystem/error-handler/type/wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidatorTest.java b/ecosystem/error-handler/type/wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidatorTest.java index 05882b65de..254e2a0125 100644 --- a/ecosystem/error-handler/type/wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidatorTest.java +++ b/ecosystem/error-handler/type/wechat/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/wechat/WechatJobErrorHandlerPropertiesValidatorTest.java @@ -47,7 +47,7 @@ void assertValidateWithPropsIsNull() { void assertValidateWithWebhookIsNull() { try { TypedSPILoader.getService(JobErrorHandlerPropertiesValidator.class, "WECHAT").validate(new Properties()); - } catch (final NullPointerException ex) { + } catch (final IllegalArgumentException ex) { assertThat(ex.getMessage(), is(String.format("The property `%s` is required.", WechatPropertiesConstants.WEBHOOK))); } }