1   package com.lexicalscope.jewel.cli.examples;
2   
3   import static org.hamcrest.MatcherAssert.assertThat;
4   import static org.hamcrest.Matchers.contains;
5   import static com.lexicalscope.jewel.cli.CliFactory.parseArgumentsUsingInstance;
6   
7   import org.hamcrest.Matchers;
8   import org.junit.Rule;
9   import org.junit.Test;
10  import org.junit.rules.ExpectedException;
11  
12  import com.lexicalscope.jewel.cli.ArgumentValidationException;
13  
14  public class TestClassOptionalUnparsedOption {
15      @Rule public final ExpectedException exception = ExpectedException.none();
16  
17      @Test public void testOptionalUnparsedOptionPresent() throws ArgumentValidationException {
18          final ClassOptionalUnparsedOption result =
19                  parseArgumentsUsingInstance(new ClassOptionalUnparsedOption(), new String[] {
20                          "--myOptionalUnparsedOption",
21                          "3",
22                          "7" });
23  
24          assertThat(result.getMyOptionalUnparsedOption(), contains(3, 7));
25      }
26  
27      @Test public void testOptionalUnparsedOptionMissing() throws ArgumentValidationException {
28          final ClassOptionalUnparsedOption result =
29                  parseArgumentsUsingInstance(new ClassOptionalUnparsedOption(), new String[] {});
30  
31          assertThat(result.getMyOptionalUnparsedOption(), Matchers.<Integer>empty());
32      }
33  }