I use the Hazelcast library in my project. It's executor service has this method:
void executeOnAllMembers(@Nonnull Runnable command);
This can fail at runtime if it is passed a command that does not implement Serializable.
I want to write a unit test that proves all callers of this method pass Serializable commands. I feel I should be able to do this using the Reflections library, but I can't figure it out.
For example, I can find all methods that invoke the method executeOnAllMembers:
Reflections reflections = new Reflections(new ConfigurationBuilder()
.setUrls(ClasspathHelper.forPackage("com.my.pet.project"))
.setScanners(new MemberUsageScanner()));
Method executeOnAllMembers =
IExecutorService.class.getDeclaredMethod("executeOnAllMembers", Runnable.class);
Collection<Member> allMethodsThatInvokeIExecutorServiceExecuteOnAllMembers =
reflections.getMemberUsage(executeOnAllMembers);
but I need the type of the argument (some implementation of Runnable that should also implement Serializable) that those methods pass into executeOnAllMembers.
Is this possible? If not, is there another way I can do it?