获取错误 junit.framework.AssertionFailedError:发生异常:java.lang.ClassCastException:us.ny.state.ij.safeact.ask.persistency.impl.CchResponsePersistenceImpl $$ EnhancerByMockitoWithCGLIB $$ d62edc51与
不兼容这里是存根
private PartnerPersistenceImpl mockPartnerPersistenceImpl;
@Before
public void setUp() throws Exception {
mockPartnerPersistenceImpl = mock(PartnerPersistenceImpl.class);
}
PowerMockito.doReturn(mockPartnerPersistenceImpl).when(PersistenceFactory.class,"getService",any(RecordTypeEnum.class),any(EntityManager.class));
service.processRequest("DUmmy data");
The return type of PersistenceFactory method is
public static ADRBasePersistenceImpl<?, Long> getService(){}
在服务类中,我们将类型转换为不同的类以返回
PartnerPersistenceImpl parnerPeristenceImpl =(PartnerPersistenceImpl)PersistenceFactory.getService(RecordTypeEnum.SELLERPARTNER,entityManager);
我不知道为什么mockito不接受演员?