automapperdatamapperobjectmappermapper

Cannot instantiate Mapper interface


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.


Solution

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