ClassCastException with @Autowired Spring JpaRepositories #294

Closed
beatjost opened this Issue Jun 15, 2016 · 2 comments

Projects

None yet

2 participants

@beatjost
beatjost commented Jun 15, 2016 edited

We have several test which run until version 1.21 of JMockit. From version 1.22 we get a 'ClassCastException'. The problem there is that the spring JpaRepository retuns a repository instance itself instead of a generic domain class.

Repository

public interface StateRepository extends JpaRepository<State, Long> {
   ...

Runtime code

@Autowired
StateRepository stateRepo;
...
activity.setState(stateRepo.findOne(stateId));  //returns repo instead of domain pojo

JUnit test

@Tested
StateUpdater stateUpdater;
@Injectable
StateRepository stateRepo;

@rliesenfeld rliesenfeld added the bug label Jun 15, 2016
@rliesenfeld rliesenfeld self-assigned this Jun 15, 2016
@rliesenfeld
Member

It's a bug.

Thanks for reporting!

@rliesenfeld rliesenfeld added a commit that closed this issue Jun 19, 2016
@rliesenfeld rliesenfeld Fixed bug in cascaded mocking, involving a multi-level hierarchy of g…
…eneric interface types, where a ClassCastException was occurring; closes #294.
049de55
@beatjost

Thanks for fast fixing - will check next release.

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