Hi I want to test some method using in memory implementation without h2.
In impl of userMapper I have.
When I try to run my test, I have NullPointerException of this passwordEncoderMapper. How can I inject to filed autowire like on first screenshoot(authService) without load spring context (@SpringBootTest).
The reason why you have a NullPointerException
for the passwordEncoderMapper
is because you are mixing the spring componentModel
with Mappers#getMapper
. You shouldn't do that.
When you are using a custom componentModel
you should always use that dependency injection in order to get the mappers.
What you can do for tests is to use Mapper#injectionStrategy
with InjectionStrategy#CONSTRUCTOR
and then instantiate the mapper on your own by providing the correct dependencies to it.