-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aca7220
commit 6138e8f
Showing
7 changed files
with
140 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/test/java/io/advantageous/reakt/impl/ExpectedImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.advantageous.reakt.impl; | ||
|
||
import io.advantageous.reakt.Expected; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.Collections; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class ExpectedImplTest { | ||
|
||
|
||
@Test | ||
public void isAbsent() throws Exception { | ||
|
||
final Expected<Object> objectExpected = Expected.ofNullable(null); | ||
assertTrue(objectExpected.isAbsent()); | ||
} | ||
|
||
@Test | ||
public void isEmpty() throws Exception { | ||
|
||
final Expected<Object> expected1 = Expected.ofNullable(null); | ||
assertTrue(expected1.isEmpty()); | ||
final Expected<Object> expected2 = Expected.ofNullable(Collections.emptyList()); | ||
assertTrue(expected2.isEmpty()); | ||
final Expected<Object> expected3 = Expected.ofNullable(new Object()); | ||
assertFalse(expected3.isEmpty()); | ||
final Expected<Object> expected4 = Expected.ofNullable(""); | ||
assertTrue(expected4.isEmpty()); | ||
|
||
final Expected<Object> expected5 = Expected.ofNullable(new Object[0]); | ||
assertTrue(expected5.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void ifEmpty() throws Exception { | ||
|
||
final Expected<Object> expected = Expected.ofNullable(new Object()); | ||
expected.ifEmpty(Assert::fail); | ||
final Expected<Object> expected2 = Expected.ofNullable(Collections.singleton(new Object())); | ||
expected2.ifEmpty(Assert::fail); | ||
|
||
final Expected<Object> expected3 = Expected.ofNullable("abc"); | ||
expected3.ifEmpty(Assert::fail); | ||
|
||
} | ||
|
||
@Test | ||
public void ifNotEmpty() throws Exception { | ||
final Expected<Object> expected = Expected.ofNullable(null); | ||
expected.ifNotEmpty(Assert::fail); | ||
|
||
final Expected<Object> expected2 = Expected.ofNullable(Collections.emptyList()); | ||
expected2.ifNotEmpty(Assert::fail); | ||
|
||
} | ||
|
||
@Test | ||
public void ifAbsent() throws Exception { | ||
|
||
|
||
final Expected<Object> expected = Expected.ofNullable(new Object()); | ||
|
||
expected.ifAbsent(Assert::fail); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters