例外
java.lang.NullPointerException
at org.powermock.api.mockito.internal.expectation.PowerMockitoStubberImpl.addAnswersForStubbing(PowerMockitoStubberImpl.java:67)
at org.powermock.api.mockito.internal.expectation.PowerMockitoStubberImpl.when(PowerMockitoStubberImpl.java:42)
at org.powermock.api.mockito.internal.expectation.PowerMockitoStubberImpl.when(PowerMockitoStubberImpl.java:105)
at us.ny.state.ij.safeact.ask.facade.AmmoSellerKeeperFacadeBeanTest.setUp(FacadeBeanTest.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
モックするコード
BusinessServiceFactory serviceFactory = BusinessServiceFactory.getInstance();
RegBusinessServiceImpl regCreateService =
serviceFactory.getRegBusinessService(adrEntityManager);
テストコード
@RunWith(PowerMockRunner.class)
@PrepareForTest({ BusinessServiceFactory.class})
public class FacadeBeanTest {
@Before
public void setUp() throws Exception {
AmmoSellerRegBusinessServiceImpl mockRegBusinessServiceImpl
= mock(AmmoSellerRegBusinessServiceImpl.class);
PowerMockito.doReturn(mockRegBusinessServiceImpl)
.when(BusinessServiceFactory.class,"getRegBusinessService",
(mockEntityManager)); //--- line 84 null pointer exception
}
}
なぜ例外が発生するのか理解できません。提案をいただければ幸いです。