I have a class that's composed of other objects/dependencies as follows:
public class One{
private RedisPool redisPool;
private static final WeakHashMap<String, Dedup<String>> CACHE = new WeakHashMap<>();
private static final ObjectMapper mapper = new ObjectMapper();
private BigQueryManager bigQueryManager;
private RedisClientManager redisClientManager;
private PubSubIntegration pubSub;
public One(RedisPool redisPool, Configuration config) {
this.redisPool = redisPool;
bigQueryManager = new BigQueryManager(config);
redisClientManager = new RedisClientManager(redisPool, config);
pubSub = new PubSubIntegration(config);
}
....
...
other methods
}
I tried:
public class OneTest{
@Mock
RedisPool redisPool;
@Mock
Configuration config;
@Before
public void setUp(){
MockitoAnnotations.initMocks(this);
One one = new One(redisPool, config);
}
}
But I'm not sure whether the objects constructed inside the constructor also get mocked, as I have used those objects in other methods inside the class.
How can I mock the objects constructed inside the constructor?