Class PowerMockitoStubberImpl
- All Implemented Interfaces:
org.mockito.stubbing.BaseStubber, org.mockito.stubbing.Stubber, PowerMockitoStubber
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidassertNotNull(Object object, String name) org.mockito.stubbing.StubberdoAnswer(org.mockito.stubbing.Answer answer) org.mockito.stubbing.Stubberorg.mockito.stubbing.Stubberorg.mockito.stubbing.Stubberorg.mockito.stubbing.Stubberorg.mockito.stubbing.Stubberorg.mockito.stubbing.Stubberorg.mockito.stubbing.StubbervoidAllows to choose a static method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style<T> voidAllows to mock a static private method based on the parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Allows to mock a static private method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.<T> voidAllows to mock a static private method based on method name and parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.<T> Twhen(T instanceMock) <T> voidAllows to mock a private instance method based on the parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Allows to mock a private instance method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.<T> voidAllows to mock a private instance method based on method name and parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.
-
Field Details
-
stubber
private final org.mockito.stubbing.Stubber stubber
-
-
Constructor Details
-
PowerMockitoStubberImpl
public PowerMockitoStubberImpl(org.mockito.stubbing.Stubber stubber)
-
-
Method Details
-
when
public <T> T when(T instanceMock) - Specified by:
whenin interfaceorg.mockito.stubbing.Stubber
-
doThrow
- Specified by:
doThrowin interfaceorg.mockito.stubbing.BaseStubber
-
doThrow
-
doThrow
-
doAnswer
public org.mockito.stubbing.Stubber doAnswer(org.mockito.stubbing.Answer answer) - Specified by:
doAnswerin interfaceorg.mockito.stubbing.BaseStubber
-
doNothing
public org.mockito.stubbing.Stubber doNothing()- Specified by:
doNothingin interfaceorg.mockito.stubbing.BaseStubber
-
doReturn
- Specified by:
doReturnin interfaceorg.mockito.stubbing.BaseStubber
-
doReturn
-
doCallRealMethod
public org.mockito.stubbing.Stubber doCallRealMethod()- Specified by:
doCallRealMethodin interfaceorg.mockito.stubbing.BaseStubber
-
when
Description copied from interface:PowerMockitoStubberAllows to choose a static method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() styleExample:
doThrow(new RuntimeException()).when(StaticList.class); StaticList.clear(); //following throws RuntimeException: StaticList.clear();
Read more about those methods:
Mockito.doThrow(Class)Mockito.doAnswer(Answer)Mockito.doNothing()Mockito.doReturn(Object)- Specified by:
whenin interfacePowerMockitoStubber- Parameters:
classMock- the mock class- See Also:
-
when
Description copied from interface:PowerMockitoStubberAllows to mock a private instance method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(instance, method("myMethod")).withNoArguments();Read more about those methods:
Mockito.doThrow(Class)Mockito.doAnswer(Answer)Mockito.doNothing()Mockito.doReturn(Object)- Specified by:
whenin interfacePowerMockitoStubber- Parameters:
mock- the methodmethod- private method to be mocked- Throws:
Exception- See Also:
-
when
Description copied from interface:PowerMockitoStubberAllows to mock a private instance method based on the parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(instance, parameter1, parameter2);
Read more about those methods:
Mockito.doThrow(Throwable...)Mockito.doAnswer(Answer)Mockito.doNothing()Mockito.doReturn(Object)- Specified by:
whenin interfacePowerMockitoStubber- Parameters:
mock- the Mockarguments- array of arguments is used to find suitable method to be mocked.- Throws:
Exception- See Also:
-
when
Description copied from interface:PowerMockitoStubberAllows to mock a private instance method based on method name and parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(instance, "methodName", parameter1, parameter2);
Read more about those methods:
Mockito.doThrow(Throwable...)Mockito.doAnswer(Answer)Mockito.doNothing()Mockito.doReturn(Object)- Specified by:
whenin interfacePowerMockitoStubber- Parameters:
mock- the MockmethodToExpect- name of method which have to mockedarguments- array of arguments ofmethodToExpect- Throws:
Exception- See Also:
-
when
Description copied from interface:PowerMockitoStubberAllows to mock a static private method based on the parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(MyClass.class, parameter1, parameter2);
Read more about those methods:
Mockito.doThrow(Throwable...)Mockito.doAnswer(Answer)Mockito.doNothing()Mockito.doReturn(Object)- Specified by:
whenin interfacePowerMockitoStubber- Parameters:
classMock- class owner of private static methodarguments- array of arguments is used to find suitable method to be mocked.- Throws:
Exception- See Also:
-
when
public <T> void when(Class<T> classMock, String methodToExpect, Object... parameters) throws Exception Description copied from interface:PowerMockitoStubberAllows to mock a static private method based on method name and parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(MyClass.class, "methodName", parameter1, parameter2);
Read more about those methods:
Mockito.doThrow(Throwable...)Mockito.doAnswer(Answer)Mockito.doNothing()Mockito.doReturn(Object)- Specified by:
whenin interfacePowerMockitoStubber- Parameters:
classMock- the class owner of static private methodmethodToExpect- name of method which have to mockedparameters- array of arguments ofmethodToExpect- Throws:
Exception- See Also:
-
when
Description copied from interface:PowerMockitoStubberAllows to mock a static private method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.Example:
doThrow(new RuntimeException()).when(MyClass.class, method("myMethod")).withNoArguments();Read more about those methods:
Mockito.doThrow(Throwable...)Mockito.doAnswer(Answer)Mockito.doNothing()Mockito.doReturn(Object)- Specified by:
whenin interfacePowerMockitoStubber- Parameters:
classMock- class owner of private static methodmethod- private static method to be mocked- Throws:
Exception- See Also:
-
assertNotNull
-