I have a class and I am injecting a proxy into my service.
Service service
{
private ServiceProxy proxy;
public Service(ServiceProxy proxy)
{
Write your test class as this, which will initialize Service with a mock of ServiceProxy:
class ServiceTest
{
@Mock
ServiceProxy mockProxy;
//This will inject the "ServiceProxy" mock into your "Service" instance.
@InjectMocks
Service service = new Service(mockProxy);
@Before
public void init() {
//This will initialize the annotated mocks
MockitoAnnotations.initMocks(this);
}
@Test
public void test() {
...
}
}