Anagrams { public static List<String> generate(String input) { List<String> anagrams = new ArrayList<String>(); char[] inputChars = input.toCharArray(); for (int i = 0; i < total(input); i++) { int movePosition = i < input.length() ? i : 0; char move = inputChars[movePosition]; char replace = inputChars[1]; inputChars[movePosition] = replace; inputChars[1] = move; String output = String.valueOf(inputChars); anagrams.add(output); } return anagrams; }  static List<String> generate(String input);  }
@Test public void testCalculateTotalAnagrams() throws Exception { String input = "biro"; List<String> output = Anagrams.generate(input); assertThat(output).hasSize(24); }
@Test public void testFirstTwoLetterOfBiroAreSwapped() throws Exception { String input = "biro"; List<String> output = Anagrams.generate(input); assertThat(output).contains("ibro"); }
@Test public void testFirstTwoLetterOfBenAreSwapped() throws Exception { String input = "ben"; List<String> output = Anagrams.generate(input); assertThat(output).contains("ebn"); }
@Test public void testFirstLetterOfBenIsSwappedWithTheLast() throws Exception { String input = "ben"; List<String> output = Anagrams.generate(input); assertThat(output).contains("neb"); }
@Ignore @Test public void testFirstLetterOfBiroIsSwappedWithTheLast() throws Exception { String input = "biro"; List<String> output = Anagrams.generate(input); assertThat(output).contains("oirb"); }