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.core.domain;
17  
18  import static org.hamcrest.MatcherAssert.assertThat;
19  import static org.hamcrest.Matchers.equalTo;
20  import static org.hamcrest.Matchers.is;
21  import static org.hamcrest.Matchers.not;
22  import static org.hamcrest.Matchers.startsWith;
23  import help.de.smartics.properties.core.PropertyKeyBuilder;
24  
25  import org.junit.Before;
26  import org.junit.Test;
27  
28  import de.smartics.properties.api.core.domain.PropertyKey;
29  import de.smartics.testdoc.annotations.TestDocHint;
30  import de.smartics.testdoc.annotations.Uut;
31  
32  /**
33   * Tests {@link PropertyKey} basic features.
34   */
35  public class PropertyKeyTest
36  {
37    // ********************************* Fields *********************************
38  
39    // --- constants ------------------------------------------------------------
40  
41    // --- members --------------------------------------------------------------
42  
43    @Uut
44    private PropertyKey uut;
45  
46    // ****************************** Inner Classes *****************************
47  
48    // ********************************* Methods ********************************
49  
50    // --- prepare --------------------------------------------------------------
51  
52    @Before
53    public void setUp()
54    {
55      uut = PropertyKeyBuilder.defaultPropertyKey();
56    }
57  
58    // --- helper ---------------------------------------------------------------
59  
60    // --- tests ----------------------------------------------------------------
61  
62    @Test
63    public void providesAccessToThePropertySetName()
64    {
65      assertThat(uut.getPropertySet(),
66          is(equalTo(PropertyKeyBuilder.DEFAULT_PROPERTY_SET)));
67    }
68  
69    @Test
70    public void providesAccessToThePropertyName()
71    {
72      assertThat(uut.getName(), is(equalTo(PropertyKeyBuilder.DEFAULT_NAME)));
73    }
74  
75    @Test
76    public void theNameDoesNotContainTheNameOfThePropertySet()
77    {
78      assertThat(uut.getName(),
79          not(startsWith(PropertyKeyBuilder.DEFAULT_PROPERTY_SET)));
80    }
81  
82    @Test
83    @TestDocHint(sentence = "'toString' provides the fully qualified name,"
84                            + " which includes the name of the property set.")
85    public void toStringProvidesTheFullyQualifiedNameWhichIncludesTheNameOfThePropertySet()
86    {
87      assertThat(uut.toString(),
88          is(equalTo(PropertyKeyBuilder.DEFAULT_FULL_NAME)));
89    }
90  }