diff --git a/exercises/pangram/src/example/java/Pangrams.java b/exercises/pangram/src/example/java/PangramChecker.java similarity index 50% rename from exercises/pangram/src/example/java/Pangrams.java rename to exercises/pangram/src/example/java/PangramChecker.java index c186aea25..f0f296402 100644 --- a/exercises/pangram/src/example/java/Pangrams.java +++ b/exercises/pangram/src/example/java/PangramChecker.java @@ -1,11 +1,13 @@ import java.util.Arrays; import java.util.stream.Collectors; -public class Pangrams { +public class PangramChecker { private static final int alphaLength = 26; - public static boolean isPangram(String input){ - return Arrays.stream(input.replaceAll("[^a-zA-Z]","").toLowerCase().split("")) + public boolean isPangram(String input) { + return Arrays.stream(input.replaceAll("[^a-zA-Z]", "") + .toLowerCase() + .split("")) .collect(Collectors.toSet()) .size() == alphaLength; } diff --git a/exercises/pangram/src/main/java/.keep b/exercises/pangram/src/main/java/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/exercises/pangram/src/main/java/PangramChecker.java b/exercises/pangram/src/main/java/PangramChecker.java new file mode 100644 index 000000000..1b1651605 --- /dev/null +++ b/exercises/pangram/src/main/java/PangramChecker.java @@ -0,0 +1,6 @@ +public class PangramChecker { + + public boolean isPangram(String input) { + throw new UnsupportedOperationException("Method has not been implemented yet."); + } +} diff --git a/exercises/pangram/src/test/java/PangramCheckerTest.java b/exercises/pangram/src/test/java/PangramCheckerTest.java new file mode 100644 index 000000000..f9d7117a4 --- /dev/null +++ b/exercises/pangram/src/test/java/PangramCheckerTest.java @@ -0,0 +1,82 @@ +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class PangramCheckerTest { + private PangramChecker pangramChecker; + + @Before + public void setup() { + pangramChecker = new PangramChecker(); + } + + + @Test + public void emptySentenceIsNotPangram() { + assertFalse(pangramChecker.isPangram("")); + } + + @Ignore + @Test + public void pangramWithOnlyLowerCaseLettersIsRecognizedAsPangram() { + assertTrue(pangramChecker.isPangram("the quick brown fox jumps over the lazy dog")); + } + + @Ignore + @Test + public void phraseMissingCharacterXIsNotPangram() { + assertFalse(pangramChecker.isPangram("a quick movement of the enemy will jeopardize five gunboats")); + } + + @Ignore + @Test + public void anotherPhraseMissingCharacterXIsNotPangram() { + assertFalse(pangramChecker.isPangram("the quick brown fish jumps over the lazy dog")); + } + + @Ignore + @Test + public void pangramWithUnderscoresIsRecognizedAsPangram() { + assertTrue(pangramChecker.isPangram("\"the_quick_brown_fox_jumps_over_the_lazy_dog\"")); + } + + @Ignore + @Test + public void pangramWithNumbersIsRecognizedAsPangram() { + assertTrue(pangramChecker.isPangram("\"the 1 quick brown fox jumps over the 2 lazy dogs\"")); + } + + @Ignore + @Test + public void phraseWithMissingLettersReplacedByNumbersIsNotPangram() { + assertFalse(pangramChecker.isPangram("\"7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog\"")); + } + + @Ignore + @Test + public void pangramWithMixedCaseAndPunctuationIsRecognizedAsPangram() { + assertTrue(pangramChecker.isPangram("\"Five quacking Zephyrs jolt my wax bed.\"")); + } + + @Ignore + @Test + public void pangramWithNonAsciiCharactersIsRecognizedAsPangram() { + assertTrue(pangramChecker.isPangram("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.")); + } + + + @Ignore + @Test + public void panagramInAlphabetOtherThanAsciiIsNotRecognizedAsPangram() { + assertFalse(pangramChecker.isPangram("Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства.")); + } + + @Ignore + @Test + public void upperAndLowerCaseVersionsOfTheSameCharacterShouldNotBeCountedSeparately() { + assertFalse(pangramChecker.isPangram("the quick brown fox jumped over the lazy FOX")); + } +} diff --git a/exercises/pangram/src/test/java/PangramsTest.java b/exercises/pangram/src/test/java/PangramsTest.java deleted file mode 100644 index f2f847c19..000000000 --- a/exercises/pangram/src/test/java/PangramsTest.java +++ /dev/null @@ -1,75 +0,0 @@ -import org.junit.Test; -import org.junit.Ignore; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; - -public class PangramsTest { - - - @Test - public void emptySentenceIsNotPangram() { - assertFalse(Pangrams.isPangram("")); - } - - @Ignore - @Test - public void pangramWithOnlyLowerCaseLettersIsRecognizedAsPangram() { - assertTrue(Pangrams.isPangram("the quick brown fox jumps over the lazy dog")); - } - - @Ignore - @Test - public void phraseMissingCharacterXIsNotPangram() { - assertFalse(Pangrams.isPangram("a quick movement of the enemy will jeopardize five gunboats")); - } - - @Ignore - @Test - public void anotherPhraseMissingCharacterXIsNotPangram() { - assertFalse(Pangrams.isPangram("the quick brown fish jumps over the lazy dog")); - } - - @Ignore - @Test - public void pangramWithUnderscoresIsRecognizedAsPangram() { - assertTrue(Pangrams.isPangram("\"the_quick_brown_fox_jumps_over_the_lazy_dog\"")); - } - - @Ignore - @Test - public void pangramWithNumbersIsRecognizedAsPangram() { - assertTrue(Pangrams.isPangram("\"the 1 quick brown fox jumps over the 2 lazy dogs\"")); - } - - @Ignore - @Test - public void phraseWithMissingLettersReplacedByNumbersIsNotPangram() { - assertFalse(Pangrams.isPangram("\"7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog\"")); - } - - @Ignore - @Test - public void pangramWithMixedCaseAndPunctuationIsRecognizedAsPangram() { - assertTrue(Pangrams.isPangram("\"Five quacking Zephyrs jolt my wax bed.\"")); - } - - @Ignore - @Test - public void pangramWithNonAsciiCharactersIsRecognizedAsPangram() { - assertTrue(Pangrams.isPangram("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich.")); - } - - - @Ignore - @Test - public void panagramInAlphabetOtherThanAsciiIsNotRecognizedAsPangram() { - assertFalse(Pangrams.isPangram("Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства.")); - } - - @Ignore - @Test - public void upperAndLowerCaseVersionsOfTheSameCharacterShouldNotBeCountedSeparately() { - assertFalse(Pangrams.isPangram("the quick brown fox jumped over the lazy FOX")); - } -}