diff options
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/org/pacien/lemonad/attempt/AttemptTest.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/test/java/org/pacien/lemonad/attempt/AttemptTest.java b/src/test/java/org/pacien/lemonad/attempt/AttemptTest.java index 1cb79c9..0d16c31 100644 --- a/src/test/java/org/pacien/lemonad/attempt/AttemptTest.java +++ b/src/test/java/org/pacien/lemonad/attempt/AttemptTest.java | |||
@@ -89,12 +89,15 @@ class AttemptTest { | |||
89 | var error3 = false; | 89 | var error3 = false; |
90 | 90 | ||
91 | Attempt.<Integer, Long>success(result0) | 91 | Attempt.<Integer, Long>success(result0) |
92 | .mapError((Long err) -> { | 92 | .recoverError((Long err) -> { |
93 | fail(); | 93 | fail(); |
94 | return Attempt.failure(err); | 94 | return Attempt.failure(err); |
95 | }) | 95 | }) |
96 | .mapResult((Integer res) -> Attempt.success(result1)) | 96 | .mapResult((Integer res) -> { |
97 | .mapResult((String res) -> { | 97 | assertEquals(result0, res); |
98 | return result1; | ||
99 | }) | ||
100 | .transformResult((String res) -> { | ||
98 | assertEquals(result1, res); | 101 | assertEquals(result1, res); |
99 | return Attempt.<String, Integer>failure(error0); | 102 | return Attempt.<String, Integer>failure(error0); |
100 | }, (Integer err) -> { | 103 | }, (Integer err) -> { |
@@ -102,15 +105,15 @@ class AttemptTest { | |||
102 | return (long) err; | 105 | return (long) err; |
103 | }) | 106 | }) |
104 | .ifSuccess((String __) -> fail()) | 107 | .ifSuccess((String __) -> fail()) |
105 | .mapResult((String res) -> { | 108 | .transformResult((String res) -> { |
106 | fail(); | 109 | fail(); |
107 | return Attempt.success(res); | 110 | return Attempt.success(res); |
108 | }) | 111 | }) |
109 | .mapError((Long err) -> { | 112 | .mapError((Long err) -> { |
110 | assertEquals(error0, err); | 113 | assertEquals(error0, err); |
111 | return Attempt.failure(error1); | 114 | return error1; |
112 | }) | 115 | }) |
113 | .mapError((Long err) -> { | 116 | .recoverError((Long err) -> { |
114 | assertEquals(error1, err); | 117 | assertEquals(error1, err); |
115 | return Attempt.<Long, Long>success(result2); | 118 | return Attempt.<Long, Long>success(result2); |
116 | }, (Long res) -> { | 119 | }, (Long res) -> { |
@@ -124,7 +127,7 @@ class AttemptTest { | |||
124 | }) | 127 | }) |
125 | .ifSuccess(__ -> fail()) | 128 | .ifSuccess(__ -> fail()) |
126 | .ifFailure(f -> assertEquals(error2, f)) | 129 | .ifFailure(f -> assertEquals(error2, f)) |
127 | .map((String __) -> Attempt.failure(error3), (String __) -> Attempt.success(result3)) | 130 | .transform((String __) -> Attempt.failure(error3), (String __) -> Attempt.success(result3)) |
128 | .ifSuccess((String result) -> assertEquals(result3, result)) | 131 | .ifSuccess((String result) -> assertEquals(result3, result)) |
129 | .ifFailure((Boolean __) -> fail()); | 132 | .ifFailure((Boolean __) -> fail()); |
130 | } | 133 | } |