I'm having a problem. I have an abstract class to which I inject its dependencies. They all build fine except for Jackson ObjectMapper.
Abstract class:
protected final ObjectMapper objectMapper;
private final String apiName;
@Autowired private MeliRestClient restClient;
public AbstractClientRepository(String apiName) {
this.apiName = apiName;
objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
}
Test class:
@Mock
private MeliRestClient restClient;
@Mock
private MeliRequestBuilder requestBuilderMock;
@Mock
private ObjectMapper objectMapper;
@InjectMocks
private static AbstractClientRepository abstractClientRepository;
private static final String poolName = "pool";
@BeforeAll
public static void setUp() throws RestException {
RoutingHelper.setMeliContext(MeliContextBuilder.build(Collections.emptyMap()));
abstractClientRepository = Mockito.mock(
AbstractClientRepository.class,
Mockito.CALLS_REAL_METHODS);
}
As you can see, the restClient is mocked and injected correctly, but the ObjectMapper is not. Any help?
Thank you!