|
| 1 | +package com.softdev.system.generator.util; |
| 2 | + |
| 3 | +import org.junit.Test; |
| 4 | + |
| 5 | +import static junit.framework.TestCase.assertEquals; |
| 6 | +import static junit.framework.TestCase.assertTrue; |
| 7 | +import static org.junit.Assert.assertFalse; |
| 8 | + |
| 9 | +public class StringUtilsTest { |
| 10 | + |
| 11 | + @Test |
| 12 | + public void toLowerCamel() { |
| 13 | + System.out.println(StringUtils.toLowerCamel("hello_world")); |
| 14 | + System.out.println(StringUtils.toLowerCamel("HELLO_WO-RLD-IK")); |
| 15 | + System.out.println(StringUtils.toLowerCamel("HELLO_WORLD-IKabc")); |
| 16 | + System.out.println(StringUtils.toLowerCamel("HELLO-WORLD-IKabc")); |
| 17 | + System.out.println(StringUtils.toLowerCamel("HELLO-123WORLD-IKabc")); |
| 18 | + System.out.println(StringUtils.toLowerCamel("helloWorldOKla")); |
| 19 | + assertEquals("helloWorldChina", StringUtils.toLowerCamel("hello_-_world-cHina")); |
| 20 | + } |
| 21 | + |
| 22 | + @Test |
| 23 | + public void upperCaseFirstShouldReturnStringWithFirstLetterCapitalized() { |
| 24 | + assertEquals("Hello", StringUtils.upperCaseFirst("hello")); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void upperCaseFirstShouldReturnEmptyStringWhenInputIsEmpty() { |
| 29 | + assertEquals("", StringUtils.upperCaseFirst("")); |
| 30 | + } |
| 31 | + |
| 32 | + @Test |
| 33 | + public void lowerCaseFirstShouldReturnStringWithFirstLetterLowercased() { |
| 34 | + assertEquals("hello", StringUtils.lowerCaseFirst("Hello")); |
| 35 | + } |
| 36 | + |
| 37 | + @Test |
| 38 | + public void lowerCaseFirstShouldReturnEmptyStringWhenInputIsEmpty() { |
| 39 | + assertEquals("", StringUtils.lowerCaseFirst("")); |
| 40 | + } |
| 41 | + |
| 42 | + @Test |
| 43 | + public void underlineToCamelCaseShouldReturnCamelCaseString() { |
| 44 | + assertEquals("helloWorld", StringUtils.underlineToCamelCase("hello_world")); |
| 45 | + } |
| 46 | + |
| 47 | + @Test |
| 48 | + public void underlineToCamelCaseShouldReturnEmptyStringWhenInputIsEmpty() { |
| 49 | + assertEquals("", StringUtils.underlineToCamelCase("")); |
| 50 | + } |
| 51 | + |
| 52 | + @Test |
| 53 | + public void toUnderlineShouldReturnUnderlinedString() { |
| 54 | + assertEquals("hello_world", StringUtils.toUnderline("helloWorld", false)); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + public void toUnderlineShouldReturnEmptyStringWhenInputIsEmpty() { |
| 59 | + assertEquals("", StringUtils.toUnderline("", false)); |
| 60 | + } |
| 61 | + |
| 62 | + @Test |
| 63 | + public void toCamelShouldReturnCamelCaseString() { |
| 64 | + assertEquals("helloWorld", StringUtils.toLowerCamel("hello_world")); |
| 65 | + } |
| 66 | + |
| 67 | + @Test |
| 68 | + public void toCamelShouldReturnEmptyStringWhenInputIsEmpty() { |
| 69 | + assertEquals("", StringUtils.toLowerCamel("")); |
| 70 | + } |
| 71 | + |
| 72 | + @Test |
| 73 | + public void isNotNullShouldReturnTrueWhenStringIsNotEmpty() { |
| 74 | + assertTrue(StringUtils.isNotNull("hello")); |
| 75 | + } |
| 76 | + |
| 77 | + @Test |
| 78 | + public void isNotNullShouldReturnFalseWhenStringIsEmpty() { |
| 79 | + assertFalse(StringUtils.isNotNull("")); |
| 80 | + } |
| 81 | +} |
0 commit comments