I have a code where i am writing Juint test case to check a service API. Below is the code :
@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);
}
My My PackageServiceImpl class contains loadPackage Method :
@Override
public PackageVO loadPackage(PackageVO packageVO){
PartnerVO partnerVO = new PartnerVO();
if (!packageVO.isParentOrg()) {
packageVO.getPackage().setOperatorId(SecurityHelper.getOrganization().getOperatorId());
}
partnerVO = partnerService.loadPartner(partnerVO);
}
i am trying to mock operatorId to setter method :
packageVO.getPackage().setOperatorId(SecurityHelper.getOrganization().getOperatorId());
but not able to get this done. Please let me know what am i missing here to mock operatorId to setter method.
Aucun commentaire:
Enregistrer un commentaire