refactor: 新增 IValidator
接口
- 让 BaseValidator 继承自 IValidator 接口 - 更新相关测试用例中的类型引用
This commit is contained in:
parent
0a5dbd9f53
commit
9f0c7cd2fb
@ -39,18 +39,18 @@ import xyz.zhouxy.plusone.validator.function.*;
|
|||||||
* @author ZhouXY
|
* @author ZhouXY
|
||||||
* @since 0.0.1
|
* @since 0.0.1
|
||||||
*/
|
*/
|
||||||
public abstract class BaseValidator<T> {
|
public abstract class BaseValidator<T> implements IValidator<T> {
|
||||||
private final List<Consumer<? super T>> rules = new ArrayList<>();
|
private final List<Consumer<? super T>> rules = new ArrayList<>();
|
||||||
|
|
||||||
protected void withRule(final Predicate<? super T> rule, final String errorMessage) {
|
protected final void withRule(final Predicate<? super T> rule, final String errorMessage) {
|
||||||
withRule(rule, () -> new IllegalArgumentException(errorMessage));
|
withRule(rule, () -> new IllegalArgumentException(errorMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <E extends RuntimeException> void withRule(Predicate<? super T> rule, Supplier<E> exceptionBuilder) {
|
protected final <E extends RuntimeException> void withRule(Predicate<? super T> rule, Supplier<E> exceptionBuilder) {
|
||||||
withRule(rule, value -> exceptionBuilder.get());
|
withRule(rule, value -> exceptionBuilder.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <E extends RuntimeException> void withRule(
|
protected final <E extends RuntimeException> void withRule(
|
||||||
Predicate<? super T> condition, Function<T, E> exceptionBuilder) {
|
Predicate<? super T> condition, Function<T, E> exceptionBuilder) {
|
||||||
withRule(value -> {
|
withRule(value -> {
|
||||||
if (!condition.test(value)) {
|
if (!condition.test(value)) {
|
||||||
@ -59,7 +59,7 @@ public abstract class BaseValidator<T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void withRule(Consumer<? super T> rule) {
|
protected final void withRule(Consumer<? super T> rule) {
|
||||||
this.rules.add(rule);
|
this.rules.add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,6 +141,7 @@ public abstract class BaseValidator<T> {
|
|||||||
return validator;
|
return validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void validate(T obj) {
|
public void validate(T obj) {
|
||||||
this.rules.forEach(rule -> rule.accept(obj));
|
this.rules.forEach(rule -> rule.accept(obj));
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2025 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package xyz.zhouxy.plusone.validator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验器
|
||||||
|
*
|
||||||
|
* @author ZhouXY
|
||||||
|
*/
|
||||||
|
public interface IValidator<T> {
|
||||||
|
|
||||||
|
void validate(T obj);
|
||||||
|
}
|
@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import xyz.zhouxy.plusone.ExampleException;
|
import xyz.zhouxy.plusone.ExampleException;
|
||||||
import xyz.zhouxy.plusone.example.ExampleCommand;
|
import xyz.zhouxy.plusone.example.ExampleCommand;
|
||||||
import xyz.zhouxy.plusone.validator.BaseValidator;
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
|
import xyz.zhouxy.plusone.validator.IValidator;
|
||||||
|
|
||||||
class BaseValidatorTest {
|
class BaseValidatorTest {
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ class BaseValidatorTest {
|
|||||||
ExampleCommand exampleCommand = new ExampleCommand();
|
ExampleCommand exampleCommand = new ExampleCommand();
|
||||||
exampleCommand.setStringProperty("Foo");
|
exampleCommand.setStringProperty("Foo");
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
withRule(command -> Objects.equals(command.getStringProperty(), "Foo"),
|
withRule(command -> Objects.equals(command.getStringProperty(), "Foo"),
|
||||||
"The stringProperty must be equal to 'Foo'");
|
"The stringProperty must be equal to 'Foo'");
|
||||||
@ -56,7 +57,7 @@ class BaseValidatorTest {
|
|||||||
void withRule_invalidInput() {
|
void withRule_invalidInput() {
|
||||||
ExampleCommand command = new ExampleCommand();
|
ExampleCommand command = new ExampleCommand();
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
withRule(command -> Objects.equals(command.getStringProperty(), "Foo"),
|
withRule(command -> Objects.equals(command.getStringProperty(), "Foo"),
|
||||||
"The stringProperty must be equal to 'Foo'");
|
"The stringProperty must be equal to 'Foo'");
|
||||||
@ -66,7 +67,7 @@ class BaseValidatorTest {
|
|||||||
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
||||||
assertEquals("The stringProperty must be equal to 'Foo'", eWithSpecifiedMessage.getMessage());
|
assertEquals("The stringProperty must be equal to 'Foo'", eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
withRule(command -> Objects.equals(command.getStringProperty(), "Foo"),
|
withRule(command -> Objects.equals(command.getStringProperty(), "Foo"),
|
||||||
() -> ExampleException.withMessage("The stringProperty must be equal to 'Foo'"));
|
() -> ExampleException.withMessage("The stringProperty must be equal to 'Foo'"));
|
||||||
@ -77,7 +78,7 @@ class BaseValidatorTest {
|
|||||||
() -> ruleWithExceptionSupplier.validate(command));
|
() -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals("The stringProperty must be equal to 'Foo'", specifiedException.getMessage());
|
assertEquals("The stringProperty must be equal to 'Foo'", specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
withRule(command -> Objects.equals(command.getStringProperty(), "Foo"), command -> ExampleException
|
withRule(command -> Objects.equals(command.getStringProperty(), "Foo"), command -> ExampleException
|
||||||
.withMessage("The stringProperty must be equal to 'Foo', but is was '%s'.", command.getStringProperty()));
|
.withMessage("The stringProperty must be equal to 'Foo', but is was '%s'.", command.getStringProperty()));
|
||||||
@ -88,7 +89,7 @@ class BaseValidatorTest {
|
|||||||
() -> ruleWithExceptionFunction.validate(command));
|
() -> ruleWithExceptionFunction.validate(command));
|
||||||
assertEquals("The stringProperty must be equal to 'Foo', but is was 'null'.", specifiedException2.getMessage());
|
assertEquals("The stringProperty must be equal to 'Foo', but is was 'null'.", specifiedException2.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> rule = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> rule = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
withRule(command -> {
|
withRule(command -> {
|
||||||
final String stringProperty = command.getStringProperty();
|
final String stringProperty = command.getStringProperty();
|
||||||
|
@ -22,6 +22,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import xyz.zhouxy.plusone.ExampleException;
|
import xyz.zhouxy.plusone.ExampleException;
|
||||||
import xyz.zhouxy.plusone.example.ExampleCommand;
|
import xyz.zhouxy.plusone.example.ExampleCommand;
|
||||||
import xyz.zhouxy.plusone.validator.BaseValidator;
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
|
import xyz.zhouxy.plusone.validator.IValidator;
|
||||||
|
|
||||||
public class BoolPropertyValidatorTests {
|
public class BoolPropertyValidatorTests {
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isTrueValue_trueProperty() {
|
void isTrueValue_trueProperty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty).isTrueValue();
|
ruleForBool(ExampleCommand::getBoolProperty).isTrueValue();
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
@ -51,7 +52,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isTrueValue_default_falseProperty() {
|
void isTrueValue_default_falseProperty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty).isTrueValue();
|
ruleForBool(ExampleCommand::getBoolProperty).isTrueValue();
|
||||||
}
|
}
|
||||||
@ -69,7 +70,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void isTrueValue_message_falseProperty() {
|
void isTrueValue_message_falseProperty() {
|
||||||
final String message = "The boolProperty should be true.";
|
final String message = "The boolProperty should be true.";
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isTrueValue(message);
|
.isTrueValue(message);
|
||||||
@ -88,7 +89,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void isTrueValue_exceptionSupplier_falseProperty() {
|
void isTrueValue_exceptionSupplier_falseProperty() {
|
||||||
final String message = "The boolProperty should be true.";
|
final String message = "The boolProperty should be true.";
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isTrueValue(() -> ExampleException.withMessage(message));
|
.isTrueValue(() -> ExampleException.withMessage(message));
|
||||||
@ -106,7 +107,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isTrueValue_exceptionFunction_falseProperty() {
|
void isTrueValue_exceptionFunction_falseProperty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isTrueValue(property -> ExampleException.withMessage(
|
.isTrueValue(property -> ExampleException.withMessage(
|
||||||
@ -125,7 +126,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isTrueValue_default_nullProperty() {
|
void isTrueValue_default_nullProperty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty).isTrueValue();
|
ruleForBool(ExampleCommand::getBoolProperty).isTrueValue();
|
||||||
}
|
}
|
||||||
@ -143,7 +144,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void isTrueValue_message_nullProperty() {
|
void isTrueValue_message_nullProperty() {
|
||||||
final String message = "The boolProperty should be true.";
|
final String message = "The boolProperty should be true.";
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isTrueValue(message);
|
.isTrueValue(message);
|
||||||
@ -162,7 +163,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void isTrueValue_exceptionSupplier_nullProperty() {
|
void isTrueValue_exceptionSupplier_nullProperty() {
|
||||||
final String message = "The boolProperty should be true.";
|
final String message = "The boolProperty should be true.";
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isTrueValue(() -> ExampleException.withMessage(message));
|
.isTrueValue(() -> ExampleException.withMessage(message));
|
||||||
@ -180,7 +181,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isTrueValue_exceptionFunction_nullProperty() {
|
void isTrueValue_exceptionFunction_nullProperty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isTrueValue(property -> ExampleException.withMessage(
|
.isTrueValue(property -> ExampleException.withMessage(
|
||||||
@ -207,7 +208,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isFalseValue_falseProperty() {
|
void isFalseValue_falseProperty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty).isFalseValue();
|
ruleForBool(ExampleCommand::getBoolProperty).isFalseValue();
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
@ -227,7 +228,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isFalseValue_default_trueProperty() {
|
void isFalseValue_default_trueProperty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty).isFalseValue();
|
ruleForBool(ExampleCommand::getBoolProperty).isFalseValue();
|
||||||
}
|
}
|
||||||
@ -245,7 +246,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void isFalseValue_message_trueProperty() {
|
void isFalseValue_message_trueProperty() {
|
||||||
final String message = "The boolProperty should be false.";
|
final String message = "The boolProperty should be false.";
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isFalseValue(message);
|
.isFalseValue(message);
|
||||||
@ -264,7 +265,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void isFalseValue_exceptionSupplier_trueProperty() {
|
void isFalseValue_exceptionSupplier_trueProperty() {
|
||||||
final String message = "The boolProperty should be false.";
|
final String message = "The boolProperty should be false.";
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isFalseValue(() -> ExampleException.withMessage(message));
|
.isFalseValue(() -> ExampleException.withMessage(message));
|
||||||
@ -282,7 +283,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isFalseValue_exceptionFunction_trueProperty() {
|
void isFalseValue_exceptionFunction_trueProperty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isFalseValue(property -> ExampleException.withMessage(
|
.isFalseValue(property -> ExampleException.withMessage(
|
||||||
@ -301,7 +302,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isFalseValue_default_nullProperty() {
|
void isFalseValue_default_nullProperty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty).isFalseValue();
|
ruleForBool(ExampleCommand::getBoolProperty).isFalseValue();
|
||||||
}
|
}
|
||||||
@ -319,7 +320,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void isFalseValue_message_nullProperty() {
|
void isFalseValue_message_nullProperty() {
|
||||||
final String message = "The boolProperty should be false.";
|
final String message = "The boolProperty should be false.";
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isFalseValue(message);
|
.isFalseValue(message);
|
||||||
@ -338,7 +339,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void isFalseValue_exceptionSupplier_nullProperty() {
|
void isFalseValue_exceptionSupplier_nullProperty() {
|
||||||
final String message = "The boolProperty should be false.";
|
final String message = "The boolProperty should be false.";
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isFalseValue(() -> ExampleException.withMessage(message));
|
.isFalseValue(() -> ExampleException.withMessage(message));
|
||||||
@ -356,7 +357,7 @@ public class BoolPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isFalseValue_exceptionFunction_nullProperty() {
|
void isFalseValue_exceptionFunction_nullProperty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isFalseValue(property -> ExampleException.withMessage(
|
.isFalseValue(property -> ExampleException.withMessage(
|
||||||
|
@ -30,6 +30,7 @@ import com.google.common.collect.Lists;
|
|||||||
import xyz.zhouxy.plusone.ExampleException;
|
import xyz.zhouxy.plusone.ExampleException;
|
||||||
import xyz.zhouxy.plusone.example.ExampleCommand;
|
import xyz.zhouxy.plusone.example.ExampleCommand;
|
||||||
import xyz.zhouxy.plusone.validator.BaseValidator;
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
|
import xyz.zhouxy.plusone.validator.IValidator;
|
||||||
|
|
||||||
public class CollectionPropertyValidatorTests {
|
public class CollectionPropertyValidatorTests {
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notEmpty_stringListIsNotEmpty() {
|
void notEmpty_stringListIsNotEmpty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty).notEmpty();
|
ruleForCollection(ExampleCommand::getStringListProperty).notEmpty();
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty).notEmpty(MESSAGE_NOT_EMPTY);
|
ruleForCollection(ExampleCommand::getStringListProperty).notEmpty(MESSAGE_NOT_EMPTY);
|
||||||
@ -60,7 +61,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notEmpty_default_stringListIsEmpty() {
|
void notEmpty_default_stringListIsEmpty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty).notEmpty();
|
ruleForCollection(ExampleCommand::getStringListProperty).notEmpty();
|
||||||
}
|
}
|
||||||
@ -74,7 +75,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notEmpty_message_stringListIsEmpty() {
|
void notEmpty_message_stringListIsEmpty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty).notEmpty(MESSAGE_NOT_EMPTY);
|
ruleForCollection(ExampleCommand::getStringListProperty).notEmpty(MESSAGE_NOT_EMPTY);
|
||||||
}
|
}
|
||||||
@ -88,7 +89,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notEmpty_exceptionSupplier_stringListIsEmpty() {
|
void notEmpty_exceptionSupplier_stringListIsEmpty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty)
|
ruleForCollection(ExampleCommand::getStringListProperty)
|
||||||
.notEmpty(() -> ExampleException.withMessage(MESSAGE_NOT_EMPTY));
|
.notEmpty(() -> ExampleException.withMessage(MESSAGE_NOT_EMPTY));
|
||||||
@ -103,7 +104,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notEmpty_exceptionFunction_stringListIsEmpty() {
|
void notEmpty_exceptionFunction_stringListIsEmpty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty)
|
ruleForCollection(ExampleCommand::getStringListProperty)
|
||||||
.notEmpty(strList -> ExampleException.withMessage(
|
.notEmpty(strList -> ExampleException.withMessage(
|
||||||
@ -119,7 +120,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notEmpty_message_stringListIsNull() {
|
void notEmpty_message_stringListIsNull() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty).notEmpty(MESSAGE_NOT_EMPTY);
|
ruleForCollection(ExampleCommand::getStringListProperty).notEmpty(MESSAGE_NOT_EMPTY);
|
||||||
}
|
}
|
||||||
@ -133,7 +134,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notEmpty_exceptionSupplier_stringListIsNull() {
|
void notEmpty_exceptionSupplier_stringListIsNull() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty)
|
ruleForCollection(ExampleCommand::getStringListProperty)
|
||||||
.notEmpty(() -> ExampleException.withMessage(MESSAGE_NOT_EMPTY));
|
.notEmpty(() -> ExampleException.withMessage(MESSAGE_NOT_EMPTY));
|
||||||
@ -148,7 +149,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notEmpty_exceptionFunction_stringListIsNull() {
|
void notEmpty_exceptionFunction_stringListIsNull() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty)
|
ruleForCollection(ExampleCommand::getStringListProperty)
|
||||||
.notEmpty(strList -> ExampleException.withMessage(
|
.notEmpty(strList -> ExampleException.withMessage(
|
||||||
@ -172,7 +173,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isEmpty_stringListIsEmpty() {
|
void isEmpty_stringListIsEmpty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty();
|
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty();
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty(MESSAGE_EMPTY);
|
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty(MESSAGE_EMPTY);
|
||||||
@ -190,7 +191,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isEmpty_stringListIsNull() {
|
void isEmpty_stringListIsNull() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty();
|
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty();
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty(MESSAGE_EMPTY);
|
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty(MESSAGE_EMPTY);
|
||||||
@ -208,7 +209,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isEmpty_default_stringListIsNotEmpty() {
|
void isEmpty_default_stringListIsNotEmpty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty();
|
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty();
|
||||||
}
|
}
|
||||||
@ -222,7 +223,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isEmpty_message_stringListIsNotEmpty() {
|
void isEmpty_message_stringListIsNotEmpty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty(MESSAGE_EMPTY);
|
ruleForCollection(ExampleCommand::getStringListProperty).isEmpty(MESSAGE_EMPTY);
|
||||||
}
|
}
|
||||||
@ -236,7 +237,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isEmpty_exceptionSupplier_stringListIsNotEmpty() {
|
void isEmpty_exceptionSupplier_stringListIsNotEmpty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty)
|
ruleForCollection(ExampleCommand::getStringListProperty)
|
||||||
.isEmpty(() -> ExampleException.withMessage(MESSAGE_EMPTY));
|
.isEmpty(() -> ExampleException.withMessage(MESSAGE_EMPTY));
|
||||||
@ -251,7 +252,7 @@ public class CollectionPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isEmpty_exceptionFunction_stringListIsNotEmpty() {
|
void isEmpty_exceptionFunction_stringListIsNotEmpty() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForCollection(ExampleCommand::getStringListProperty)
|
ruleForCollection(ExampleCommand::getStringListProperty)
|
||||||
.isEmpty(strList -> ExampleException.withMessage(
|
.isEmpty(strList -> ExampleException.withMessage(
|
||||||
|
@ -28,6 +28,7 @@ import com.google.common.collect.Range;
|
|||||||
import xyz.zhouxy.plusone.ExampleException;
|
import xyz.zhouxy.plusone.ExampleException;
|
||||||
import xyz.zhouxy.plusone.example.ExampleCommand;
|
import xyz.zhouxy.plusone.example.ExampleCommand;
|
||||||
import xyz.zhouxy.plusone.validator.BaseValidator;
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
|
import xyz.zhouxy.plusone.validator.IValidator;
|
||||||
|
|
||||||
public class ComparablePropertyValidatorTests {
|
public class ComparablePropertyValidatorTests {
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ public class ComparablePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void inRange_valueIsInTheInterval() {
|
void inRange_valueIsInTheInterval() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
||||||
.inRange(DATE_TIME_RANGE);
|
.inRange(DATE_TIME_RANGE);
|
||||||
@ -77,7 +78,7 @@ public class ComparablePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void inRange_default_valueIsNotInTheInterval() {
|
void inRange_default_valueIsNotInTheInterval() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
||||||
.inRange(DATE_TIME_RANGE);
|
.inRange(DATE_TIME_RANGE);
|
||||||
@ -96,7 +97,7 @@ public class ComparablePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void inRange_message_valueIsNotInTheInterval() {
|
void inRange_message_valueIsNotInTheInterval() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
||||||
.inRange(DATE_TIME_RANGE, MESSAGE);
|
.inRange(DATE_TIME_RANGE, MESSAGE);
|
||||||
@ -114,7 +115,7 @@ public class ComparablePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void inRange_exceptionSupplier_valueIsNotInTheInterval() {
|
void inRange_exceptionSupplier_valueIsNotInTheInterval() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
||||||
.inRange(DATE_TIME_RANGE, () -> ExampleException.withMessage(MESSAGE));
|
.inRange(DATE_TIME_RANGE, () -> ExampleException.withMessage(MESSAGE));
|
||||||
@ -132,7 +133,7 @@ public class ComparablePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void inRange_exceptionFunction_valueIsNotInTheInterval() {
|
void inRange_exceptionFunction_valueIsNotInTheInterval() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
||||||
.inRange(DATE_TIME_RANGE, property -> ExampleException.withMessage(
|
.inRange(DATE_TIME_RANGE, property -> ExampleException.withMessage(
|
||||||
@ -160,7 +161,7 @@ public class ComparablePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void inRange_default_valueIsNull() {
|
void inRange_default_valueIsNull() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
||||||
.inRange(DATE_TIME_RANGE);
|
.inRange(DATE_TIME_RANGE);
|
||||||
@ -179,7 +180,7 @@ public class ComparablePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void inRange_message_valueIsNull() {
|
void inRange_message_valueIsNull() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
||||||
.inRange(DATE_TIME_RANGE, MESSAGE);
|
.inRange(DATE_TIME_RANGE, MESSAGE);
|
||||||
@ -197,7 +198,7 @@ public class ComparablePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void inRange_exceptionSupplier_valueIsNull() {
|
void inRange_exceptionSupplier_valueIsNull() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
||||||
.inRange(DATE_TIME_RANGE, () -> ExampleException.withMessage(MESSAGE));
|
.inRange(DATE_TIME_RANGE, () -> ExampleException.withMessage(MESSAGE));
|
||||||
@ -215,7 +216,7 @@ public class ComparablePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void inRange_exceptionFunction_valueIsNull() {
|
void inRange_exceptionFunction_valueIsNull() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
ruleForComparable(ExampleCommand::getDateTimeProperty)
|
||||||
.inRange(DATE_TIME_RANGE, property -> ExampleException.withMessage(
|
.inRange(DATE_TIME_RANGE, property -> ExampleException.withMessage(
|
||||||
|
@ -25,6 +25,7 @@ import org.junit.jupiter.params.provider.ValueSource;
|
|||||||
import xyz.zhouxy.plusone.ExampleException;
|
import xyz.zhouxy.plusone.ExampleException;
|
||||||
import xyz.zhouxy.plusone.example.ExampleCommand;
|
import xyz.zhouxy.plusone.example.ExampleCommand;
|
||||||
import xyz.zhouxy.plusone.validator.BaseValidator;
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
|
import xyz.zhouxy.plusone.validator.IValidator;
|
||||||
|
|
||||||
public class DoublePropertyValidatorTests {
|
public class DoublePropertyValidatorTests {
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MIN + 0.000000000000001, Double.MAX_VALUE })
|
@ValueSource(doubles = { MIN + 0.000000000000001, Double.MAX_VALUE })
|
||||||
void gt_all_validValue(double value) {
|
void gt_all_validValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.gt(MIN);
|
.gt(MIN);
|
||||||
@ -74,7 +75,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MIN, MIN - 0.000000000000001, Double.MIN_VALUE })
|
@ValueSource(doubles = { MIN, MIN - 0.000000000000001, Double.MIN_VALUE })
|
||||||
void gt_default_invalidValue(double value) {
|
void gt_default_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.gt(MIN);
|
.gt(MIN);
|
||||||
@ -91,7 +92,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MIN, MIN - 0.000000000000001, Double.MIN_VALUE })
|
@ValueSource(doubles = { MIN, MIN - 0.000000000000001, Double.MIN_VALUE })
|
||||||
void gt_message_invalidValue(double value) {
|
void gt_message_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.gt(MIN, MESSAGE_GT);
|
.gt(MIN, MESSAGE_GT);
|
||||||
@ -108,7 +109,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MIN, MIN - 0.000000000000001, Double.MIN_VALUE })
|
@ValueSource(doubles = { MIN, MIN - 0.000000000000001, Double.MIN_VALUE })
|
||||||
void gt_exceptionSupplier_invalidValue(double value) {
|
void gt_exceptionSupplier_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
||||||
@ -125,7 +126,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MIN, MIN - 0.000000000000001, Double.MIN_VALUE })
|
@ValueSource(doubles = { MIN, MIN - 0.000000000000001, Double.MIN_VALUE })
|
||||||
void gt_exceptionFunction_invalidValue(double value) {
|
void gt_exceptionFunction_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.gt(MIN, property -> ExampleException.withMessage(
|
.gt(MIN, property -> ExampleException.withMessage(
|
||||||
@ -151,7 +152,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_default_null() {
|
void gt_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.gt(MIN);
|
.gt(MIN);
|
||||||
@ -167,7 +168,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_message_null() {
|
void gt_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.gt(MIN, MESSAGE_GT);
|
.gt(MIN, MESSAGE_GT);
|
||||||
@ -183,7 +184,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_exceptionSupplier_null() {
|
void gt_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
||||||
@ -199,7 +200,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_exceptionFunction_null() {
|
void gt_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.gt(MIN, property -> ExampleException.withMessage(
|
.gt(MIN, property -> ExampleException.withMessage(
|
||||||
@ -226,7 +227,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MIN, MIN + 0.000000000000001, Double.MAX_VALUE })
|
@ValueSource(doubles = { MIN, MIN + 0.000000000000001, Double.MAX_VALUE })
|
||||||
void ge_all_validValue(double value) {
|
void ge_all_validValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.ge(MIN);
|
.ge(MIN);
|
||||||
@ -256,7 +257,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MIN - 0.000000000000001, Double.MIN_VALUE })
|
@ValueSource(doubles = { MIN - 0.000000000000001, Double.MIN_VALUE })
|
||||||
void ge_default_invalidValue(double value) {
|
void ge_default_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.ge(MIN);
|
.ge(MIN);
|
||||||
@ -273,7 +274,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MIN - 0.000000000000001, Double.MIN_VALUE })
|
@ValueSource(doubles = { MIN - 0.000000000000001, Double.MIN_VALUE })
|
||||||
void ge_message_invalidValue(double value) {
|
void ge_message_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.ge(MIN, MESSAGE_GE);
|
.ge(MIN, MESSAGE_GE);
|
||||||
@ -290,7 +291,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MIN - 0.000000000000001, Double.MIN_VALUE })
|
@ValueSource(doubles = { MIN - 0.000000000000001, Double.MIN_VALUE })
|
||||||
void ge_exceptionSupplier_invalidValue(double value) {
|
void ge_exceptionSupplier_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
||||||
@ -307,7 +308,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MIN - 0.000000000000001, Double.MIN_VALUE })
|
@ValueSource(doubles = { MIN - 0.000000000000001, Double.MIN_VALUE })
|
||||||
void ge_exceptionFunction_invalidValue(double value) {
|
void ge_exceptionFunction_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.ge(MIN, property -> ExampleException.withMessage(
|
.ge(MIN, property -> ExampleException.withMessage(
|
||||||
@ -333,7 +334,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_default_null() {
|
void ge_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.ge(MIN);
|
.ge(MIN);
|
||||||
@ -349,7 +350,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_message_null() {
|
void ge_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.ge(MIN, MESSAGE_GE);
|
.ge(MIN, MESSAGE_GE);
|
||||||
@ -365,7 +366,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_exceptionSupplier_null() {
|
void ge_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
||||||
@ -381,7 +382,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_exceptionFunction_null() {
|
void ge_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.ge(MIN, property -> ExampleException.withMessage(
|
.ge(MIN, property -> ExampleException.withMessage(
|
||||||
@ -408,7 +409,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MAX - 0.000000000000001, Double.MIN_VALUE })
|
@ValueSource(doubles = { MAX - 0.000000000000001, Double.MIN_VALUE })
|
||||||
void lt_all_validValue(double value) {
|
void lt_all_validValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.lt(MAX);
|
.lt(MAX);
|
||||||
@ -438,7 +439,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MAX, MAX + 0.000000000000001, Double.MAX_VALUE })
|
@ValueSource(doubles = { MAX, MAX + 0.000000000000001, Double.MAX_VALUE })
|
||||||
void lt_default_invalidValue(double value) {
|
void lt_default_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.lt(MAX);
|
.lt(MAX);
|
||||||
@ -455,7 +456,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MAX, MAX + 0.000000000000001, Double.MAX_VALUE })
|
@ValueSource(doubles = { MAX, MAX + 0.000000000000001, Double.MAX_VALUE })
|
||||||
void lt_message_invalidValue(double value) {
|
void lt_message_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.lt(MAX, MESSAGE_LT);
|
.lt(MAX, MESSAGE_LT);
|
||||||
@ -472,7 +473,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MAX, MAX + 0.000000000000001, Double.MAX_VALUE })
|
@ValueSource(doubles = { MAX, MAX + 0.000000000000001, Double.MAX_VALUE })
|
||||||
void lt_exceptionSupplier_invalidValue(double value) {
|
void lt_exceptionSupplier_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
||||||
@ -489,7 +490,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MAX, MAX + 0.000000000000001, Double.MAX_VALUE })
|
@ValueSource(doubles = { MAX, MAX + 0.000000000000001, Double.MAX_VALUE })
|
||||||
void lt_exceptionFunction_invalidValue(double value) {
|
void lt_exceptionFunction_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.lt(MAX, property -> ExampleException.withMessage(
|
.lt(MAX, property -> ExampleException.withMessage(
|
||||||
@ -515,7 +516,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_default_null() {
|
void lt_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.lt(MAX);
|
.lt(MAX);
|
||||||
@ -531,7 +532,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_message_null() {
|
void lt_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.lt(MAX, MESSAGE_LT);
|
.lt(MAX, MESSAGE_LT);
|
||||||
@ -547,7 +548,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_exceptionSupplier_null() {
|
void lt_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
||||||
@ -563,7 +564,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_exceptionFunction_null() {
|
void lt_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.lt(MAX, property -> ExampleException.withMessage(
|
.lt(MAX, property -> ExampleException.withMessage(
|
||||||
@ -590,7 +591,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MAX, MAX - 0.000000000000001, Double.MIN_VALUE })
|
@ValueSource(doubles = { MAX, MAX - 0.000000000000001, Double.MIN_VALUE })
|
||||||
void le_all_validValue(double value) {
|
void le_all_validValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.le(MAX);
|
.le(MAX);
|
||||||
@ -620,7 +621,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MAX + 0.000000000000001, Double.MAX_VALUE })
|
@ValueSource(doubles = { MAX + 0.000000000000001, Double.MAX_VALUE })
|
||||||
void le_default_invalidValue(double value) {
|
void le_default_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.le(MAX);
|
.le(MAX);
|
||||||
@ -637,7 +638,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MAX + 0.000000000000001, Double.MAX_VALUE })
|
@ValueSource(doubles = { MAX + 0.000000000000001, Double.MAX_VALUE })
|
||||||
void le_message_invalidValue(double value) {
|
void le_message_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.le(MAX, MESSAGE_LE);
|
.le(MAX, MESSAGE_LE);
|
||||||
@ -654,7 +655,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MAX + 0.000000000000001, Double.MAX_VALUE })
|
@ValueSource(doubles = { MAX + 0.000000000000001, Double.MAX_VALUE })
|
||||||
void le_exceptionSupplier_invalidValue(double value) {
|
void le_exceptionSupplier_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
||||||
@ -671,7 +672,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(doubles = { MAX + 0.000000000000001, Double.MAX_VALUE })
|
@ValueSource(doubles = { MAX + 0.000000000000001, Double.MAX_VALUE })
|
||||||
void le_exceptionFunction_invalidValue(double value) {
|
void le_exceptionFunction_invalidValue(double value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.le(MAX, property -> ExampleException.withMessage(
|
.le(MAX, property -> ExampleException.withMessage(
|
||||||
@ -697,7 +698,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_default_null() {
|
void le_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.le(MAX);
|
.le(MAX);
|
||||||
@ -713,7 +714,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_message_null() {
|
void le_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.le(MAX, MESSAGE_LE);
|
.le(MAX, MESSAGE_LE);
|
||||||
@ -729,7 +730,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_exceptionSupplier_null() {
|
void le_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
||||||
@ -745,7 +746,7 @@ public class DoublePropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_exceptionFunction_null() {
|
void le_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForDouble(ExampleCommand::getDoubleProperty)
|
ruleForDouble(ExampleCommand::getDoubleProperty)
|
||||||
.le(MAX, property -> ExampleException.withMessage(
|
.le(MAX, property -> ExampleException.withMessage(
|
||||||
|
@ -24,6 +24,7 @@ import org.junit.jupiter.params.provider.ValueSource;
|
|||||||
import xyz.zhouxy.plusone.ExampleException;
|
import xyz.zhouxy.plusone.ExampleException;
|
||||||
import xyz.zhouxy.plusone.example.ExampleCommand;
|
import xyz.zhouxy.plusone.example.ExampleCommand;
|
||||||
import xyz.zhouxy.plusone.validator.BaseValidator;
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
|
import xyz.zhouxy.plusone.validator.IValidator;
|
||||||
|
|
||||||
public class IntPropertyValidatorTests {
|
public class IntPropertyValidatorTests {
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MIN + 1, Integer.MAX_VALUE })
|
@ValueSource(ints = { MIN + 1, Integer.MAX_VALUE })
|
||||||
void gt_all_validValue(int value) {
|
void gt_all_validValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.gt(MIN);
|
.gt(MIN);
|
||||||
@ -73,7 +74,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MIN, MIN - 1, Integer.MIN_VALUE })
|
@ValueSource(ints = { MIN, MIN - 1, Integer.MIN_VALUE })
|
||||||
void gt_default_invalidValue(int value) {
|
void gt_default_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.gt(MIN);
|
.gt(MIN);
|
||||||
@ -90,7 +91,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MIN, MIN - 1, Integer.MIN_VALUE })
|
@ValueSource(ints = { MIN, MIN - 1, Integer.MIN_VALUE })
|
||||||
void gt_message_invalidValue(int value) {
|
void gt_message_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.gt(MIN, MESSAGE_GT);
|
.gt(MIN, MESSAGE_GT);
|
||||||
@ -107,7 +108,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MIN, MIN - 1, Integer.MIN_VALUE })
|
@ValueSource(ints = { MIN, MIN - 1, Integer.MIN_VALUE })
|
||||||
void gt_exceptionSupplier_invalidValue(int value) {
|
void gt_exceptionSupplier_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
||||||
@ -124,7 +125,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MIN, MIN - 1, Integer.MIN_VALUE })
|
@ValueSource(ints = { MIN, MIN - 1, Integer.MIN_VALUE })
|
||||||
void gt_exceptionFunction_invalidValue(int value) {
|
void gt_exceptionFunction_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.gt(MIN, property -> ExampleException.withMessage(
|
.gt(MIN, property -> ExampleException.withMessage(
|
||||||
@ -150,7 +151,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_default_null() {
|
void gt_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.gt(MIN);
|
.gt(MIN);
|
||||||
@ -166,7 +167,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_message_null() {
|
void gt_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.gt(MIN, MESSAGE_GT);
|
.gt(MIN, MESSAGE_GT);
|
||||||
@ -182,7 +183,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_exceptionSupplier_null() {
|
void gt_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
||||||
@ -198,7 +199,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_exceptionFunction_null() {
|
void gt_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.gt(MIN, property -> ExampleException.withMessage(
|
.gt(MIN, property -> ExampleException.withMessage(
|
||||||
@ -225,7 +226,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MIN, MIN + 1, Integer.MAX_VALUE })
|
@ValueSource(ints = { MIN, MIN + 1, Integer.MAX_VALUE })
|
||||||
void ge_all_validValue(int value) {
|
void ge_all_validValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.ge(MIN);
|
.ge(MIN);
|
||||||
@ -255,7 +256,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MIN - 1, Integer.MIN_VALUE })
|
@ValueSource(ints = { MIN - 1, Integer.MIN_VALUE })
|
||||||
void ge_default_invalidValue(int value) {
|
void ge_default_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.ge(MIN);
|
.ge(MIN);
|
||||||
@ -272,7 +273,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MIN - 1, Integer.MIN_VALUE })
|
@ValueSource(ints = { MIN - 1, Integer.MIN_VALUE })
|
||||||
void ge_message_invalidValue(int value) {
|
void ge_message_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.ge(MIN, MESSAGE_GE);
|
.ge(MIN, MESSAGE_GE);
|
||||||
@ -289,7 +290,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MIN - 1, Integer.MIN_VALUE })
|
@ValueSource(ints = { MIN - 1, Integer.MIN_VALUE })
|
||||||
void ge_exceptionSupplier_invalidValue(int value) {
|
void ge_exceptionSupplier_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
||||||
@ -306,7 +307,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MIN - 1, Integer.MIN_VALUE })
|
@ValueSource(ints = { MIN - 1, Integer.MIN_VALUE })
|
||||||
void ge_exceptionFunction_invalidValue(int value) {
|
void ge_exceptionFunction_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.ge(MIN, property -> ExampleException.withMessage(
|
.ge(MIN, property -> ExampleException.withMessage(
|
||||||
@ -332,7 +333,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_default_null() {
|
void ge_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.ge(MIN);
|
.ge(MIN);
|
||||||
@ -348,7 +349,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_message_null() {
|
void ge_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.ge(MIN, MESSAGE_GE);
|
.ge(MIN, MESSAGE_GE);
|
||||||
@ -364,7 +365,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_exceptionSupplier_null() {
|
void ge_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
||||||
@ -380,7 +381,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_exceptionFunction_null() {
|
void ge_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.ge(MIN, property -> ExampleException.withMessage(
|
.ge(MIN, property -> ExampleException.withMessage(
|
||||||
@ -407,7 +408,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MAX - 1, Integer.MIN_VALUE })
|
@ValueSource(ints = { MAX - 1, Integer.MIN_VALUE })
|
||||||
void lt_all_validValue(int value) {
|
void lt_all_validValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.lt(MAX);
|
.lt(MAX);
|
||||||
@ -437,7 +438,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MAX, MAX + 1, Integer.MAX_VALUE })
|
@ValueSource(ints = { MAX, MAX + 1, Integer.MAX_VALUE })
|
||||||
void lt_default_invalidValue(int value) {
|
void lt_default_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.lt(MAX);
|
.lt(MAX);
|
||||||
@ -454,7 +455,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MAX, MAX + 1, Integer.MAX_VALUE })
|
@ValueSource(ints = { MAX, MAX + 1, Integer.MAX_VALUE })
|
||||||
void lt_message_invalidValue(int value) {
|
void lt_message_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.lt(MAX, MESSAGE_LT);
|
.lt(MAX, MESSAGE_LT);
|
||||||
@ -471,7 +472,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MAX, MAX + 1, Integer.MAX_VALUE })
|
@ValueSource(ints = { MAX, MAX + 1, Integer.MAX_VALUE })
|
||||||
void lt_exceptionSupplier_invalidValue(int value) {
|
void lt_exceptionSupplier_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
||||||
@ -488,7 +489,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MAX, MAX + 1, Integer.MAX_VALUE })
|
@ValueSource(ints = { MAX, MAX + 1, Integer.MAX_VALUE })
|
||||||
void lt_exceptionFunction_invalidValue(int value) {
|
void lt_exceptionFunction_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.lt(MAX, property -> ExampleException.withMessage(
|
.lt(MAX, property -> ExampleException.withMessage(
|
||||||
@ -514,7 +515,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_default_null() {
|
void lt_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.lt(MAX);
|
.lt(MAX);
|
||||||
@ -530,7 +531,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_message_null() {
|
void lt_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.lt(MAX, MESSAGE_LT);
|
.lt(MAX, MESSAGE_LT);
|
||||||
@ -546,7 +547,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_exceptionSupplier_null() {
|
void lt_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
||||||
@ -562,7 +563,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_exceptionFunction_null() {
|
void lt_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.lt(MAX, property -> ExampleException.withMessage(
|
.lt(MAX, property -> ExampleException.withMessage(
|
||||||
@ -589,7 +590,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MAX, MAX - 1, Integer.MIN_VALUE })
|
@ValueSource(ints = { MAX, MAX - 1, Integer.MIN_VALUE })
|
||||||
void le_all_validValue(int value) {
|
void le_all_validValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.le(MAX);
|
.le(MAX);
|
||||||
@ -619,7 +620,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MAX + 1, Integer.MAX_VALUE })
|
@ValueSource(ints = { MAX + 1, Integer.MAX_VALUE })
|
||||||
void le_default_invalidValue(int value) {
|
void le_default_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.le(MAX);
|
.le(MAX);
|
||||||
@ -636,7 +637,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MAX + 1, Integer.MAX_VALUE })
|
@ValueSource(ints = { MAX + 1, Integer.MAX_VALUE })
|
||||||
void le_message_invalidValue(int value) {
|
void le_message_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.le(MAX, MESSAGE_LE);
|
.le(MAX, MESSAGE_LE);
|
||||||
@ -653,7 +654,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MAX + 1, Integer.MAX_VALUE })
|
@ValueSource(ints = { MAX + 1, Integer.MAX_VALUE })
|
||||||
void le_exceptionSupplier_invalidValue(int value) {
|
void le_exceptionSupplier_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
||||||
@ -670,7 +671,7 @@ public class IntPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(ints = { MAX + 1, Integer.MAX_VALUE })
|
@ValueSource(ints = { MAX + 1, Integer.MAX_VALUE })
|
||||||
void le_exceptionFunction_invalidValue(int value) {
|
void le_exceptionFunction_invalidValue(int value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.le(MAX, property -> ExampleException.withMessage(
|
.le(MAX, property -> ExampleException.withMessage(
|
||||||
@ -696,7 +697,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_default_null() {
|
void le_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.le(MAX);
|
.le(MAX);
|
||||||
@ -712,7 +713,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_message_null() {
|
void le_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.le(MAX, MESSAGE_LE);
|
.le(MAX, MESSAGE_LE);
|
||||||
@ -728,7 +729,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_exceptionSupplier_null() {
|
void le_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
||||||
@ -744,7 +745,7 @@ public class IntPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_exceptionFunction_null() {
|
void le_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForInt(ExampleCommand::getIntProperty)
|
ruleForInt(ExampleCommand::getIntProperty)
|
||||||
.le(MAX, property -> ExampleException.withMessage(
|
.le(MAX, property -> ExampleException.withMessage(
|
||||||
|
@ -24,6 +24,7 @@ import org.junit.jupiter.params.provider.ValueSource;
|
|||||||
import xyz.zhouxy.plusone.ExampleException;
|
import xyz.zhouxy.plusone.ExampleException;
|
||||||
import xyz.zhouxy.plusone.example.ExampleCommand;
|
import xyz.zhouxy.plusone.example.ExampleCommand;
|
||||||
import xyz.zhouxy.plusone.validator.BaseValidator;
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
|
import xyz.zhouxy.plusone.validator.IValidator;
|
||||||
|
|
||||||
public class LongPropertyValidatorTests {
|
public class LongPropertyValidatorTests {
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MIN + 1, Long.MAX_VALUE })
|
@ValueSource(longs = { MIN + 1, Long.MAX_VALUE })
|
||||||
void gt_all_validValue(long value) {
|
void gt_all_validValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.gt(MIN);
|
.gt(MIN);
|
||||||
@ -74,7 +75,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MIN, MIN - 1, Long.MIN_VALUE })
|
@ValueSource(longs = { MIN, MIN - 1, Long.MIN_VALUE })
|
||||||
void gt_default_invalidValue(long value) {
|
void gt_default_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.gt(MIN);
|
.gt(MIN);
|
||||||
@ -91,7 +92,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MIN, MIN - 1, Long.MIN_VALUE })
|
@ValueSource(longs = { MIN, MIN - 1, Long.MIN_VALUE })
|
||||||
void gt_message_invalidValue(long value) {
|
void gt_message_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.gt(MIN, MESSAGE_GT);
|
.gt(MIN, MESSAGE_GT);
|
||||||
@ -108,7 +109,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MIN, MIN - 1, Long.MIN_VALUE })
|
@ValueSource(longs = { MIN, MIN - 1, Long.MIN_VALUE })
|
||||||
void gt_exceptionSupplier_invalidValue(long value) {
|
void gt_exceptionSupplier_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
||||||
@ -125,7 +126,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MIN, MIN - 1, Long.MIN_VALUE })
|
@ValueSource(longs = { MIN, MIN - 1, Long.MIN_VALUE })
|
||||||
void gt_exceptionFunction_invalidValue(long value) {
|
void gt_exceptionFunction_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.gt(MIN, property -> ExampleException.withMessage(
|
.gt(MIN, property -> ExampleException.withMessage(
|
||||||
@ -151,7 +152,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_default_null() {
|
void gt_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.gt(MIN);
|
.gt(MIN);
|
||||||
@ -167,7 +168,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_message_null() {
|
void gt_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.gt(MIN, MESSAGE_GT);
|
.gt(MIN, MESSAGE_GT);
|
||||||
@ -183,7 +184,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_exceptionSupplier_null() {
|
void gt_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
.gt(MIN, () -> ExampleException.withMessage(MESSAGE_GT));
|
||||||
@ -199,7 +200,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void gt_exceptionFunction_null() {
|
void gt_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.gt(MIN, property -> ExampleException.withMessage(
|
.gt(MIN, property -> ExampleException.withMessage(
|
||||||
@ -226,7 +227,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MIN, MIN + 1, Long.MAX_VALUE })
|
@ValueSource(longs = { MIN, MIN + 1, Long.MAX_VALUE })
|
||||||
void ge_all_validValue(long value) {
|
void ge_all_validValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.ge(MIN);
|
.ge(MIN);
|
||||||
@ -256,7 +257,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MIN - 1, Long.MIN_VALUE })
|
@ValueSource(longs = { MIN - 1, Long.MIN_VALUE })
|
||||||
void ge_default_invalidValue(long value) {
|
void ge_default_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.ge(MIN);
|
.ge(MIN);
|
||||||
@ -273,7 +274,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MIN - 1, Long.MIN_VALUE })
|
@ValueSource(longs = { MIN - 1, Long.MIN_VALUE })
|
||||||
void ge_message_invalidValue(long value) {
|
void ge_message_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.ge(MIN, MESSAGE_GE);
|
.ge(MIN, MESSAGE_GE);
|
||||||
@ -290,7 +291,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MIN - 1, Long.MIN_VALUE })
|
@ValueSource(longs = { MIN - 1, Long.MIN_VALUE })
|
||||||
void ge_exceptionSupplier_invalidValue(long value) {
|
void ge_exceptionSupplier_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
||||||
@ -307,7 +308,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MIN - 1, Long.MIN_VALUE })
|
@ValueSource(longs = { MIN - 1, Long.MIN_VALUE })
|
||||||
void ge_exceptionFunction_invalidValue(long value) {
|
void ge_exceptionFunction_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.ge(MIN, property -> ExampleException.withMessage(
|
.ge(MIN, property -> ExampleException.withMessage(
|
||||||
@ -333,7 +334,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_default_null() {
|
void ge_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.ge(MIN);
|
.ge(MIN);
|
||||||
@ -349,7 +350,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_message_null() {
|
void ge_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.ge(MIN, MESSAGE_GE);
|
.ge(MIN, MESSAGE_GE);
|
||||||
@ -365,7 +366,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_exceptionSupplier_null() {
|
void ge_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
.ge(MIN, () -> ExampleException.withMessage(MESSAGE_GE));
|
||||||
@ -381,7 +382,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ge_exceptionFunction_null() {
|
void ge_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.ge(MIN, property -> ExampleException.withMessage(
|
.ge(MIN, property -> ExampleException.withMessage(
|
||||||
@ -408,7 +409,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MAX - 1, Long.MIN_VALUE })
|
@ValueSource(longs = { MAX - 1, Long.MIN_VALUE })
|
||||||
void lt_all_validValue(long value) {
|
void lt_all_validValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.lt(MAX);
|
.lt(MAX);
|
||||||
@ -438,7 +439,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MAX, MAX + 1, Long.MAX_VALUE })
|
@ValueSource(longs = { MAX, MAX + 1, Long.MAX_VALUE })
|
||||||
void lt_default_invalidValue(long value) {
|
void lt_default_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.lt(MAX);
|
.lt(MAX);
|
||||||
@ -455,7 +456,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MAX, MAX + 1, Long.MAX_VALUE })
|
@ValueSource(longs = { MAX, MAX + 1, Long.MAX_VALUE })
|
||||||
void lt_message_invalidValue(long value) {
|
void lt_message_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.lt(MAX, MESSAGE_LT);
|
.lt(MAX, MESSAGE_LT);
|
||||||
@ -472,7 +473,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MAX, MAX + 1, Long.MAX_VALUE })
|
@ValueSource(longs = { MAX, MAX + 1, Long.MAX_VALUE })
|
||||||
void lt_exceptionSupplier_invalidValue(long value) {
|
void lt_exceptionSupplier_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
||||||
@ -489,7 +490,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MAX, MAX + 1, Long.MAX_VALUE })
|
@ValueSource(longs = { MAX, MAX + 1, Long.MAX_VALUE })
|
||||||
void lt_exceptionFunction_invalidValue(long value) {
|
void lt_exceptionFunction_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.lt(MAX, property -> ExampleException.withMessage(
|
.lt(MAX, property -> ExampleException.withMessage(
|
||||||
@ -515,7 +516,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_default_null() {
|
void lt_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.lt(MAX);
|
.lt(MAX);
|
||||||
@ -531,7 +532,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_message_null() {
|
void lt_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.lt(MAX, MESSAGE_LT);
|
.lt(MAX, MESSAGE_LT);
|
||||||
@ -547,7 +548,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_exceptionSupplier_null() {
|
void lt_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
.lt(MAX, () -> ExampleException.withMessage(MESSAGE_LT));
|
||||||
@ -563,7 +564,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lt_exceptionFunction_null() {
|
void lt_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.lt(MAX, property -> ExampleException.withMessage(
|
.lt(MAX, property -> ExampleException.withMessage(
|
||||||
@ -590,7 +591,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MAX, MAX - 1, Long.MIN_VALUE })
|
@ValueSource(longs = { MAX, MAX - 1, Long.MIN_VALUE })
|
||||||
void le_all_validValue(long value) {
|
void le_all_validValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.le(MAX);
|
.le(MAX);
|
||||||
@ -620,7 +621,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MAX + 1, Long.MAX_VALUE })
|
@ValueSource(longs = { MAX + 1, Long.MAX_VALUE })
|
||||||
void le_default_invalidValue(long value) {
|
void le_default_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.le(MAX);
|
.le(MAX);
|
||||||
@ -637,7 +638,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MAX + 1, Long.MAX_VALUE })
|
@ValueSource(longs = { MAX + 1, Long.MAX_VALUE })
|
||||||
void le_message_invalidValue(long value) {
|
void le_message_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.le(MAX, MESSAGE_LE);
|
.le(MAX, MESSAGE_LE);
|
||||||
@ -654,7 +655,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MAX + 1, Long.MAX_VALUE })
|
@ValueSource(longs = { MAX + 1, Long.MAX_VALUE })
|
||||||
void le_exceptionSupplier_invalidValue(long value) {
|
void le_exceptionSupplier_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
||||||
@ -671,7 +672,7 @@ public class LongPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(longs = { MAX + 1, Long.MAX_VALUE })
|
@ValueSource(longs = { MAX + 1, Long.MAX_VALUE })
|
||||||
void le_exceptionFunction_invalidValue(long value) {
|
void le_exceptionFunction_invalidValue(long value) {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.le(MAX, property -> ExampleException.withMessage(
|
.le(MAX, property -> ExampleException.withMessage(
|
||||||
@ -697,7 +698,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_default_null() {
|
void le_default_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.le(MAX);
|
.le(MAX);
|
||||||
@ -713,7 +714,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_message_null() {
|
void le_message_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.le(MAX, MESSAGE_LE);
|
.le(MAX, MESSAGE_LE);
|
||||||
@ -729,7 +730,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_exceptionSupplier_null() {
|
void le_exceptionSupplier_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
.le(MAX, () -> ExampleException.withMessage(MESSAGE_LE));
|
||||||
@ -745,7 +746,7 @@ public class LongPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void le_exceptionFunction_null() {
|
void le_exceptionFunction_null() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForLong(ExampleCommand::getLongProperty)
|
ruleForLong(ExampleCommand::getLongProperty)
|
||||||
.le(MAX, property -> ExampleException.withMessage(
|
.le(MAX, property -> ExampleException.withMessage(
|
||||||
|
@ -37,6 +37,7 @@ import xyz.zhouxy.plusone.commons.util.StringTools;
|
|||||||
import xyz.zhouxy.plusone.example.ExampleCommand;
|
import xyz.zhouxy.plusone.example.ExampleCommand;
|
||||||
import xyz.zhouxy.plusone.example.Foo;
|
import xyz.zhouxy.plusone.example.Foo;
|
||||||
import xyz.zhouxy.plusone.validator.BaseValidator;
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
|
import xyz.zhouxy.plusone.validator.IValidator;
|
||||||
|
|
||||||
public class ObjectPropertyValidatorTests {
|
public class ObjectPropertyValidatorTests {
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void withRule_validInput() {
|
void withRule_validInput() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getBoolProperty)
|
ruleFor(ExampleCommand::getBoolProperty)
|
||||||
.notNull("The boolProperty cannot be null.")
|
.notNull("The boolProperty cannot be null.")
|
||||||
@ -103,7 +104,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void withRule_invalidInputs() {
|
void withRule_invalidInputs() {
|
||||||
ExampleCommand command = new ExampleCommand();
|
ExampleCommand command = new ExampleCommand();
|
||||||
BaseValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.withRule(x -> false);
|
.withRule(x -> false);
|
||||||
@ -113,7 +114,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> ruleWithDefaultMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithDefaultMessage.validate(command));
|
||||||
assertNull(eWithDefaultMessage.getMessage());
|
assertNull(eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.withRule(x -> false, "invalid input.");
|
.withRule(x -> false, "invalid input.");
|
||||||
@ -123,7 +124,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
||||||
assertEquals("invalid input.", eWithMessage.getMessage());
|
assertEquals("invalid input.", eWithMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.withRule(x -> false, () -> ExampleException.withMessage("invalid input."));
|
.withRule(x -> false, () -> ExampleException.withMessage("invalid input."));
|
||||||
@ -133,7 +134,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals("invalid input.", specifiedException.getMessage());
|
assertEquals("invalid input.", specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.withRule(x -> false, x -> ExampleException.withMessage("invalid input: [%s].", x));
|
.withRule(x -> false, x -> ExampleException.withMessage("invalid input: [%s].", x));
|
||||||
@ -154,7 +155,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notNull_validInput() {
|
void notNull_validInput() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.notNull();
|
.notNull();
|
||||||
@ -191,7 +192,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
void notNull_invalidInput() {
|
void notNull_invalidInput() {
|
||||||
ExampleCommand command = new ExampleCommand();
|
ExampleCommand command = new ExampleCommand();
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.notNull();
|
.notNull();
|
||||||
@ -201,7 +202,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> defaultRule.validate(command));
|
IllegalArgumentException.class, () -> defaultRule.validate(command));
|
||||||
assertEquals("The input must not be null.", eWithDefaultMessage.getMessage());
|
assertEquals("The input must not be null.", eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.notNull("The objectProperty could not be null.");
|
.notNull("The objectProperty could not be null.");
|
||||||
@ -211,7 +212,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
||||||
assertEquals("The objectProperty could not be null.", eWithSpecifiedMessage.getMessage());
|
assertEquals("The objectProperty could not be null.", eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.notNull(() -> ExampleException.withMessage("The objectProperty could not be null."));
|
.notNull(() -> ExampleException.withMessage("The objectProperty could not be null."));
|
||||||
@ -221,7 +222,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals("The objectProperty could not be null.", specifiedException.getMessage());
|
assertEquals("The objectProperty could not be null.", specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.notNull(str -> ExampleException.withMessage("The objectProperty could not be null, but is was " + str));
|
.notNull(str -> ExampleException.withMessage("The objectProperty could not be null, but is was " + str));
|
||||||
@ -242,7 +243,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isNull_validInput() {
|
void isNull_validInput() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForBool(ExampleCommand::getBoolProperty)
|
ruleForBool(ExampleCommand::getBoolProperty)
|
||||||
.isNull();
|
.isNull();
|
||||||
@ -272,7 +273,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleCommand command = new ExampleCommand();
|
ExampleCommand command = new ExampleCommand();
|
||||||
command.setObjectProperty(new Foo(Integer.MAX_VALUE, "StringValue"));
|
command.setObjectProperty(new Foo(Integer.MAX_VALUE, "StringValue"));
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.isNull();
|
.isNull();
|
||||||
@ -282,7 +283,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> ruleWithDefaultMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithDefaultMessage.validate(command));
|
||||||
assertEquals("The input must be null.", eWithDefaultMessage.getMessage());
|
assertEquals("The input must be null.", eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.isNull("The objectProperty should be null.");
|
.isNull("The objectProperty should be null.");
|
||||||
@ -292,7 +293,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
||||||
assertEquals("The objectProperty should be null.", eWithSpecifiedMessage.getMessage());
|
assertEquals("The objectProperty should be null.", eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.isNull(() -> ExampleException.withMessage("The objectProperty should be null."));
|
.isNull(() -> ExampleException.withMessage("The objectProperty should be null."));
|
||||||
@ -302,7 +303,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals("The objectProperty should be null.", specifiedException.getMessage());
|
assertEquals("The objectProperty should be null.", specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleFor(ExampleCommand::getObjectProperty)
|
ruleFor(ExampleCommand::getObjectProperty)
|
||||||
.isNull(str -> ExampleException.withMessage("The objectProperty should be null, but is was " + str));
|
.isNull(str -> ExampleException.withMessage("The objectProperty should be null, but is was " + str));
|
||||||
@ -323,7 +324,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void equalTo_validInput() {
|
void equalTo_validInput() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.equalTo("Foo")
|
.equalTo("Foo")
|
||||||
@ -345,7 +346,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleCommand command = new ExampleCommand();
|
ExampleCommand command = new ExampleCommand();
|
||||||
command.setStringProperty("Bar");
|
command.setStringProperty("Bar");
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo");
|
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo");
|
||||||
}
|
}
|
||||||
@ -354,7 +355,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> defaultRule.validate(command));
|
IllegalArgumentException.class, () -> defaultRule.validate(command));
|
||||||
assertEquals("The input must be equal to 'Foo'.", eWithDefaultMessage.getMessage());
|
assertEquals("The input must be equal to 'Foo'.", eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
||||||
"The stringProperty should be equal to 'Foo'.");
|
"The stringProperty should be equal to 'Foo'.");
|
||||||
@ -364,7 +365,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
||||||
assertEquals("The stringProperty should be equal to 'Foo'.", eWithSpecifiedMessage.getMessage());
|
assertEquals("The stringProperty should be equal to 'Foo'.", eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
||||||
() -> ExampleException.withMessage("The stringProperty should be equal to 'Foo'."));
|
() -> ExampleException.withMessage("The stringProperty should be equal to 'Foo'."));
|
||||||
@ -374,7 +375,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals("The stringProperty should be equal to 'Foo'.", specifiedException.getMessage());
|
assertEquals("The stringProperty should be equal to 'Foo'.", specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
||||||
str -> ExampleException.withMessage("The stringProperty should be equal to 'Foo', but is was '%s'.", str));
|
str -> ExampleException.withMessage("The stringProperty should be equal to 'Foo', but is was '%s'.", str));
|
||||||
@ -389,7 +390,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
void equalTo_nullInput() {
|
void equalTo_nullInput() {
|
||||||
ExampleCommand command = new ExampleCommand();
|
ExampleCommand command = new ExampleCommand();
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo");
|
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo");
|
||||||
}
|
}
|
||||||
@ -398,7 +399,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> defaultRule.validate(command));
|
IllegalArgumentException.class, () -> defaultRule.validate(command));
|
||||||
assertEquals("The input must be equal to 'Foo'.", eWithDefaultMessage.getMessage());
|
assertEquals("The input must be equal to 'Foo'.", eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
||||||
"The stringProperty should be equal to 'Foo'.");
|
"The stringProperty should be equal to 'Foo'.");
|
||||||
@ -408,7 +409,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
||||||
assertEquals("The stringProperty should be equal to 'Foo'.", eWithSpecifiedMessage.getMessage());
|
assertEquals("The stringProperty should be equal to 'Foo'.", eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
||||||
() -> ExampleException.withMessage("The stringProperty should be equal to 'Foo'."));
|
() -> ExampleException.withMessage("The stringProperty should be equal to 'Foo'."));
|
||||||
@ -418,7 +419,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals("The stringProperty should be equal to 'Foo'.", specifiedException.getMessage());
|
assertEquals("The stringProperty should be equal to 'Foo'.", specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
ruleForString(ExampleCommand::getStringProperty).equalTo("Foo",
|
||||||
str -> ExampleException.withMessage("The stringProperty should be equal to 'Foo', but is was '%s'.", str));
|
str -> ExampleException.withMessage("The stringProperty should be equal to 'Foo', but is was '%s'.", str));
|
||||||
@ -442,7 +443,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleCommand command = new ExampleCommand();
|
ExampleCommand command = new ExampleCommand();
|
||||||
command.setStringProperty("Foo");
|
command.setStringProperty("Foo");
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.must(str -> Objects.equals(str, "Foo"))
|
.must(str -> Objects.equals(str, "Foo"))
|
||||||
@ -458,7 +459,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
void must_oneCondition_invalid() {
|
void must_oneCondition_invalid() {
|
||||||
ExampleCommand command = new ExampleCommand();
|
ExampleCommand command = new ExampleCommand();
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.must(str -> Objects.equals(str, "Foo"));
|
.must(str -> Objects.equals(str, "Foo"));
|
||||||
@ -468,7 +469,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> ruleWithDefaultMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithDefaultMessage.validate(command));
|
||||||
assertEquals("The specified condition was not met for the input.", eWithDefaultMessage.getMessage());
|
assertEquals("The specified condition was not met for the input.", eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.must(str -> Objects.equals(str, "Foo"),
|
.must(str -> Objects.equals(str, "Foo"),
|
||||||
@ -479,7 +480,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
||||||
assertEquals("The stringProperty must be equal to 'Foo'.", eWithSpecifiedMessage.getMessage());
|
assertEquals("The stringProperty must be equal to 'Foo'.", eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.must(str -> Objects.equals(str, "Foo"),
|
.must(str -> Objects.equals(str, "Foo"),
|
||||||
@ -490,7 +491,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals("The stringProperty must be equal to 'Foo'.", specifiedException.getMessage());
|
assertEquals("The stringProperty must be equal to 'Foo'.", specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.must(str -> Objects.equals(str, "Foo"),
|
.must(str -> Objects.equals(str, "Foo"),
|
||||||
@ -507,7 +508,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleCommand command = new ExampleCommand();
|
ExampleCommand command = new ExampleCommand();
|
||||||
command.setStringProperty("Foo");
|
command.setStringProperty("Foo");
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.must(ImmutableList.of(StringTools::isNotEmpty, str -> Objects.equals(str, "Foo")))
|
.must(ImmutableList.of(StringTools::isNotEmpty, str -> Objects.equals(str, "Foo")))
|
||||||
@ -524,7 +525,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleCommand command = new ExampleCommand();
|
ExampleCommand command = new ExampleCommand();
|
||||||
command.setStringProperty("Bar");
|
command.setStringProperty("Bar");
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithDefaultMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.must(ImmutableList.of(StringTools::isNotEmpty, str -> Objects.equals(str, "Foo")));
|
.must(ImmutableList.of(StringTools::isNotEmpty, str -> Objects.equals(str, "Foo")));
|
||||||
@ -534,7 +535,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> ruleWithDefaultMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithDefaultMessage.validate(command));
|
||||||
assertEquals("The specified conditions were not met for the input.", eWithDefaultMessage.getMessage());
|
assertEquals("The specified conditions were not met for the input.", eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.must(ImmutableList.of(StringTools::isNotEmpty, str -> Objects.equals(str, "Foo")),
|
.must(ImmutableList.of(StringTools::isNotEmpty, str -> Objects.equals(str, "Foo")),
|
||||||
@ -545,7 +546,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
IllegalArgumentException.class, () -> ruleWithMessage.validate(command));
|
||||||
assertEquals("The stringProperty must be equal to 'Foo'.", eWithSpecifiedMessage.getMessage());
|
assertEquals("The stringProperty must be equal to 'Foo'.", eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.must(ImmutableList.of(StringTools::isNotEmpty, str -> Objects.equals(str, "Foo")),
|
.must(ImmutableList.of(StringTools::isNotEmpty, str -> Objects.equals(str, "Foo")),
|
||||||
@ -556,7 +557,7 @@ public class ObjectPropertyValidatorTests {
|
|||||||
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
ExampleException.class, () -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals("The stringProperty must be equal to 'Foo'.", specifiedException.getMessage());
|
assertEquals("The stringProperty must be equal to 'Foo'.", specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.must(ImmutableList.of(StringTools::isNotEmpty, str -> Objects.equals(str, "Foo")),
|
.must(ImmutableList.of(StringTools::isNotEmpty, str -> Objects.equals(str, "Foo")),
|
||||||
|
@ -31,6 +31,7 @@ import xyz.zhouxy.plusone.ExampleException;
|
|||||||
import xyz.zhouxy.plusone.commons.util.StringTools;
|
import xyz.zhouxy.plusone.commons.util.StringTools;
|
||||||
import xyz.zhouxy.plusone.example.ExampleCommand;
|
import xyz.zhouxy.plusone.example.ExampleCommand;
|
||||||
import xyz.zhouxy.plusone.validator.BaseValidator;
|
import xyz.zhouxy.plusone.validator.BaseValidator;
|
||||||
|
import xyz.zhouxy.plusone.validator.IValidator;
|
||||||
|
|
||||||
public class StringPropertyValidatorTests {
|
public class StringPropertyValidatorTests {
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ public class StringPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void matches_InputMatchesPattern() {
|
void matches_InputMatchesPattern() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matches(Pattern.compile("\\w{3,6}"), MESSAGE_SHOULD_MATCH)
|
.matches(Pattern.compile("\\w{3,6}"), MESSAGE_SHOULD_MATCH)
|
||||||
@ -64,7 +65,7 @@ public class StringPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void matches_message_InputDoesNotMatchPattern() {
|
void matches_message_InputDoesNotMatchPattern() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matches(Pattern.compile("\\w{3,6}"), MESSAGE_SHOULD_MATCH);
|
.matches(Pattern.compile("\\w{3,6}"), MESSAGE_SHOULD_MATCH);
|
||||||
@ -80,7 +81,7 @@ public class StringPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void matches_exceptionSupplier_InputDoesNotMatchPattern() {
|
void matches_exceptionSupplier_InputDoesNotMatchPattern() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matches(Pattern.compile("\\w{3,6}"), () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
.matches(Pattern.compile("\\w{3,6}"), () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
||||||
@ -96,7 +97,7 @@ public class StringPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void matches_exceptionFunction_InputDoesNotMatchPattern() {
|
void matches_exceptionFunction_InputDoesNotMatchPattern() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matches(Pattern.compile("\\w{3,6}"), str -> ExampleException.withMessage(
|
.matches(Pattern.compile("\\w{3,6}"), str -> ExampleException.withMessage(
|
||||||
@ -113,7 +114,7 @@ public class StringPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void matches_message_InputIsNull() {
|
void matches_message_InputIsNull() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matches(Pattern.compile("\\w{3,6}"), MESSAGE_SHOULD_MATCH);
|
.matches(Pattern.compile("\\w{3,6}"), MESSAGE_SHOULD_MATCH);
|
||||||
@ -126,7 +127,7 @@ public class StringPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void matches_exceptionSupplier_InputIsNull() {
|
void matches_exceptionSupplier_InputIsNull() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matches(Pattern.compile("\\w{3,6}"), () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
.matches(Pattern.compile("\\w{3,6}"), () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
||||||
@ -139,7 +140,7 @@ public class StringPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void matches_exceptionFunction_InputIsNull() {
|
void matches_exceptionFunction_InputIsNull() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matches(Pattern.compile("\\w{3,6}"), str -> ExampleException.withMessage(
|
.matches(Pattern.compile("\\w{3,6}"), str -> ExampleException.withMessage(
|
||||||
@ -165,7 +166,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}")
|
Pattern.compile("\\w{4,6}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, MESSAGE_SHOULD_MATCH)
|
.matchesOne(patterns, MESSAGE_SHOULD_MATCH)
|
||||||
@ -185,7 +186,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}")
|
Pattern.compile("\\w{4,6}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, MESSAGE_SHOULD_MATCH);
|
.matchesOne(patterns, MESSAGE_SHOULD_MATCH);
|
||||||
@ -205,7 +206,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}")
|
Pattern.compile("\\w{4,6}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
.matchesOne(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
||||||
@ -225,7 +226,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}")
|
Pattern.compile("\\w{4,6}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, str -> ExampleException.withMessage(
|
.matchesOne(patterns, str -> ExampleException.withMessage(
|
||||||
@ -246,7 +247,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}")
|
Pattern.compile("\\w{4,6}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, MESSAGE_SHOULD_MATCH);
|
.matchesOne(patterns, MESSAGE_SHOULD_MATCH);
|
||||||
@ -263,7 +264,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}")
|
Pattern.compile("\\w{4,6}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
.matchesOne(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
||||||
@ -280,7 +281,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}")
|
Pattern.compile("\\w{4,6}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, str -> ExampleException.withMessage(
|
.matchesOne(patterns, str -> ExampleException.withMessage(
|
||||||
@ -297,7 +298,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}"));
|
Pattern.compile("\\w{4,6}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, MESSAGE_SHOULD_MATCH)
|
.matchesOne(patterns, MESSAGE_SHOULD_MATCH)
|
||||||
@ -316,7 +317,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}"));
|
Pattern.compile("\\w{4,6}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, MESSAGE_SHOULD_MATCH);
|
.matchesOne(patterns, MESSAGE_SHOULD_MATCH);
|
||||||
@ -335,7 +336,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}"));
|
Pattern.compile("\\w{4,6}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
.matchesOne(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
||||||
@ -354,7 +355,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}"));
|
Pattern.compile("\\w{4,6}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, str -> ExampleException.withMessage(
|
.matchesOne(patterns, str -> ExampleException.withMessage(
|
||||||
@ -374,7 +375,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}"));
|
Pattern.compile("\\w{4,6}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, MESSAGE_SHOULD_MATCH);
|
.matchesOne(patterns, MESSAGE_SHOULD_MATCH);
|
||||||
@ -390,7 +391,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}"));
|
Pattern.compile("\\w{4,6}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
.matchesOne(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
||||||
@ -406,7 +407,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{1,3}"),
|
Pattern.compile("\\w{1,3}"),
|
||||||
Pattern.compile("\\w{4,6}"));
|
Pattern.compile("\\w{4,6}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesOne(patterns, str -> ExampleException.withMessage(
|
.matchesOne(patterns, str -> ExampleException.withMessage(
|
||||||
@ -432,7 +433,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}")
|
Pattern.compile("\\w{5,7}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, MESSAGE_SHOULD_MATCH)
|
.matchesAll(patterns, MESSAGE_SHOULD_MATCH)
|
||||||
@ -452,7 +453,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}")
|
Pattern.compile("\\w{5,7}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, MESSAGE_SHOULD_MATCH);
|
.matchesAll(patterns, MESSAGE_SHOULD_MATCH);
|
||||||
@ -472,7 +473,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}")
|
Pattern.compile("\\w{5,7}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
.matchesAll(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
||||||
@ -492,7 +493,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}")
|
Pattern.compile("\\w{5,7}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, str -> ExampleException.withMessage(
|
.matchesAll(patterns, str -> ExampleException.withMessage(
|
||||||
@ -513,7 +514,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}")
|
Pattern.compile("\\w{5,7}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, MESSAGE_SHOULD_MATCH);
|
.matchesAll(patterns, MESSAGE_SHOULD_MATCH);
|
||||||
@ -530,7 +531,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}")
|
Pattern.compile("\\w{5,7}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
.matchesAll(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
||||||
@ -547,7 +548,7 @@ public class StringPropertyValidatorTests {
|
|||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}")
|
Pattern.compile("\\w{5,7}")
|
||||||
};
|
};
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, str -> ExampleException.withMessage(
|
.matchesAll(patterns, str -> ExampleException.withMessage(
|
||||||
@ -564,7 +565,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}"));
|
Pattern.compile("\\w{5,7}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, MESSAGE_SHOULD_MATCH)
|
.matchesAll(patterns, MESSAGE_SHOULD_MATCH)
|
||||||
@ -583,7 +584,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}"));
|
Pattern.compile("\\w{5,7}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, MESSAGE_SHOULD_MATCH);
|
.matchesAll(patterns, MESSAGE_SHOULD_MATCH);
|
||||||
@ -602,7 +603,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}"));
|
Pattern.compile("\\w{5,7}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
.matchesAll(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
||||||
@ -621,7 +622,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}"));
|
Pattern.compile("\\w{5,7}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, str -> ExampleException.withMessage(
|
.matchesAll(patterns, str -> ExampleException.withMessage(
|
||||||
@ -641,7 +642,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}"));
|
Pattern.compile("\\w{5,7}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, MESSAGE_SHOULD_MATCH);
|
.matchesAll(patterns, MESSAGE_SHOULD_MATCH);
|
||||||
@ -657,7 +658,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}"));
|
Pattern.compile("\\w{5,7}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
.matchesAll(patterns, () -> ExampleException.withMessage(MESSAGE_SHOULD_MATCH));
|
||||||
@ -673,7 +674,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final List<Pattern> patterns = Lists.newArrayList(
|
final List<Pattern> patterns = Lists.newArrayList(
|
||||||
Pattern.compile("\\w{4,6}"),
|
Pattern.compile("\\w{4,6}"),
|
||||||
Pattern.compile("\\w{5,7}"));
|
Pattern.compile("\\w{5,7}"));
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.matchesAll(patterns, str -> ExampleException.withMessage(
|
.matchesAll(patterns, str -> ExampleException.withMessage(
|
||||||
@ -695,7 +696,7 @@ public class StringPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notBlank_all_validInput() {
|
void notBlank_all_validInput() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notBlank()
|
.notBlank()
|
||||||
@ -714,7 +715,7 @@ public class StringPropertyValidatorTests {
|
|||||||
void notBlank_invalidInput(String value) {
|
void notBlank_invalidInput(String value) {
|
||||||
ExampleCommand command = exampleCommandWithStringProperty(value);
|
ExampleCommand command = exampleCommandWithStringProperty(value);
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notBlank();
|
.notBlank();
|
||||||
@ -725,7 +726,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> defaultRule.validate(command));
|
() -> defaultRule.validate(command));
|
||||||
assertEquals("The input must not be blank.", eWithDefaultMessage.getMessage());
|
assertEquals("The input must not be blank.", eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notBlank(MESSAGE_NOT_BLANK);
|
.notBlank(MESSAGE_NOT_BLANK);
|
||||||
@ -736,7 +737,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithMessage.validate(command));
|
() -> ruleWithMessage.validate(command));
|
||||||
assertEquals(MESSAGE_NOT_BLANK, eWithSpecifiedMessage.getMessage());
|
assertEquals(MESSAGE_NOT_BLANK, eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notBlank(() -> ExampleException.withMessage(MESSAGE_NOT_BLANK));
|
.notBlank(() -> ExampleException.withMessage(MESSAGE_NOT_BLANK));
|
||||||
@ -747,7 +748,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithExceptionSupplier.validate(command));
|
() -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals(MESSAGE_NOT_BLANK, specifiedException.getMessage());
|
assertEquals(MESSAGE_NOT_BLANK, specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notBlank(str -> ExampleException.withMessage("The stringProperty cannot be blank, but is was %s", StringTools.toQuotedString(str)));
|
.notBlank(str -> ExampleException.withMessage("The stringProperty cannot be blank, but is was %s", StringTools.toQuotedString(str)));
|
||||||
@ -764,7 +765,7 @@ public class StringPropertyValidatorTests {
|
|||||||
void notBlank_nullInput() {
|
void notBlank_nullInput() {
|
||||||
ExampleCommand command = exampleCommandWithStringProperty(null);
|
ExampleCommand command = exampleCommandWithStringProperty(null);
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notBlank();
|
.notBlank();
|
||||||
@ -775,7 +776,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> defaultRule.validate(command));
|
() -> defaultRule.validate(command));
|
||||||
assertEquals("The input must not be blank.", eWithDefaultMessage.getMessage());
|
assertEquals("The input must not be blank.", eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notBlank(MESSAGE_NOT_BLANK);
|
.notBlank(MESSAGE_NOT_BLANK);
|
||||||
@ -786,7 +787,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithMessage.validate(command));
|
() -> ruleWithMessage.validate(command));
|
||||||
assertEquals(MESSAGE_NOT_BLANK, eWithSpecifiedMessage.getMessage());
|
assertEquals(MESSAGE_NOT_BLANK, eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notBlank(() -> ExampleException.withMessage(MESSAGE_NOT_BLANK));
|
.notBlank(() -> ExampleException.withMessage(MESSAGE_NOT_BLANK));
|
||||||
@ -797,7 +798,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithExceptionSupplier.validate(command));
|
() -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals(MESSAGE_NOT_BLANK, specifiedException.getMessage());
|
assertEquals(MESSAGE_NOT_BLANK, specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notBlank(str -> ExampleException.withMessage("The stringProperty cannot be blank, but is was %s", StringTools.toQuotedString(str)));
|
.notBlank(str -> ExampleException.withMessage("The stringProperty cannot be blank, but is was %s", StringTools.toQuotedString(str)));
|
||||||
@ -820,7 +821,7 @@ public class StringPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void emailAddress_validInput() {
|
void emailAddress_validInput() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.emailAddress()
|
.emailAddress()
|
||||||
@ -841,7 +842,7 @@ public class StringPropertyValidatorTests {
|
|||||||
void emailAddress_invalidInput(String value) {
|
void emailAddress_invalidInput(String value) {
|
||||||
ExampleCommand command = exampleCommandWithStringProperty(value);
|
ExampleCommand command = exampleCommandWithStringProperty(value);
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.emailAddress();
|
.emailAddress();
|
||||||
@ -852,7 +853,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> defaultRule.validate(command));
|
() -> defaultRule.validate(command));
|
||||||
assertEquals("The input is not a valid email address.", eWithDefaultMessage.getMessage());
|
assertEquals("The input is not a valid email address.", eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.emailAddress(MESSAGE_NOT_EMAIL);
|
.emailAddress(MESSAGE_NOT_EMAIL);
|
||||||
@ -863,7 +864,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithMessage.validate(command));
|
() -> ruleWithMessage.validate(command));
|
||||||
assertEquals(MESSAGE_NOT_EMAIL, eWithSpecifiedMessage.getMessage());
|
assertEquals(MESSAGE_NOT_EMAIL, eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.emailAddress(() -> ExampleException.withMessage(MESSAGE_NOT_EMAIL));
|
.emailAddress(() -> ExampleException.withMessage(MESSAGE_NOT_EMAIL));
|
||||||
@ -874,7 +875,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithExceptionSupplier.validate(command));
|
() -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals(MESSAGE_NOT_EMAIL, specifiedException.getMessage());
|
assertEquals(MESSAGE_NOT_EMAIL, specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.emailAddress(str -> ExampleException.withMessage("Input should be an email address, but it was \"%s\"", str));
|
.emailAddress(str -> ExampleException.withMessage("Input should be an email address, but it was \"%s\"", str));
|
||||||
@ -897,7 +898,7 @@ public class StringPropertyValidatorTests {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ValueSource(strings = { "abcd", " ", " ", "\t", "\n" })
|
@ValueSource(strings = { "abcd", " ", " ", "\t", "\n" })
|
||||||
void notEmpty_all_validInput() {
|
void notEmpty_all_validInput() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notEmpty()
|
.notEmpty()
|
||||||
@ -916,7 +917,7 @@ public class StringPropertyValidatorTests {
|
|||||||
final String value = "";
|
final String value = "";
|
||||||
ExampleCommand command = exampleCommandWithStringProperty(value);
|
ExampleCommand command = exampleCommandWithStringProperty(value);
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notEmpty();
|
.notEmpty();
|
||||||
@ -927,7 +928,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> defaultRule.validate(command));
|
() -> defaultRule.validate(command));
|
||||||
assertEquals("The input must not be empty.", eWithDefaultMessage.getMessage());
|
assertEquals("The input must not be empty.", eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notEmpty(MESSAGE_NOT_EMPTY);
|
.notEmpty(MESSAGE_NOT_EMPTY);
|
||||||
@ -938,7 +939,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithMessage.validate(command));
|
() -> ruleWithMessage.validate(command));
|
||||||
assertEquals(MESSAGE_NOT_EMPTY, eWithSpecifiedMessage.getMessage());
|
assertEquals(MESSAGE_NOT_EMPTY, eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notEmpty(() -> ExampleException.withMessage(MESSAGE_NOT_EMPTY));
|
.notEmpty(() -> ExampleException.withMessage(MESSAGE_NOT_EMPTY));
|
||||||
@ -949,7 +950,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithExceptionSupplier.validate(command));
|
() -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals(MESSAGE_NOT_EMPTY, specifiedException.getMessage());
|
assertEquals(MESSAGE_NOT_EMPTY, specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notEmpty(str -> ExampleException.withMessage("The stringProperty cannot be empty, but is was %s", StringTools.toQuotedString(str)));
|
.notEmpty(str -> ExampleException.withMessage("The stringProperty cannot be empty, but is was %s", StringTools.toQuotedString(str)));
|
||||||
@ -966,7 +967,7 @@ public class StringPropertyValidatorTests {
|
|||||||
void notEmpty_nullInput() {
|
void notEmpty_nullInput() {
|
||||||
ExampleCommand command = exampleCommandWithStringProperty(null);
|
ExampleCommand command = exampleCommandWithStringProperty(null);
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> defaultRule = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notEmpty();
|
.notEmpty();
|
||||||
@ -977,7 +978,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> defaultRule.validate(command));
|
() -> defaultRule.validate(command));
|
||||||
assertEquals("The input must not be empty.", eWithDefaultMessage.getMessage());
|
assertEquals("The input must not be empty.", eWithDefaultMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notEmpty(MESSAGE_NOT_EMPTY);
|
.notEmpty(MESSAGE_NOT_EMPTY);
|
||||||
@ -988,7 +989,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithMessage.validate(command));
|
() -> ruleWithMessage.validate(command));
|
||||||
assertEquals(MESSAGE_NOT_EMPTY, eWithSpecifiedMessage.getMessage());
|
assertEquals(MESSAGE_NOT_EMPTY, eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notEmpty(() -> ExampleException.withMessage(MESSAGE_NOT_EMPTY));
|
.notEmpty(() -> ExampleException.withMessage(MESSAGE_NOT_EMPTY));
|
||||||
@ -999,7 +1000,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithExceptionSupplier.validate(command));
|
() -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals(MESSAGE_NOT_EMPTY, specifiedException.getMessage());
|
assertEquals(MESSAGE_NOT_EMPTY, specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.notEmpty(str -> ExampleException.withMessage("The stringProperty cannot be empty, but is was %s", StringTools.toQuotedString(str)));
|
.notEmpty(str -> ExampleException.withMessage("The stringProperty cannot be empty, but is was %s", StringTools.toQuotedString(str)));
|
||||||
@ -1022,7 +1023,7 @@ public class StringPropertyValidatorTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void length_specifiedLength_validLength() {
|
void length_specifiedLength_validLength() {
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.length(MIN_LENGTH, "The length of the string must be 6")
|
.length(MIN_LENGTH, "The length of the string must be 6")
|
||||||
@ -1042,7 +1043,7 @@ public class StringPropertyValidatorTests {
|
|||||||
void length_specifiedLength_invalidLength(String value) {
|
void length_specifiedLength_invalidLength(String value) {
|
||||||
ExampleCommand command = exampleCommandWithStringProperty(value);
|
ExampleCommand command = exampleCommandWithStringProperty(value);
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.length(MIN_LENGTH, "The length of the string must be 6");
|
.length(MIN_LENGTH, "The length of the string must be 6");
|
||||||
@ -1053,7 +1054,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithMessage.validate(command));
|
() -> ruleWithMessage.validate(command));
|
||||||
assertEquals("The length of the string must be 6", eWithSpecifiedMessage.getMessage());
|
assertEquals("The length of the string must be 6", eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.length(MIN_LENGTH, () -> ExampleException.withMessage("The length of the string must be 6"));
|
.length(MIN_LENGTH, () -> ExampleException.withMessage("The length of the string must be 6"));
|
||||||
@ -1064,7 +1065,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithExceptionSupplier.validate(command));
|
() -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals("The length of the string must be 6", specifiedException.getMessage());
|
assertEquals("The length of the string must be 6", specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.length(MIN_LENGTH, str -> ExampleException.withMessage("The length of the string must be 6, but it was %d", str.length()));
|
.length(MIN_LENGTH, str -> ExampleException.withMessage("The length of the string must be 6, but it was %d", str.length()));
|
||||||
@ -1082,7 +1083,7 @@ public class StringPropertyValidatorTests {
|
|||||||
@ValueSource(strings = { "123456", "1234567", "12345678" })
|
@ValueSource(strings = { "123456", "1234567", "12345678" })
|
||||||
void length_specifiedMinLengthAndMaxLength_validLength(String value) {
|
void length_specifiedMinLengthAndMaxLength_validLength(String value) {
|
||||||
ExampleCommand command = exampleCommandWithStringProperty(value);
|
ExampleCommand command = exampleCommandWithStringProperty(value);
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.length(MIN_LENGTH, MAX_LENGTH, String.format("Min length is %d, max length is %d", MIN_LENGTH, MAX_LENGTH))
|
.length(MIN_LENGTH, MAX_LENGTH, String.format("Min length is %d, max length is %d", MIN_LENGTH, MAX_LENGTH))
|
||||||
@ -1096,7 +1097,7 @@ public class StringPropertyValidatorTests {
|
|||||||
@Test
|
@Test
|
||||||
void length_specifiedMinLengthAndMaxLength_null() {
|
void length_specifiedMinLengthAndMaxLength_null() {
|
||||||
ExampleCommand command = exampleCommandWithStringProperty(null);
|
ExampleCommand command = exampleCommandWithStringProperty(null);
|
||||||
BaseValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> validator = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.length(MIN_LENGTH, MAX_LENGTH, String.format("Min length is %d, max length is %d", MIN_LENGTH, MAX_LENGTH))
|
.length(MIN_LENGTH, MAX_LENGTH, String.format("Min length is %d, max length is %d", MIN_LENGTH, MAX_LENGTH))
|
||||||
@ -1112,7 +1113,7 @@ public class StringPropertyValidatorTests {
|
|||||||
void length_specifiedMinLengthAndMaxLength_invalidLength(String value) {
|
void length_specifiedMinLengthAndMaxLength_invalidLength(String value) {
|
||||||
ExampleCommand command = exampleCommandWithStringProperty(value);
|
ExampleCommand command = exampleCommandWithStringProperty(value);
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithMessage = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.length(MIN_LENGTH, MAX_LENGTH, String.format("Min length is %d, max length is %d", MIN_LENGTH, MAX_LENGTH));
|
.length(MIN_LENGTH, MAX_LENGTH, String.format("Min length is %d, max length is %d", MIN_LENGTH, MAX_LENGTH));
|
||||||
@ -1123,7 +1124,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithMessage.validate(command));
|
() -> ruleWithMessage.validate(command));
|
||||||
assertEquals("Min length is 6, max length is 8", eWithSpecifiedMessage.getMessage());
|
assertEquals("Min length is 6, max length is 8", eWithSpecifiedMessage.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionSupplier = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.length(MIN_LENGTH, MAX_LENGTH, () -> ExampleException.withMessage("Min length is %d, max length is %d", MIN_LENGTH, MAX_LENGTH));
|
.length(MIN_LENGTH, MAX_LENGTH, () -> ExampleException.withMessage("Min length is %d, max length is %d", MIN_LENGTH, MAX_LENGTH));
|
||||||
@ -1134,7 +1135,7 @@ public class StringPropertyValidatorTests {
|
|||||||
() -> ruleWithExceptionSupplier.validate(command));
|
() -> ruleWithExceptionSupplier.validate(command));
|
||||||
assertEquals("Min length is 6, max length is 8", specifiedException.getMessage());
|
assertEquals("Min length is 6, max length is 8", specifiedException.getMessage());
|
||||||
|
|
||||||
BaseValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
IValidator<ExampleCommand> ruleWithExceptionFunction = new BaseValidator<ExampleCommand>() {
|
||||||
{
|
{
|
||||||
ruleForString(ExampleCommand::getStringProperty)
|
ruleForString(ExampleCommand::getStringProperty)
|
||||||
.length(MIN_LENGTH, MAX_LENGTH, str -> ExampleException.withMessage("Length of StringProperty is %d, min length is %d, max length is %d", str.length(), MIN_LENGTH, MAX_LENGTH));
|
.length(MIN_LENGTH, MAX_LENGTH, str -> ExampleException.withMessage("Length of StringProperty is %d, min length is %d, max length is %d", str.length(), MIN_LENGTH, MAX_LENGTH));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user