AreAnagrams { public boolean check(String a, String b) { if (a == null || b == null) { throw new IllegalArgumentException("You can't use null Strings as input."); } if (a.length() != b.length()) { return false; } int[] lettersA = getLettersAsArray(a); int[] lettersB = getLettersAsArray(b); int valuesA = getSumOfArray(lettersA); int valuesB = getSumOfArray(lettersB); return valuesA == valuesB; }  boolean check(String a, String b);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullStringsAsInput() { areAnagrams.check(null, null); }
@Test public void shouldReturnTrueIfBothWordsAreEmpty() { assertTrue(areAnagrams.check("", "")); }
@Test public void shouldReturnFalseIfOneWordIsEmptyAndTheOtherNo() { assertFalse(areAnagrams.check("", "pedro")); }
@Test public void shouldReturnFalseIfWordsAreNotAnagrams() { assertFalse(areAnagrams.check("ana", "pedro")); }
@Test public void shouldReturnTrueIfWordsAreAnagrams() { assertTrue(areAnagrams.check("ana", "naa")); }