0

出现错误 junit.framework.AssertionFailedError: 发生异常:java.lang.ClassCastException: us.ny.state.ij.safeact.ask.persistency.impl.CchResponsePersistenceImpl$$EnhancerByMockitoWithCGLIB$$d62edc51 不兼容

这是存根

私人合作伙伴PersistenceImpl 模拟合作伙伴PersistenceImpl;

@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不接受那个演员?

4

0 回答 0