private PreconfigGroupOpenLPolicyRulesService openlApi;
@Override
public Object[] getPackageEligibility(IRulesRuntimeContext context, Dimension dimension) {
return openlApi.PackageEligibility(context, dimension);
}
我是jUnits的新手。任何人都可以帮我写方法getPackageEligibility的测试用例。我需要做的就是@Mock。
我试过
PreconfigGroupOpenLComponentService preconfigGroupOpenLComponentService = new PreconfigGroupOpenLComponentService();
@Mock
PreconfigGroupOpenLPolicyRulesService openlApi;
@Mock
IRulesRuntimeContext context;
@Mock
Dimension dimension;
@Test
public void testGetPackageEligibility() {
Object[] arg = preconfigGroupOpenLComponentService.getPackageEligibility(context, dimension);
assertNotNull(arg);
}
但是
显示java.lang.NullPointerException at com.exigen.eis.preconfig.policy.group.services.impl.PreconfigGroupOpenLComponentService.getPackageEligibility(PreconfigGroupOpenLComponentService.java:32) at com.exigen.eis.preconfig.policy.group.services.impl.PreconfigGroupOpenLComponentServiceTest.testGetPackageEligibility(PreconfigGroupOpenLComponentServiceTest.java:28)