View Javadoc
1   package io.atlassian.fugue;
2   
3   import org.junit.Test;
4   
5   import static org.hamcrest.MatcherAssert.assertThat;
6   import static org.hamcrest.Matchers.is;
7   
8   public class OptionFunctionsTest {
9   
10    private Integer NULL = null;
11  
12    @Test public void nullSafeIdentityOnNull() {
13      assertThat(Options.nullSafe(i -> i).apply(NULL).isEmpty(), is(true));
14    }
15  
16    @Test public void nullSafeIdentityOnValue() {
17      assertThat(Options.nullSafe(i -> i).apply(1).isEmpty(), is(false));
18    }
19  
20    @Test public void toOptionWithNull() {
21      assertThat(Options.toOption().apply(NULL).isEmpty(), is(true));
22    }
23  
24    @Test public void toOptionWithValue() {
25      assertThat(Options.toOption().apply(1).isEmpty(), is(false));
26    }
27  }