diff options
Diffstat (limited to 'src/test/java/org/pacien/lemonad')
-rw-r--r-- | src/test/java/org/pacien/lemonad/validation/ValidationTest.java (renamed from src/test/java/org/pacien/lemonad/validation/ValidationResultTest.java) | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/test/java/org/pacien/lemonad/validation/ValidationResultTest.java b/src/test/java/org/pacien/lemonad/validation/ValidationTest.java index 65b2cb3..665f501 100644 --- a/src/test/java/org/pacien/lemonad/validation/ValidationResultTest.java +++ b/src/test/java/org/pacien/lemonad/validation/ValidationTest.java | |||
@@ -32,44 +32,44 @@ import static org.junit.jupiter.api.Assertions.fail; | |||
32 | /** | 32 | /** |
33 | * @author pacien | 33 | * @author pacien |
34 | */ | 34 | */ |
35 | class ValidationResultTest { | 35 | class ValidationTest { |
36 | @Test void testValidResult() { | 36 | @Test void testValidResult() { |
37 | var subject = "subject"; | 37 | var subject = "subject"; |
38 | var validationResult = ValidationResult.valid(subject); | 38 | var validation = Validation.valid(subject); |
39 | assertTrue(validationResult.getErrors().isEmpty()); | 39 | assertTrue(validation.getErrors().isEmpty()); |
40 | assertTrue(validationResult.isValid()); | 40 | assertTrue(validation.isValid()); |
41 | assertFalse(validationResult.isInvalid()); | 41 | assertFalse(validation.isInvalid()); |
42 | validationResult.ifValid(innerSubject -> assertEquals(subject, innerSubject)); | 42 | validation.ifValid(innerSubject -> assertEquals(subject, innerSubject)); |
43 | validationResult.ifInvalid((__, ___) -> fail()); | 43 | validation.ifInvalid((__, ___) -> fail()); |
44 | } | 44 | } |
45 | 45 | ||
46 | @Test void testInvalidResult() { | 46 | @Test void testInvalidResult() { |
47 | var subject = "subject"; | 47 | var subject = "subject"; |
48 | var errors = List.of(0, 1); | 48 | var errors = List.of(0, 1); |
49 | var validationResult = ValidationResult.invalid(subject, 0, 1); | 49 | var validation = Validation.invalid(subject, 0, 1); |
50 | assertEquals(errors, validationResult.getErrors()); | 50 | assertEquals(errors, validation.getErrors()); |
51 | assertFalse(validationResult.isValid()); | 51 | assertFalse(validation.isValid()); |
52 | assertTrue(validationResult.isInvalid()); | 52 | assertTrue(validation.isInvalid()); |
53 | validationResult.ifValid(Assertions::fail); | 53 | validation.ifValid(Assertions::fail); |
54 | validationResult.ifInvalid((innerSubject, innerErrors) -> { | 54 | validation.ifInvalid((innerSubject, innerErrors) -> { |
55 | assertEquals(subject, innerSubject); | 55 | assertEquals(subject, innerSubject); |
56 | assertEquals(errors, innerErrors); | 56 | assertEquals(errors, innerErrors); |
57 | }); | 57 | }); |
58 | } | 58 | } |
59 | 59 | ||
60 | @Test void testFlatMap() { | 60 | @Test void testFlatMap() { |
61 | ValidationResult.valid("subject") | 61 | Validation.valid("subject") |
62 | .ifInvalid((__, ___) -> fail()) | 62 | .ifInvalid((__, ___) -> fail()) |
63 | .flatMap(res -> ValidationResult.invalid(res.getSubject(), 0)) | 63 | .flatMap(res -> Validation.invalid(res.getSubject(), 0)) |
64 | .ifValid(innerSubject -> fail()); | 64 | .ifValid(innerSubject -> fail()); |
65 | } | 65 | } |
66 | 66 | ||
67 | @Test void testMerge() { | 67 | @Test void testMerge() { |
68 | var subject = "subject"; | 68 | var subject = "subject"; |
69 | assertEquals(List.of(0, 1, 2, 3), ValidationResult.merge(subject, Stream.of( | 69 | assertEquals(List.of(0, 1, 2, 3), Validation.merge(subject, Stream.of( |
70 | ValidationResult.valid(subject), | 70 | Validation.valid(subject), |
71 | ValidationResult.invalid(subject, 0, 1), | 71 | Validation.invalid(subject, 0, 1), |
72 | ValidationResult.invalid(subject, 2, 3)) | 72 | Validation.invalid(subject, 2, 3)) |
73 | ).getErrors()); | 73 | ).getErrors()); |
74 | } | 74 | } |
75 | } | 75 | } |