I have a class Component which creates two objects from other classes JMSConnector and AppiaConnector and links both of them.
I have a method that reads the status of both objects and return a combined value.
Problem I am facing when testing this method is I have no way of injecting mocks of appiaConnector and jmsConnector to test the behaviour of this method.
For example I tried this:
@RunWith(MockitoJUnitRunner.class) public class ComponentTest { @Mock JMSConnector jmsConnector; @Mock AppiaConnector appiaConnector; Component component = new Component(); @Test public void testGetStatus() { given(jmsConnector.getStatus()).willReturn(true); given(appiaConnector.getStatus()).willReturn(true); // this is what I want... but I can't dynamically inject these mocks into component ??? assertTrue(component.getStatus()); } } Is there a way that I can achieve this, or should I use stubs? (which seems an overkill for such a small method)

