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.ArrayList;
23 import java.util.Arrays;
24 import java.util.List;
25
26 import org.junit.Test;
27
28 import de.smartics.properties.api.config.domain.key.ApplicationId;
29 import de.smartics.properties.api.config.domain.key.ConfigurationKey;
30 import de.smartics.properties.api.config.domain.key.EnvironmentId;
31 import de.smartics.properties.impl.config.domain.key.envapp.EnvAppConfigurationKey;
32 import de.smartics.properties.impl.config.domain.key.envapp.EnvAppDefinitionKeyHelper;
33 import de.smartics.properties.impl.config.domain.key.envapp.EnvAppPropertiesDefinitionContext;
34 import de.smartics.properties.spi.config.domain.key.PathMatcher;
35 import de.smartics.properties.spi.config.domain.key.PropertiesResourceMatcher;
36 import de.smartics.properties.spi.config.domain.key.PropertyResourceMatchers;
37 import de.smartics.testdoc.annotations.Uut;
38
39
40
41
42 @Uut(type = EnvAppDefinitionKeyHelper.class)
43 @SuppressWarnings("rawtypes")
44 public class DefinitionKeyHelperRegisteredFilesTest
45 {
46
47
48
49
50 private static final ConfigurationKey DEFAULT_KEY =
51 new EnvAppConfigurationKey(new EnvironmentId("xxx-env", "xxx-node"),
52 new ApplicationId("xxx-group", "xxx-artifact", "23.42"));
53
54 private static final String DEFAULT_GROUP = "de.smartics.test.one";
55
56
57
58 private static final EnvironmentId ENV_PRODUCTION = new EnvironmentId(
59 "production", "node");
60
61
62
63 private static final ApplicationId APP_ANY_IN_GROUP = new ApplicationId(
64 DEFAULT_GROUP, null, null);
65
66
67
68
69
70
71
72
73
74
75
76
77
78 @Test
79 public void identifiesRegisteredFiles()
80 {
81 final String path =
82 ENV_PRODUCTION.toString() + '/' + APP_ANY_IN_GROUP.toPath();
83 final List<PropertiesResourceMatcher> matchers =
84 new ArrayList<PropertiesResourceMatcher>();
85 matchers.add(PathMatcher.forMatchers(DEFAULT_KEY,
86 Arrays.asList(new PathMatcher.Matcher(path))));
87 final PropertyResourceMatchers files =
88 new PropertyResourceMatchers(null, matchers);
89
90 final EnvAppPropertiesDefinitionContext context =
91 new EnvAppPropertiesDefinitionContext(null, null, null, files);
92
93 final EnvAppDefinitionKeyHelper uut =
94 new EnvAppDefinitionKeyHelper(context);
95 final ConfigurationKey key = uut.parse(path);
96
97 assertThat(key, is(equalTo(DEFAULT_KEY)));
98 }
99 }