1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package test.de.smartics.properties.spi.config.definition;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.is;
20
21 import java.util.HashSet;
22 import java.util.Set;
23
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.junit.experimental.categories.Category;
27
28 import de.smartics.properties.impl.config.domain.key.envapp.EnvAppPropertiesDefinitionContext;
29 import de.smartics.testdoc.annotations.Uut;
30 import de.smartics.testdoc.categories.type.Coverage;
31
32
33
34
35 public class PropertiesDefinitionContextTest
36 {
37
38
39
40
41 private static final String REGISTERED_GROUP = "registered";
42
43
44
45 @Uut(method = "isRegisteredGroupTld(String)")
46 private EnvAppPropertiesDefinitionContext uut;
47
48
49
50
51
52
53
54 @Before
55 public void setUp()
56 {
57 final Set<String> tlds = new HashSet<String>();
58 tlds.add(REGISTERED_GROUP);
59 uut = new EnvAppPropertiesDefinitionContext(null, null, tlds);
60 }
61
62
63
64
65
66 @Test
67 public void anyTwoLetterTldIdentifiesAGroup()
68 {
69 final String tld = "de";
70 final boolean result = uut.isRegisteredGroupTld(tld);
71
72 assertThat(result, is(true));
73 }
74
75 @Test
76 public void anyTwoCharsDoNotIdentifyAGroup()
77 {
78 final String tld = "a1";
79 final boolean result = uut.isRegisteredGroupTld(tld);
80
81 assertThat(result, is(false));
82 }
83
84 @Test
85 @Category(Coverage.class)
86 public void anyTwoCharsDoNotIdentifyAGroupDigitFirst()
87 {
88 final String tld = "1a";
89 final boolean result = uut.isRegisteredGroupTld(tld);
90
91 assertThat(result, is(false));
92 }
93
94 @Test
95 @Category(Coverage.class)
96 public void anyThreeLettersDoNotIdentifyAGroup()
97 {
98 final String tld = "any";
99 final boolean result = uut.isRegisteredGroupTld(tld);
100
101 assertThat(result, is(false));
102 }
103
104 @Test
105 public void aDefaultTldIdentifiesAGroup()
106 {
107 final String tld = "com";
108 final boolean result = uut.isRegisteredGroupTld(tld);
109
110 assertThat(result, is(true));
111 }
112
113 @Test
114 public void nullIsNotAGroup()
115 {
116 final String tld = null;
117 final boolean result = uut.isRegisteredGroupTld(tld);
118
119 assertThat(result, is(false));
120 }
121 }