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.properties.impl.config.domain.key.envapp.EnvAppConfigurationKey;
29  import de.smartics.testdoc.annotations.Uut;
30  import de.smartics.testdoc.categories.type.Construction;
31  import de.smartics.util.lang.NullArgumentException;
32  
33  /**
34   * Tests {@link ConfigurationKey}.
35   */
36  @Uut(type = ConfigurationKey.class)
37  @Category(Construction.class)
38  public class ConfigurationKeyConstructionTest
39  {
40  
41    public static final EnvironmentId ENV_ID = new EnvironmentId("test2");
42  
43    public static final ApplicationId APP_ID = new ApplicationId("group",
44        "artifactId", "1.0");
45  
46    // ********************************* Fields *********************************
47  
48    // --- constants ------------------------------------------------------------
49  
50    // --- members --------------------------------------------------------------
51  
52    // ****************************** Inner Classes *****************************
53  
54    // ********************************* Methods ********************************
55  
56    // --- prepare --------------------------------------------------------------
57  
58    // --- helper ---------------------------------------------------------------
59  
60    @Test
61    public void providesAccessToEnvironmentId()
62    {
63      final EnvAppConfigurationKey uut = new EnvAppConfigurationKey(ENV_ID, APP_ID);
64      assertThat(uut.getEnvironmentId(), is(equalTo(ENV_ID)));
65    }
66  
67    @Test
68    public void providesAccessToApplicationId()
69    {
70      final EnvAppConfigurationKey uut = new EnvAppConfigurationKey(ENV_ID, APP_ID);
71      assertThat(uut.getApplicationId(), is(equalTo(APP_ID)));
72    }
73  
74    @Test(expected = NullArgumentException.class)
75    public void requiresEnvironmentIdOnConstruction()
76    {
77      new EnvAppConfigurationKey((EnvironmentId)null, APP_ID);
78    }
79  
80    @Test(expected = NullArgumentException.class)
81    public void requiresApplicationIdOnConstruction()
82    {
83      new EnvAppConfigurationKey(ENV_ID, null);
84    }
85  
86    // --- tests ----------------------------------------------------------------
87  
88  }