我有一个代码,我正在编写Juint测试用例来检查服务API。 以下是代码:
@RunWith(PowerMockRunner.class)
@PrepareForTest({PackageVO.class,PackageServiceImpl.class})
public class TestPackageService extends BaseTestClass {
packageVO = PowerMockito.spy(packageVO);
Package Package = EasyMock.createMock(Package.class);
Package = PowerMockito.spy(Package);
String OperatorId = "tivo:op.56";
Package.setOperatorId(OperatorId);
Package.setPackageType("Mock Package Type");
PowerMockito.doCallRealMethod().when(Package).setOperatorId(OperatorId);
packageVO.setPackage(Package);
packageVO = packageServiceImpl.loadPackage(packageVO);
Assert.assertNotNull("packageServiceImpl loadPackage", packageVO);
}
我的PackageServiceImpl类包含loadPackage方法:
@Override
public PackageVO loadPackage(PackageVO packageVO){
PartnerVO partnerVO = new PartnerVO();
if (!packageVO.isParentOrg()) {
packageVO.getPackage().setOperatorId(SecurityHelper.getOrganization().getOperatorId());
}
partnerVO = partnerService.loadPartner(partnerVO);
}
我正在尝试将operatorId模拟为setter方法:
packageVO.getPackage().setOperatorId(SecurityHelper.getOrganization().getOperatorId());
但无法完成此操作。请让我知道我在这里缺少什么来模拟operatorId到setter方法。