### Question:
VisitorUtils { public static void executeVisitorMethod(Object visitor, Object visitedObject) { Class<?> visitableClass = visitedObject.getClass(); Method visitMethod = ReflectionTools.findMethod(visitor.getClass(), "visit", visitedObject); if (visitMethod != null) { try { visitMethod.invoke(visitor, new Object[]{visitedObject}); return; } catch (IllegalAccessException | InvocationTargetException e) { e.printStackTrace(); throw new RuntimeException(e); } } throw new IllegalArgumentException("visit("+visitableClass.getSimpleName()+") method not found in visitor class "+visitor.getClass().getName()); }  static void executeVisitorMethod(Object visitor, Object visitedObject);  }### Answer:
@Test public void executeVisitorMethod() { VisitorUtils.executeVisitorMethod(visitorA, visitableFoo); verify(visitableFoo).fooA(); }
@Test(expected=IllegalArgumentException.class) public void executeVisitorMethod_MethodNotFound() { VisitorUtils.executeVisitorMethod(visitorA, "aaa"); }