1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package test.de.smartics.ci.config.load;
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.is;
22 import static org.hamcrest.Matchers.sameInstance;
23
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.junit.experimental.categories.Category;
27
28 import de.smartics.ci.config.load.LoaderPlan;
29 import de.smartics.ci.config.maven.MavenConfig;
30 import de.smartics.ci.config.test.MavenConfigBuilder;
31 import de.smartics.testdoc.annotations.Uut;
32 import de.smartics.testdoc.categories.type.Construction;
33 import de.smartics.util.lang.BlankArgumentException;
34 import de.smartics.util.lang.NullArgumentException;
35
36
37
38
39 @Uut(type = LoaderPlan.class)
40 @Category(Construction.class)
41 public class LoaderPlanConstructionTest
42 {
43
44
45
46
47
48
49 private MavenConfig mavenConfig;
50
51
52
53
54
55
56
57 @Before
58 public void setUp()
59 {
60 mavenConfig = MavenConfigBuilder.a().build();
61 }
62
63
64
65
66
67 @Test(expected = BlankArgumentException.class)
68 public void allowsNoBlankIdInConstruction()
69 {
70 new LoaderPlan("", mavenConfig);
71 }
72
73 @Test(expected = NullArgumentException.class)
74 public void requiresAMavenConfig()
75 {
76 new LoaderPlan("valid", null);
77 }
78
79 @Test
80 public void providesValidToStringWithoutElements()
81 {
82 final String id = "id";
83 final LoaderPlan uut = new LoaderPlan(id, mavenConfig);
84
85 final String string = uut.toString();
86 assertThat(string, containsString(id));
87 assertThat(uut.getMavenConfig(), is(sameInstance(mavenConfig)));
88 }
89
90 @Test
91 @SuppressWarnings("unchecked")
92 public void providesValidToStringWithElements()
93 {
94 final String id = "id";
95 final String configurationName = "valid";
96 final LoaderPlan uut = new LoaderPlan(id, mavenConfig);
97 uut.addConfigurationName(configurationName);
98
99 final String string = uut.toString();
100 assertThat(string,
101 allOf(containsString(id), containsString(configurationName)));
102 }
103 }