### Question:
BannedRefChecker { protected List<Range> getRangeMatches(String line, String[] words) { List<Range> ranges = new ArrayList<Range>(); if (words == null) { return ranges; } String lowerline = line.toLowerCase(); int idx = 0; int end = 0; for (String word : words) { idx = lowerline.indexOf(word, idx); while (idx >= 0) { end = idx + word.length(); ranges.add(new Range(idx, end, line.substring(idx, end))); idx = lowerline.indexOf(word, idx + word.length()); } } return ranges; } BannedRefChecker(String included[], String excluded[]); void check(Report report, File file);  }### Answer:
@Test public void testGetRangeMatchesSimple() { String includes[] = { "fakeco" }; String excludes[] = null; BannedRefChecker checker = new BannedRefChecker(includes, excludes); List<Range> ranges = checker.getRangeMatches("import com.fakeco.common.Utils;", includes); Assert.assertNotNull("Should not have a null range", ranges); Assert.assertThat("Ranges.size()", ranges.size(), is(1)); Range range = ranges.get(0); Assert.assertThat("Range.start", range.start, is(11)); Assert.assertThat("Range.end", range.end, is(17)); Assert.assertThat("Range.match", range.match, is("fakeco")); }
@Test public void testGetRangeMatchesMulti() { String includes[] = { "fakeco" }; String excludes[] = null; BannedRefChecker checker = new BannedRefChecker(includes, excludes); List<Range> ranges = checker.getRangeMatches("import com.fakeco.internal.fakecommon.FakeCoFakeColocated;", includes); Assert.assertNotNull("Should not have a null range", ranges); Range expected[] = new Range[] { new Range(11, "fakeco"), new Range(27, "fakeco"), new Range(38, "FakeCo"), new Range(44, "FakeCo") }; Assert.assertThat("Ranges.size()", ranges.size(), is(expected.length)); for(int i=0; i<expected.length; i++) { Range actual = ranges.get(i); Assert.assertThat("Range.start", actual.start, is(expected[i].start)); Assert.assertThat("Range.end", actual.end, is(expected[i].end)); Assert.assertThat("Range.match", actual.match, is(expected[i].match)); } }