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 void
assertNotNull
(Object object, String name) org.mockito.stubbing.Stubber
doAnswer
(org.mockito.stubbing.Answer answer) org.mockito.stubbing.Stubber
org.mockito.stubbing.Stubber
org.mockito.stubbing.Stubber
org.mockito.stubbing.Stubber
org.mockito.stubbing.Stubber
org.mockito.stubbing.Stubber
org.mockito.stubbing.Stubber
void
Allows to choose a static method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style<T> void
Allows 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> void
Allows to mock a static private method based on method name and parameters when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style.<T> T
when
(T instanceMock) <T> void
Allows 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> void
Allows 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:
when
in interfaceorg.mockito.stubbing.Stubber
-
doThrow
- Specified by:
doThrow
in interfaceorg.mockito.stubbing.BaseStubber
-
doThrow
- Specified by:
doThrow
in interfaceorg.mockito.stubbing.BaseStubber
-
doThrow
public org.mockito.stubbing.Stubber doThrow(Class<? extends Throwable> toBeThrown, Class<? extends Throwable>[] nextToBeThrown) - Specified by:
doThrow
in interfaceorg.mockito.stubbing.BaseStubber
-
doAnswer
public org.mockito.stubbing.Stubber doAnswer(org.mockito.stubbing.Answer answer) - Specified by:
doAnswer
in interfaceorg.mockito.stubbing.BaseStubber
-
doNothing
public org.mockito.stubbing.Stubber doNothing()- Specified by:
doNothing
in interfaceorg.mockito.stubbing.BaseStubber
-
doReturn
- Specified by:
doReturn
in interfaceorg.mockito.stubbing.BaseStubber
-
doReturn
- Specified by:
doReturn
in interfaceorg.mockito.stubbing.BaseStubber
-
doCallRealMethod
public org.mockito.stubbing.Stubber doCallRealMethod()- Specified by:
doCallRealMethod
in interfaceorg.mockito.stubbing.BaseStubber
-
when
Description copied from interface:PowerMockitoStubber
Allows 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:
when
in interfacePowerMockitoStubber
- Parameters:
classMock
- the mock class- See Also:
-
when
Description copied from interface:PowerMockitoStubber
Allows 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:
when
in interfacePowerMockitoStubber
- Parameters:
mock
- the methodmethod
- private method to be mocked- Throws:
Exception
- See Also:
-
when
Description copied from interface:PowerMockitoStubber
Allows 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:
when
in 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:PowerMockitoStubber
Allows 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:
when
in 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:PowerMockitoStubber
Allows 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:
when
in 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:PowerMockitoStubber
Allows 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:
when
in 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:PowerMockitoStubber
Allows 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:
when
in interfacePowerMockitoStubber
- Parameters:
classMock
- class owner of private static methodmethod
- private static method to be mocked- Throws:
Exception
- See Also:
-
assertNotNull
-