### Question:
MethodExecutionStrategy implements ExecutionStrategy { public static MethodExecutionStrategy byMatchingArguments(Class<?> clazz, String methodName, Object... arguments) throws ScriptException { List<Method> matchingMethods = new ArrayList<>(); for (Method method : clazz.getMethods()) { if (method.getName().equals(methodName) && (method.getModifiers() & Modifier.PUBLIC) != 0 && ReflectionUtil.matchesArguments(method, arguments)) { matchingMethods.add(method); } } int count = matchingMethods.size(); if (count == 0) { throw new ScriptException("No method '" + methodName + "' with matching arguments found"); } else if (count > 1) { throw new ScriptException("Ambiguous methods '" + methodName + "' with matching arguments found: " + "\n" + matchingMethods.stream().map(Object::toString).collect(Collectors.joining("\n"))); } return byMethod(matchingMethods.get(0), arguments); } private  MethodExecutionStrategy(Method method, Object... arguments); @Override Object execute(Object instance); static MethodExecutionStrategy byMethod(Method method, Object... arguments); static MethodExecutionStrategy byMainMethod(Class<?> clazz, String... arguments); static MethodExecutionStrategy byArgumentTypes(Class<?> clazz, String methodName, Class<?>[] argumentTypes, Object... arguments); static MethodExecutionStrategy byMatchingArguments(Class<?> clazz, String methodName, Object... arguments);  }### Answer:
@Test public void testByMatchingArguments() throws ScriptException { MethodExecutionStrategy methodExecutionStrategy = MethodExecutionStrategy.byMatchingArguments( TestMethod.class, "doSomething", "Hello", 42); TestMethod instance = new TestMethod(); Object result = methodExecutionStrategy.execute(instance); assertThat(result).isEqualTo("doSomething(Hello,42)"); }
@Test public void failUnknownByMatchingArguments() throws ScriptException { assertThatThrownBy(() -> { MethodExecutionStrategy.byMatchingArguments( TestMethod.class, "unknown", "Hello", 42); }).isInstanceOf(ScriptException.class); }
@Test public void failNoMatchByMatchingArguments() throws ScriptException { assertThatThrownBy(() -> { MethodExecutionStrategy.byMatchingArguments( TestMethod.class, "doSomething", 1, 2, 3, 4); }).isInstanceOf(ScriptException.class); }
@Test public void failAmbiguousByMatchingArguments() throws ScriptException { assertThatThrownBy(() -> { MethodExecutionStrategy.byMatchingArguments( TestMethod.class, "doSomething", null, null, 42); }).isInstanceOf(ScriptException.class); }