I want to inject mock object into method's fields in testing bean. We have sth. like:
@Stateless
@LocalBean
public class TestedBean implements TestedBeanInterface
{
public OtherClass testedMethod {
private ClassIWantToMock necessaryField = new ClassIWantToMock();
return necessaryField.doThingsImpossibleToDoAtTest();
}
}
And that bean, I am testing in this way:
@RunWith(Arquillian.class)
public class TripPlannerFactoryBeanTest {
@Deployment
public static JavaArchive createDeployment() {
//
}
@EJB(mappedName = "java:module/TestedBean!ab.abc.abcd.TestedBean")
TestedBean testedBean;
@Test
public void testMethodOfTestedBean(){
testedBean.testedMethod();
}
}
It is possible to mock ClassIWantToMock() without any changes in TestedBean code?