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;
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.Property;
26  import de.smartics.properties.api.config.domain.PropertyLocation;
27  import de.smartics.testdoc.annotations.Uut;
28  import de.smartics.testdoc.categories.type.Construction;
29  import de.smartics.util.lang.BlankArgumentException;
30  
31  /**
32   * Tests {@link Property}
33   */
34  @Uut(type = Property.class)
35  @Category(Construction.class)
36  public class PropertyConstructionTest
37  {
38    // ********************************* Fields *********************************
39  
40    // --- constants ------------------------------------------------------------
41  
42    private static final PropertyLocation SOURCE_ID =
43        new PropertyLocation("test");
44  
45    private static final String NAME = "name";
46  
47    private static final String VALUE = "value";
48  
49    // --- members --------------------------------------------------------------
50  
51    // ****************************** Inner Classes *****************************
52  
53    // ********************************* Methods ********************************
54  
55    // --- prepare --------------------------------------------------------------
56  
57    // --- helper ---------------------------------------------------------------
58  
59    // --- tests ----------------------------------------------------------------
60  
61    @Test
62    public void allowsValueOfNull()
63    {
64      new Property(SOURCE_ID, NAME, null);
65    }
66  
67    @Test(expected = BlankArgumentException.class)
68    public void requiresNameToBeNotNull()
69    {
70      new Property(SOURCE_ID, null, VALUE);
71    }
72  
73    @Test
74    public void providesAccessToPropertyName()
75    {
76      final Property uut = new Property(SOURCE_ID, NAME, VALUE);
77      assertThat(uut.getName(), is(equalTo(NAME)));
78    }
79  
80    @Test
81    public void providesAccessToPropertyValue()
82    {
83      final Property uut = new Property(SOURCE_ID, NAME, VALUE);
84      assertThat(uut.getValue(), is(equalTo(VALUE)));
85    }
86  }