1 package com.lexicalscope.jewel.cli.examples;
2
3 import static com.lexicalscope.jewel.cli.CliFactory.*;
4 import static org.hamcrest.MatcherAssert.assertThat;
5 import static org.hamcrest.Matchers.equalTo;
6
7 import org.junit.Test;
8
9 import com.lexicalscope.jewel.cli.Option;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 public class TestOptionsWithoutGetPrefix {
28 public interface InterfaceWithNoGetPrefix {
29 @Option String name();
30 }
31
32 public static class ClassWithNoGetPrefix {
33 private String name;
34
35 public String name()
36 {
37 return name;
38 }
39
40 @Option public void name(final String name)
41 {
42 this.name = name;
43 }
44 }
45
46 @Test public void interfaceOptionsWithoutGetPrefixWork()
47 {
48 assertThat(parseArguments(InterfaceWithNoGetPrefix.class, "--name", "value").name(), equalTo("value"));
49 }
50
51 @Test public void classOptionsWithoutGetPrefixWork()
52 {
53 assertThat(parseArgumentsUsingInstance(new ClassWithNoGetPrefix(), "--name", "value").name(), equalTo("value"));
54 }
55 }