Contains { public boolean evaluate(String w1, String w2) { if (w1 == null || w2 == null) { throw new IllegalArgumentException("You can't pass null strings as input."); } boolean contains = false; for (int i = 0; i < w2.length() - 1; i++) { if (w2.charAt(i) == w1.charAt(0)) { for (int j = 0; j < w1.length(); j++) { if (w1.charAt(j) == w2.charAt(i + j) && j == w1.length() - 1) { contains = true; break; } } } } return contains; }  boolean evaluate(String w1, String w2);  }
@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptNullStringsAsInput() { contains.evaluate(null, null); }
@Test public void shouldReturnTrueIfSecondStringContainsFirstString() { String word1 = "dro"; String word2 = "Pedro"; boolean result = contains.evaluate(word1, word2); assertTrue(result); }
@Test public void shouldReturnFalseIfSecondStringDoesNotContainFirstString() { String word1 = "ana"; String word2 = "Pedro"; boolean result = contains.evaluate(word1, word2); assertFalse(result); }
@Test public void shouldBeCaseSensitive() { String word1 = "PE"; String word2 = "Pedro"; boolean result = contains.evaluate(word1, word2); assertFalse(result); }