### Question:
MethodCallMetadata implements CallMetadata { public static MethodCallMetadata method(Object instance, Method method) { return new MethodCallMetadata( Objects.requireNonNull(instance), Objects.requireNonNull(method), null); } MethodCallMetadata(Object instance, Method method, Routine<?, ?> routine); static MethodCallMetadata method(Object instance, Method method); static MethodCallMetadata method(Method method); static MethodCallMetadata method(Object instance, Routine<T, Object> routine); static MethodCallMetadata method(Object instance, String methodName, Type... argumentsTypes); static MethodCallMetadata method(Class<?> targetType, String methodName, Type... argumentsTypes); static MethodCallMetadata method(T instance, Consumer<T> catchingInvocation); @Override InvocationFactory getInvocationFactory(); Object getInstance(); Method getMethod(); Routine<?, ?> getRoutine(); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test void shouldNotResolveProtectedMethod() { assertThatThrownBy(() -> MethodCallMetadata.method(new AnAction(), "protectedExecute")) .isExactlyInstanceOf(IllegalArgumentException.class); }
@Test void shouldNotResolveDefaultScopedMethod() { assertThatThrownBy(() -> MethodCallMetadata.method(new AnAction(), "defaultExecute")) .isExactlyInstanceOf(IllegalArgumentException.class); }
@Test void shouldMapPublicMethodCorrectly() { method(this, a -> a.publicCollect(null, null)); }
@Test void shouldFailWhenMappingPackageAccessMethod() { assertThatThrownBy(() -> method(this, a -> a.packageCollect(null, null))) .isExactlyInstanceOf(IllegalArgumentException.class) .hasMessage("" + "Method void com.sabre.oss.yare.invoker.java.MethodCallMetadataTest.packageCollect(java.util.List,java.lang.Object)" + " in class com.sabre.oss.yare.invoker.java.MethodCallMetadataTest must be public!"); }
@Test void shouldFailWhenMappingPrivateAccessMethod() { assertThatThrownBy(() -> method(this, a -> a.privateCollect(null, null))) .isExactlyInstanceOf(IllegalArgumentException.class); }
@Test void shouldFailWhenMappingPublicStaticMethod() { assertThatThrownBy(() -> method(this, a -> a.publicStaticCollect(null, null))) .isExactlyInstanceOf(IllegalArgumentException.class); }
@Test void shouldMapPublicMethodInDifferentPublicAccessClassInstanceCorrectly() { SimplePublicCollector simplePublicCollector = new SimplePublicCollector(); method(simplePublicCollector, a -> a.publicCollect(null, null)); }
@Test void shouldFailWhenMappingPackageAccessMethodInDifferentPublicAccessClassInstance() { SimplePublicCollector simplePublicCollector = new SimplePublicCollector(); assertThatThrownBy(() -> method(simplePublicCollector, a -> a.packageCollect(null, null))) .isExactlyInstanceOf(IllegalArgumentException.class) .hasMessage("" + "Method void com.sabre.oss.yare.invoker.java.SimplePublicCollector.packageCollect(java.util.List,java.lang.Object)" + " in class com.sabre.oss.yare.invoker.java.SimplePublicCollector must be public!"); }
@Test void shouldFailWhenMappingPublicAccessMethodInDifferentPackageAccessClassInstance() { SimplePackageCollector simplePackageCollector = new SimplePackageCollector(); assertThatThrownBy(() -> method(simplePackageCollector, a -> a.publicCollect(null, null))) .isExactlyInstanceOf(IllegalArgumentException.class); }
@Test void shouldFailWhenMappingPackageAccessMethodInDifferentPackageAccessClassInstance() { SimplePackageCollector simplePackageCollector = new SimplePackageCollector(); assertThatThrownBy(() -> method(simplePackageCollector, a -> a.packageCollect(null, null))) .isExactlyInstanceOf(IllegalArgumentException.class); }