1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.properties.api.config.domain;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.hasItem;
20 import static org.hamcrest.Matchers.hasItems;
21 import static org.hamcrest.Matchers.is;
22
23 import java.util.List;
24
25 import org.junit.Before;
26 import org.junit.Test;
27
28 import de.smartics.testdoc.annotations.Uut;
29
30
31
32
33 public class DependencyParserTest
34 {
35
36
37
38
39
40
41 @Uut
42 private DependenciesParser uut;
43
44
45
46
47
48
49
50 @Before
51 public void setUp()
52 {
53 uut = new DependenciesParser();
54 }
55
56
57
58
59
60 @Test
61 public void theNullValueReturnsTheEmptyList()
62 {
63 final String value = null;
64 final List<String> dependencies = uut.getDependencies(value);
65 assertThat(dependencies.isEmpty(), is(true));
66 }
67
68 @Test
69 public void aValueWithoutPlaceholdersReturnsTheEmptyList()
70 {
71 final String value = "noPlaceholderInside";
72 final List<String> dependencies = uut.getDependencies(value);
73 assertThat(dependencies.isEmpty(), is(true));
74 }
75
76 @Test
77 public void aPlaceholderIsFound()
78 {
79 final String value = "${thePlaceholder}";
80 final List<String> dependencies = uut.getDependencies(value);
81 assertThat(dependencies, hasItem("thePlaceholder"));
82 }
83
84 @Test
85 public void moreThanOnePlaceholderIsFound()
86 {
87 final String value = "${one} ${two} three";
88 final List<String> dependencies = uut.getDependencies(value);
89 assertThat(dependencies, hasItems("one", "two"));
90 }
91 }