From 86c108fbb769adef9ead48dda22dc6be15bf0aea Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Mon, 11 Sep 2023 15:56:40 -0400 Subject: [PATCH] About the test, we update String Vowel Test --- .../codebank/tests/EmptyQuickTest.java | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/EmptyQuickTest.java b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/EmptyQuickTest.java index f2cade6972..616318f28e 100644 --- a/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/EmptyQuickTest.java +++ b/toolkits/codebank/src/test/java/com/ossez/toolkits/codebank/tests/EmptyQuickTest.java @@ -1,19 +1,28 @@ package com.ossez.toolkits.codebank.tests; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import java.util.List; + /** - * Empty Test Case + * String Test Case * * @author YuCheng */ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @Slf4j public class EmptyQuickTest { + private static final String VOWEL_A = "a"; + private static final String VOWEL_E = "e"; + private static final String VOWEL_I = "i"; + private static final String VOWEL_O = "o"; + private static final String VOWEL_U = "u"; + @BeforeEach protected void setUp() throws Exception { @@ -26,8 +35,37 @@ public class EmptyQuickTest { @Test public void testMain() { - log.info("TEST MAIN - BEGIN"); + String strTransform = "AI is driving the world crazy"; + List test = List.of(StringUtils.split(strTransform, " ")); + + for (int i = 0; i < test.size(); i++) { + if (hasVowels(test.get(i))) { + log.debug("Vowel STR - {}", test.get(i)); + } + + } + } + + private Boolean hasVowels(String str) { + + str = StringUtils.trimToEmpty(str); + str = StringUtils.lowerCase(str); + str = StringUtils.remove(str, " "); + + if (StringUtils.contains(str, VOWEL_A)) { + return Boolean.TRUE; + } else if (StringUtils.contains(str, VOWEL_E)) { + return Boolean.TRUE; + } else if (StringUtils.contains(str, VOWEL_I)) { + return Boolean.TRUE; + } else if (StringUtils.contains(str, VOWEL_O)) { + return Boolean.TRUE; + } else if (StringUtils.contains(str, VOWEL_U)) { + return Boolean.TRUE; + } + + return Boolean.FALSE; } }