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.is;
20  import static org.hamcrest.Matchers.nullValue;
21  import static org.junit.Assert.assertSame;
22  
23  import org.junit.Test;
24  import org.junit.experimental.categories.Category;
25  
26  import de.smartics.properties.api.core.domain.PropertyExpression;
27  import de.smartics.testdoc.annotations.Uut;
28  import de.smartics.testdoc.categories.type.Construction;
29  
30  /**
31   * Tests {@link PropertyExpression}.
32   */
33  @Category(Construction.class)
34  @Uut(type = PropertyExpression.class)
35  public class PropertyExpressionTest
36  {
37    // ********************************* Fields *********************************
38  
39    // --- constants ------------------------------------------------------------
40  
41    // --- members --------------------------------------------------------------
42  
43    // ****************************** Inner Classes *****************************
44  
45    // ********************************* Methods ********************************
46  
47    // --- prepare --------------------------------------------------------------
48  
49    // --- helper ---------------------------------------------------------------
50  
51    // --- tests ----------------------------------------------------------------
52  
53    @Test
54    public void createsANonBlankExpression()
55    {
56      final String expression = "${test}";
57      final PropertyExpression uut = PropertyExpression.create(expression);
58  
59      assertThat(uut.hasExpression(), is(true));
60      assertThat(uut.getExpression(), is(expression));
61      assertThat(uut.toString(), is(expression));
62    }
63  
64    @Test
65    public void createsABlankExpression()
66    {
67      final String expression = " ";
68      final PropertyExpression uut = PropertyExpression.create(expression);
69  
70      assertThat(uut.hasExpression(), is(false));
71      assertThat(uut.getExpression(), is(nullValue()));
72      assertThat(uut.toString(), is(""));
73      assertSame(PropertyExpression.NO_EXPRESSION, uut);
74    }
75  }