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 @SuppressWarnings("unchecked")
83 public void providesAStringRepresentation()
84 {
85 uut.add(property);
86 final String string = uut.toString();
87 assertThat(string, allOf(containsString("name"), containsString("value")));
88 }
89
90 @Test
91 @Category(Coverage.class)
92 public void providesAStringRepresentationForEmptyProperties()
93 {
94 final String string = uut.toString();
95 assertThat(string, is(equalTo(StringUtils.EMPTY)));
96 }
97 }