1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package test.de.smartics.properties.api.core.domain;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.equalTo;
20 import static org.hamcrest.Matchers.is;
21 import static org.hamcrest.Matchers.nullValue;
22
23 import org.junit.Test;
24 import org.junit.experimental.categories.Category;
25
26 import de.smartics.properties.api.core.domain.PropertyKey;
27 import de.smartics.testdoc.annotations.Uut;
28 import de.smartics.testdoc.categories.Technical;
29 import de.smartics.util.lang.BlankArgumentException;
30
31
32
33
34
35 @Uut(type = PropertyKey.class, method = "create(String)")
36 public class PropertyKeyCreateWithQualifiedNameTest
37 {
38 private static final String VALID_NAME = "test.key";
39
40 private static final String VALID_COMPONENT_NAME = "Test-Component";
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 @Test
59 public void allowsToCreateWithAQualifiedNameConveniently()
60 {
61 final PropertyKey uut =
62 PropertyKey.create(VALID_COMPONENT_NAME + '@' + VALID_NAME);
63
64 assertThat(uut.getPropertySet(), is(equalTo(VALID_COMPONENT_NAME)));
65 assertThat(uut.getName(), is(equalTo(VALID_NAME)));
66 }
67
68 @Test
69 @Category(Technical.class)
70 public void allowsSeparatorAtStart()
71 {
72 final String input = '@' + VALID_NAME;
73 final PropertyKey uut = PropertyKey.create(input);
74
75 assertThat(uut.getPropertySet(), is(nullValue()));
76 assertThat(uut.getName(), is(equalTo(input)));
77 }
78
79 @Test
80 @Category(Technical.class)
81 public void allowsSeparatorAtEnd()
82 {
83 final String input = VALID_NAME + '@';
84 final PropertyKey uut = PropertyKey.create(input);
85
86 assertThat(uut.getPropertySet(), is(nullValue()));
87 assertThat(uut.getName(), is(equalTo(input)));
88 }
89
90 @Test(expected = BlankArgumentException.class)
91 @Category(Technical.class)
92 public void rejectsBlankQualifiedNames()
93 {
94 PropertyKey.create("");
95 }
96 }