Skip to content

Conversation

@lestephane
Copy link

When I use a generified use case:

public interface GenericMethodInterface<I, O> {
    O invoke(I request);
}

public class GenericMethodUseCase implements GenericMethodInterface<String, String> {
    @Override
    public String invoke(final String in) {
        return in.replace("in", "out");
    }
}

I can't (no pun intended) use it. The use-case method lookup logic in SinglePublicUseCaseMethodCaller sees two methods

  • The generic method
  • The bridge method associated with the generic method (whassat?, wait, what?)

And throws the exception:

java.lang.IllegalArgumentException: Use case classes must have 1 instance method.
Found the methods[
public java.lang.String pkg.GenericMethodUseCase.invoke(java.lang.String),
public java.lang.Object pkg.GenericMethodUseCase.invoke(java.lang.Object)
]for class class pkg.GenericMethodUseCase

The fix is simple, but for the life of me, the test suite is so complex I could not write
a test in the same style as what exists there already.

Instead I added a shim by making a production method package-private and calling
that method directly from a simple unit test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant