View Javadoc
1   /*
2    * Licensed under the Apache License, Version 2.0 (the "License");
3    * you may not use this file except in compliance with the License.
4    * You may obtain a copy of the License at
5    *
6    * http://www.apache.org/licenses/LICENSE-2.0
7    *
8    * Unless required by applicable law or agreed to in writing, software
9    * distributed under the License is distributed on an "AS IS" BASIS,
10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11   * See the License for the specific language governing permissions and
12   * limitations under the License.
13   */
14  
15  package org.basepom.mojo.propertyhelper;
16  
17  import static org.junit.jupiter.api.Assertions.assertEquals;
18  
19  import java.util.function.Function;
20  
21  import org.junit.jupiter.api.Test;
22  
23  public class TestTransformerRegistry {
24  
25      @Test
26      public void testLowercase() {
27          final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("lowercase");
28  
29          assertEquals(" hello, world! ", transformer.apply(" Hello, World! "));
30      }
31  
32      @Test
33      public void testUppercase() {
34          final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("uppercase");
35  
36          assertEquals(" HELLO, WORLD! ", transformer.apply(" Hello, World! "));
37      }
38  
39      @Test
40      public void testRemoveWhitespace() {
41          final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("remove_whitespace");
42  
43          assertEquals("Hello,World!", transformer.apply(" Hello, World! "));
44      }
45  
46      @Test
47      public void testUnderscoreForWhitespace() {
48          final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("underscore_for_whitespace");
49  
50          assertEquals("_Hello,_World!_", transformer.apply(" Hello, World! "));
51      }
52  
53      @Test
54      public void testDashForWhitespace() {
55          final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("dash_for_whitespace");
56  
57          assertEquals("-Hello,-World!-", transformer.apply(" Hello, World! "));
58      }
59  
60      @Test
61      public void testUseUnderscore() {
62          final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("use_underscore");
63  
64          assertEquals("_This:_Is_a_test!", transformer.apply(" This: Is_a-test!"));
65      }
66  
67      @Test
68      public void testUseDash() {
69          final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("use_dash");
70  
71          assertEquals("-This:-Is-a-test!", transformer.apply(" This: Is_a-test!"));
72      }
73  
74      @Test
75      public void testTrim() {
76          final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("trim");
77  
78          assertEquals("Hello, World!", transformer.apply(" Hello, World! "));
79      }
80  }