From 60a665926403e65ae6abf181916c439db52ce0e2 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 5 Apr 2019 05:11:13 +0200 Subject: refactor and add simple mapping inner methods --- .../java/org/pacien/lemonad/attempt/AttemptTest.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/test/java/org') 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 { var error3 = false; Attempt.success(result0) - .mapError((Long err) -> { + .recoverError((Long err) -> { fail(); return Attempt.failure(err); }) - .mapResult((Integer res) -> Attempt.success(result1)) - .mapResult((String res) -> { + .mapResult((Integer res) -> { + assertEquals(result0, res); + return result1; + }) + .transformResult((String res) -> { assertEquals(result1, res); return Attempt.failure(error0); }, (Integer err) -> { @@ -102,15 +105,15 @@ class AttemptTest { return (long) err; }) .ifSuccess((String __) -> fail()) - .mapResult((String res) -> { + .transformResult((String res) -> { fail(); return Attempt.success(res); }) .mapError((Long err) -> { assertEquals(error0, err); - return Attempt.failure(error1); + return error1; }) - .mapError((Long err) -> { + .recoverError((Long err) -> { assertEquals(error1, err); return Attempt.success(result2); }, (Long res) -> { @@ -124,7 +127,7 @@ class AttemptTest { }) .ifSuccess(__ -> fail()) .ifFailure(f -> assertEquals(error2, f)) - .map((String __) -> Attempt.failure(error3), (String __) -> Attempt.success(result3)) + .transform((String __) -> Attempt.failure(error3), (String __) -> Attempt.success(result3)) .ifSuccess((String result) -> assertEquals(result3, result)) .ifFailure((Boolean __) -> fail()); } -- cgit v1.2.3