Cannot instantiate Mapper interface

120 views Asked by At

Getting a null pointer because Mapper interface not instantiated for Junit Not sure how to fix. Example code bellow,

@Autowired private Mapper mapper;

Detail newDetail= mapper.map(detail, Detail.class);

Any help would be awesome

I tried instantiating with other maps and it didn’t work.

1

There are 1 answers

0
Merri Curlz On BEST ANSWER

I found the solution. I used a @Mock injection and mocked the mapper being called like in the main function. This solved the npe.