1 package com.lexicalscope.jewel.cli.examples;
2
3 import static org.junit.Assert.assertTrue;
4
5 import org.junit.Test;
6
7 import com.lexicalscope.jewel.cli.CliFactory;
8 import com.lexicalscope.jewel.cli.Option;
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 public class TestBooleanOptionExample {
27 interface BooleanOptionExample
28 {
29 @Option boolean getOptionOne();
30
31 @Option Boolean getOptionTwo();
32 }
33
34 @Test public void specifiedBooleanOptionsReturnTrue() {
35 final BooleanOptionExample cli =
36 CliFactory.parseArguments(BooleanOptionExample.class, "--optionOne", "--optionTwo");
37
38 assertTrue("option one is present", cli.getOptionOne());
39 assertTrue("option two is present", cli.getOptionTwo());
40 }
41
42 @Test public void omittedBooleanOptionsReturnFalse() {
43 final BooleanOptionExample cli =
44 CliFactory.parseArguments(BooleanOptionExample.class);
45
46 assertTrue("option one is not present", !cli.getOptionOne());
47 assertTrue("option two is not present", !cli.getOptionTwo());
48 }
49 }