1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.properties.impl.config.domain.key.rtaware;
17
18 import static org.hamcrest.MatcherAssert.assertThat;
19 import static org.hamcrest.Matchers.is;
20 import static org.hamcrest.Matchers.notNullValue;
21
22 import org.junit.Before;
23 import org.junit.Test;
24
25 import de.smartics.properties.api.config.domain.key.ConfigurationKey;
26 import de.smartics.testdoc.annotations.Uut;
27
28
29
30
31 public class TenantUserConfigurationKeyFactoryCreateKeyFromStringTest
32 {
33
34 @Uut(method = "createKeyFromString(String)")
35 private TenantUserConfigurationKeyFactory uut;
36
37 @Before
38 public void setUp()
39 {
40 uut = new TenantUserConfigurationKeyFactory();
41 }
42
43 @Test(expected = IllegalArgumentException.class)
44 public void rejectsNullKeyString()
45 {
46 uut.createKeyFromString(null);
47 }
48
49 @Test(expected = IllegalArgumentException.class)
50 public void rejectsEmptyKeyString()
51 {
52 uut.createKeyFromString("");
53 }
54
55 @Test(expected = IllegalArgumentException.class)
56 public void rejectsTooShortKeyString()
57 {
58 uut.createKeyFromString("user/tenant");
59 }
60
61 @Test
62 public void returnsValidKeyForShortestPossibleDefaultKey()
63 {
64 final ConfigurationKey<?> key = uut.createKeyFromString("///");
65 assertThat(key, notNullValue());
66 assertThat(key.toString(), is("//:/::"));
67 }
68
69 @Test
70 public void returnsValidKeyForFullKey()
71 {
72 final ConfigurationKey<?> key =
73 uut.createKeyFromString("user/tenant/environment:node/groupid:artifactid:version");
74 assertThat(key, notNullValue());
75 assertThat(key.toString(),
76 is("user/tenant/environment:node/groupid:artifactid:version"));
77 }
78 }