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 help.de.smartics.properties.core.PropertiesContextBuilder.DEFAULT_HOME_PAGE_URL;
19 import static help.de.smartics.properties.core.PropertiesContextBuilder.DEFAULT_PROPERTIES_REPORT_URL;
20 import static org.hamcrest.MatcherAssert.assertThat;
21 import static org.hamcrest.Matchers.is;
22 import static org.hamcrest.Matchers.nullValue;
23
24 import org.junit.Test;
25
26 import de.smartics.properties.api.core.domain.PropertiesContext;
27 import de.smartics.testdoc.annotations.Uut;
28
29
30
31
32 @Uut(type = PropertiesContext.class)
33 public class PropertiesContextCreationTest
34 {
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 @Test(expected = NullPointerException.class)
52 public void requiresHomePageUrl()
53 {
54 new PropertiesContext.Builder().withHomePageUrl(null);
55 }
56
57 @Test(expected = NullPointerException.class)
58 public void requiresPropertiesReportUrl()
59 {
60 new PropertiesContext.Builder().withPropertiesReportUrl(null);
61 }
62
63 @Test
64 public void providesAccessToItsInformation()
65 {
66 final PropertiesContext.Builder builder =
67 new PropertiesContext.Builder().withHomePageUrl(DEFAULT_HOME_PAGE_URL)
68 .withPropertiesReportUrl(DEFAULT_PROPERTIES_REPORT_URL);
69 final PropertiesContext uut = builder.build();
70
71 assertThat(uut.getHomePageUrl(), is(DEFAULT_HOME_PAGE_URL));
72 assertThat(uut.getPropertiesReportUrl(), is(DEFAULT_PROPERTIES_REPORT_URL));
73 assertThat(uut.getPropertiesReportIndexUrl(),
74 is(DEFAULT_PROPERTIES_REPORT_URL + "/smartics-properties-report.html"));
75 }
76
77 @Test
78 public void returnsNullIfInformationIsMissing()
79 {
80 final PropertiesContext.Builder builder = new PropertiesContext.Builder();
81 final PropertiesContext uut = builder.build();
82
83 assertThat(uut.getHomePageUrl(), is(nullValue()));
84 assertThat(uut.getPropertiesReportUrl(), is(nullValue()));
85 assertThat(uut.getPropertiesReportIndexUrl(), is(nullValue()));
86 }
87
88 @Test
89 public void removesATrailingSlashFromReportUrl()
90 {
91 final PropertiesContext.Builder builder =
92 new PropertiesContext.Builder().withHomePageUrl(DEFAULT_HOME_PAGE_URL)
93 .withPropertiesReportUrl(DEFAULT_PROPERTIES_REPORT_URL + '/');
94 final PropertiesContext uut = builder.build();
95
96 assertThat(uut.getPropertiesReportUrl(), is(DEFAULT_PROPERTIES_REPORT_URL));
97 }
98 }