Anagrams { public List<String> from(String word) { List<String> anagrams = new ArrayList<String>(); for (int i = 0; i < word.length(); i++) { anagrams.addAll(generatePermutationsFor(word)); } return anagrams; }  List<String> from(String word);  }
@Test public void testAnagramForAIsItself() throws Exception { List<String> expected = ANAGRAMS_FOR_A; List<String> result = anagrams.from(A); assertThat(result).isEqualTo(expected); }
@Test public void testAnagramsForAbHasCorrectLength() throws Exception { List<String> expected = ANAGRAMS_FOR_AB; List<String> result = anagrams.from(AB); assertThat(result).hasSameSizeAs(expected); }
@Test public void testAnagramsForAbcHasCorrectLength() { List<String> expected = ANAGRAMS_FOR_ABC; List<String> result = anagrams.from(ABC); assertThat(result).hasSameSizeAs(expected); }
@Test @Ignore public void testAllAnagramsAreSameLengthAsInput() throws Exception { List<String> expected = ANAGRAMS_FOR_AB; List<String> result = anagrams.from(AB); for (String anagram : result) { assertThat(anagram).hasSize(AB.length()); } }