@@ -53,6 +53,20 @@ public class ResultTests {
5353 }
5454
5555 @ Test public void testResultOfCorrect () throws Exception {
56+ Result <String , Exception > result = Result .of (new Function <String >() {
57+ @ Override public String call () throws Exception {
58+ return OOOH_YEAH ;
59+ }
60+ });
61+
62+ assertThat (result .isSuccess (), is (true ));
63+ assertThat (result .value (), is (notNullValue ()));
64+ assertThat (result .isEmpty (), is (false ));
65+ assertThat (result .value (), is (OOOH_YEAH ));
66+ assertThat (result .error (), is (nullValue ()));
67+ }
68+
69+ @ Test public void testResultOfFailureCorrect () throws Exception {
5670 Result <String , Exception > result = Result .of (new Function <String >() {
5771 @ Override public String call () throws Exception {
5872 // Just throw IllegalStateException
@@ -87,16 +101,29 @@ public class ResultTests {
87101 @ Test public void testResultOrFailNullErrorCorrect () throws Exception {
88102 Result <String , String > result = Result .orFailWith (new Function <String >() {
89103 @ Override public String call () throws Exception {
90- throw new NullPointerException ( OOOH_NOOO ) ;
104+ return OOOH_YEAH ;
91105 }
92106 }, null );
93107
94- assertThat (result .isSuccess (), is (false ));
95- assertThat (result .value (), is (nullValue () ));
96- assertThat (result .isEmpty (), is (true ));
108+ assertThat (result .isSuccess (), is (true ));
109+ assertThat (result .isEmpty (), is (false ));
110+ assertThat (result .value (), is (OOOH_YEAH ));
97111 assertThat (result .error (), is (nullValue ()));
98112 }
99113
114+ @ Test public void testResultOrDefaultCorrect () throws Exception {
115+ Result <String , String > result = Result .orDefault (new Function <String >() {
116+ @ Override public String call () throws Exception {
117+ return OOOH_YEAH ;
118+ }
119+ }, OOOH_NOOO );
120+
121+ assertThat (result .isSuccess (), is (true ));
122+ assertThat (result .isEmpty (), is (false ));
123+ assertThat (result .error (), is (nullValue ()));
124+ assertThat (result .value (), is (OOOH_YEAH ));
125+ }
126+
100127 @ Test public void testResultOrDefaultReturnDefault () throws Exception {
101128 Result <String , String > result = Result .orDefault (new Function <String >() {
102129 @ Override public String call () throws Exception {
0 commit comments