1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package test.de.smartics.properties.api.config;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.allOf;
20 import static org.hamcrest.Matchers.containsString;
21 import static org.hamcrest.Matchers.equalTo;
22 import static org.hamcrest.Matchers.hasItem;
23 import static org.hamcrest.Matchers.is;
24
25 import org.apache.commons.lang.StringUtils;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.junit.experimental.categories.Category;
29
30 import de.smartics.properties.api.config.domain.Property;
31 import de.smartics.properties.api.config.domain.PropertyLocation;
32 import de.smartics.properties.api.config.domain.UnknownProperties;
33 import de.smartics.testdoc.annotations.Uut;
34 import de.smartics.testdoc.categories.type.Coverage;
35
36
37
38
39 public class UnknownPropertiesTest
40 {
41
42
43
44
45 private static final PropertyLocation SOURCE_ID =
46 new PropertyLocation("test");
47
48
49
50 @Uut
51 private UnknownProperties uut;
52
53 private Property property;
54
55
56
57
58
59
60
61 @Before
62 public void setUp()
63 {
64 uut = new UnknownProperties();
65
66 property = new Property(SOURCE_ID, "name", "value");
67 }
68
69
70
71
72
73 @Test
74 public void allowsAddingProperties()
75 {
76 uut.add(property);
77 assertThat(uut.isEmpty(), is(false));
78 assertThat(uut.getProperties(), hasItem(property));
79 }
80
81 @Test
82 public void providesAStringRepresentation()
83 {
84 uut.add(property);
85 final String string = uut.toString();
86 assertThat(string, allOf(containsString("name"), containsString("value")));
87 }
88
89 @Test
90 @Category(Coverage.class)
91 public void providesAStringRepresentationForEmptyProperties()
92 {
93 final String string = uut.toString();
94 assertThat(string, is(equalTo(StringUtils.EMPTY)));
95 }
96 }