001/* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014 015package org.basepom.mojo.propertyhelper; 016 017import static org.junit.jupiter.api.Assertions.assertEquals; 018 019import java.util.function.Function; 020 021import org.junit.jupiter.api.Test; 022 023public class TestTransformerRegistry { 024 025 @Test 026 public void testLowercase() { 027 final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("lowercase"); 028 029 assertEquals(" hello, world! ", transformer.apply(" Hello, World! ")); 030 } 031 032 @Test 033 public void testUppercase() { 034 final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("uppercase"); 035 036 assertEquals(" HELLO, WORLD! ", transformer.apply(" Hello, World! ")); 037 } 038 039 @Test 040 public void testRemoveWhitespace() { 041 final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("remove_whitespace"); 042 043 assertEquals("Hello,World!", transformer.apply(" Hello, World! ")); 044 } 045 046 @Test 047 public void testUnderscoreForWhitespace() { 048 final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("underscore_for_whitespace"); 049 050 assertEquals("_Hello,_World!_", transformer.apply(" Hello, World! ")); 051 } 052 053 @Test 054 public void testDashForWhitespace() { 055 final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("dash_for_whitespace"); 056 057 assertEquals("-Hello,-World!-", transformer.apply(" Hello, World! ")); 058 } 059 060 @Test 061 public void testUseUnderscore() { 062 final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("use_underscore"); 063 064 assertEquals("_This:_Is_a_test!", transformer.apply(" This: Is_a-test!")); 065 } 066 067 @Test 068 public void testUseDash() { 069 final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("use_dash"); 070 071 assertEquals("-This:-Is-a-test!", transformer.apply(" This: Is_a-test!")); 072 } 073 074 @Test 075 public void testTrim() { 076 final Function<String, String> transformer = TransformerRegistry.INSTANCE.forName("trim"); 077 078 assertEquals("Hello, World!", transformer.apply(" Hello, World! ")); 079 } 080}