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.allOf;
20 import static org.hamcrest.Matchers.hasItem;
21 import static org.hamcrest.Matchers.is;
22 import static org.hamcrest.Matchers.not;
23 import static org.hamcrest.Matchers.nullValue;
24
25 import java.io.Serializable;
26
27 import org.junit.Test;
28 import org.junit.experimental.categories.Category;
29
30 import de.smartics.properties.api.core.domain.PropertyValueComment;
31 import de.smartics.testdoc.annotations.Uut;
32 import de.smartics.testdoc.categories.type.Coverage;
33
34
35
36
37 @Uut(type = PropertyValueComment.class)
38 public class PropertyValueCommentTest
39 {
40
41
42
43
44 private static final String DEFAULT_SUMMARY = "Test comment";
45
46
47
48
49
50
51
52
53
54
55
56
57
58 @Test
59 public void providesASummaryComment()
60 {
61 final PropertyValueComment uut = new PropertyValueComment(DEFAULT_SUMMARY);
62
63 assertThat(uut.getSummary(), is(DEFAULT_SUMMARY));
64 }
65
66 @Test
67 public void allowsToAddValueCommentsComment()
68 {
69 final PropertyValueComment uut = new PropertyValueComment(DEFAULT_SUMMARY);
70 final Serializable value1 = "Value 1";
71 final String comment1 = "Value 1 Comment";
72 final Serializable value2 = 42;
73 final String comment2 = "Value 2 Comment";
74
75 uut.addValueComment(value1, comment1);
76 uut.addValueComment(value2, comment2);
77
78 assertThat(uut.getValueComment(value1), is(comment1));
79 assertThat(uut.getValueComment(value2), is(comment2));
80 assertThat(uut.getValues(), allOf(hasItem(value1), hasItem(value2)));
81 }
82
83 @Test
84 @Category(Coverage.class)
85 public void toStringOnEmptyInstanceDoesNotFail()
86 {
87 final PropertyValueComment uut = new PropertyValueComment(null);
88
89 assertThat(uut.toString(), is(not(nullValue())));
90 }
91
92 @Test
93 @Category(Coverage.class)
94 public void toStringOnFullInstanceDoesNotFail()
95 {
96 final PropertyValueComment uut = new PropertyValueComment(DEFAULT_SUMMARY);
97 final Serializable value1 = "Value 1";
98 final String comment1 = "Value 1 Comment";
99 final Serializable value2 = 42;
100 final String comment2 = "Value 2 Comment";
101
102 uut.addValueComment(value1, comment1);
103 uut.addValueComment(value2, comment2);
104
105 assertThat(uut.toString(), is(not(nullValue())));
106 }
107 }