View Javadoc

1   /*
2    * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package test.de.smartics.properties.api.config.domain.key;
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 org.junit.Test;
23  import org.junit.experimental.categories.Category;
24  
25  import de.smartics.properties.api.config.domain.key.ApplicationId;
26  import de.smartics.properties.api.config.domain.key.ConfigurationKey;
27  import de.smartics.properties.api.config.domain.key.EnvironmentId;
28  import de.smartics.testdoc.annotations.Uut;
29  import de.smartics.testdoc.categories.type.Construction;
30  import de.smartics.util.lang.NullArgumentException;
31  
32  /**
33   * Tests {@link ConfigurationKey}.
34   */
35  @Uut(type = ConfigurationKey.class)
36  @Category(Construction.class)
37  public class ConfigurationKeyConstructionTest
38  {
39  
40    public static final EnvironmentId ENV_ID = new EnvironmentId("test2");
41  
42    public static final ApplicationId APP_ID = new ApplicationId("group",
43        "artifactId", "1.0");
44  
45    // ********************************* Fields *********************************
46  
47    // --- constants ------------------------------------------------------------
48  
49    // --- members --------------------------------------------------------------
50  
51    // ****************************** Inner Classes *****************************
52  
53    // ********************************* Methods ********************************
54  
55    // --- prepare --------------------------------------------------------------
56  
57    // --- helper ---------------------------------------------------------------
58  
59    @Test
60    public void providesAccessToEnvironmentId()
61    {
62      final ConfigurationKey uut = new ConfigurationKey(ENV_ID, APP_ID);
63      assertThat(uut.getEnvironmentId(), is(equalTo(ENV_ID)));
64    }
65  
66    @Test
67    public void providesAccessToApplicationId()
68    {
69      final ConfigurationKey uut = new ConfigurationKey(ENV_ID, APP_ID);
70      assertThat(uut.getApplicationId(), is(equalTo(APP_ID)));
71    }
72  
73    @Test(expected = NullArgumentException.class)
74    public void requiresEnvironmentIdOnConstruction()
75    {
76      new ConfigurationKey(null, APP_ID);
77    }
78  
79    @Test(expected = NullArgumentException.class)
80    public void requiresApplicationIdOnConstruction()
81    {
82      new ConfigurationKey(ENV_ID, null);
83    }
84  
85    // --- tests ----------------------------------------------------------------
86  
87  }