All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.powermock.api.mockito.expectation.PowerMockitoStubber Maven / Gradle / Ivy

There is a newer version: 1.7.4
Show newest version
/*
 * Copyright 2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.powermock.api.mockito.expectation;

import org.mockito.Mockito;
import org.mockito.stubbing.Answer;
import org.mockito.stubbing.Stubber;

import java.lang.reflect.Method;

/**
 * Setup stubbing for private or void methods in final class, final void
 * methods, or static (final) methods.
 */
public interface PowerMockitoStubber extends Stubber {
	/**
	 * Allows to choose a static method when stubbing in
	 * doThrow()|doAnswer()|doNothing()|doReturn() style
	 * 

* Example: * *

	 * doThrow(new RuntimeException()).when();
	 * StaticList.clear();
	 * 
	 * //following throws RuntimeException:
	 * StaticList.clear();
	 * 
* * Read more about those methods: *

* {@link Mockito#doThrow(Throwable)} *

* {@link Mockito#doAnswer(Answer)} *

* {@link Mockito#doNothing()} *

* {@link Mockito#doReturn(Object)} *

* * See examples in javadoc for {@link Mockito} */ void when(Class classMock); /** * 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: *

* {@link Mockito#doThrow(Throwable)} *

* {@link Mockito#doAnswer(Answer)} *

* {@link Mockito#doNothing()} *

* {@link Mockito#doReturn(Object)} *

* * See examples in javadoc for {@link Mockito} */ PrivatelyExpectedArguments when(T mock, Method method) throws Exception; /** * 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: *

* {@link Mockito#doThrow(Throwable)} *

* {@link Mockito#doAnswer(Answer)} *

* {@link Mockito#doNothing()} *

* {@link Mockito#doReturn(Object)} *

* * See examples in javadoc for {@link Mockito} */ void when(T mock, Object... arguments) throws Exception; /** * 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: *

* {@link Mockito#doThrow(Throwable)} *

* {@link Mockito#doAnswer(Answer)} *

* {@link Mockito#doNothing()} *

* {@link Mockito#doReturn(Object)} *

* * See examples in javadoc for {@link Mockito} */ void when(T mock, String methodToExpect, Object... arguments) throws Exception; /** * 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: *

* {@link Mockito#doThrow(Throwable)} *

* {@link Mockito#doAnswer(Answer)} *

* {@link Mockito#doNothing()} *

* {@link Mockito#doReturn(Object)} *

* * See examples in javadoc for {@link Mockito} */ PrivatelyExpectedArguments when(Class classMock, Method method) throws Exception; /** * 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: *

* {@link Mockito#doThrow(Throwable)} *

* {@link Mockito#doAnswer(Answer)} *

* {@link Mockito#doNothing()} *

* {@link Mockito#doReturn(Object)} *

* * See examples in javadoc for {@link Mockito} */ void when(Class classMock, Object... arguments) throws Exception; /** * 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: *

* {@link Mockito#doThrow(Throwable)} *

* {@link Mockito#doAnswer(Answer)} *

* {@link Mockito#doNothing()} *

* {@link Mockito#doReturn(Object)} *

* * See examples in javadoc for {@link Mockito} */ void when(Class classMock, String methodToExpect, Object... parameters) throws Exception; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy