@Test public void shouldFindMethodsWithNameMatchingRegularExpression() { Method[] stringMethods = stringReflection.findMethods("indexO.", true); assertThat(stringMethods.length, is(4)); for (Method method : stringMethods) { assertThat(method.getName(), is("indexOf")); } stringMethods = stringReflection.findMethods(".+gth", true); assertThat(stringMethods.length, is(1)); for (Method method : stringMethods) { assertThat(method.getName(), is("length")); } }
@Test public void shouldNotFindMethodsWhenThereAreNoMethodsWithThatName() { assertThat(stringReflection.findMethods("size", true).length, is(0)); assertThat(stringListReflection.findMethods("argleBargle", true).length, is(0)); }