1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package test.de.smartics.properties.spi.config.definition;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.equalTo;
20 import static org.hamcrest.Matchers.is;
21
22 import java.util.HashMap;
23 import java.util.Map;
24
25 import org.junit.Test;
26
27 import de.smartics.properties.api.config.domain.key.ApplicationId;
28 import de.smartics.properties.api.config.domain.key.ConfigurationKey;
29 import de.smartics.properties.api.config.domain.key.EnvironmentId;
30 import de.smartics.properties.spi.config.definition.DefinitionKeyHelper;
31 import de.smartics.properties.spi.config.definition.PropertiesDefinitionContext;
32 import de.smartics.testdoc.annotations.Uut;
33
34
35
36
37 @Uut(type = DefinitionKeyHelper.class)
38 public class DefinitionKeyHelperRegisteredFilesTest
39 {
40
41
42
43
44 private static final ConfigurationKey DEFAULT_KEY = new ConfigurationKey(
45 new EnvironmentId("xxx-env", "xxx-node"), new ApplicationId("xxx-group",
46 "xxx-artifact", "23.42"));
47
48 private static final String DEFAULT_GROUP = "de.smartics.test.one";
49
50
51
52 private static final EnvironmentId ENV_PRODUCTION = new EnvironmentId(
53 "production", "node");
54
55
56
57 private static final ApplicationId APP_ANY_IN_GROUP = new ApplicationId(
58 DEFAULT_GROUP, null, null);
59
60
61
62
63
64
65
66
67
68
69
70
71
72 @Test
73 public void identifiesRegisteredFiles()
74 {
75 final String path =
76 ENV_PRODUCTION.toString() + '/' + APP_ANY_IN_GROUP.toPath();
77 final Map<String, ConfigurationKey> files =
78 new HashMap<String, ConfigurationKey>();
79 files.put(path, DEFAULT_KEY);
80
81 final PropertiesDefinitionContext context =
82 new PropertiesDefinitionContext(null, null, null, files);
83
84 final DefinitionKeyHelper uut = new DefinitionKeyHelper(context);
85 final ConfigurationKey key = uut.parse(path);
86
87 assertThat(key, is(equalTo(DEFAULT_KEY)));
88 }
89 }