org.powermock.mockpolicies.impl
Class MockPolicyInterceptionSettingsImpl

java.lang.Object
  extended by org.powermock.mockpolicies.impl.MockPolicyInterceptionSettingsImpl
All Implemented Interfaces:
MockPolicyInterceptionSettings

public class MockPolicyInterceptionSettingsImpl
extends Object
implements MockPolicyInterceptionSettings


Constructor Summary
MockPolicyInterceptionSettingsImpl()
           
 
Method Summary
 void addFieldToSuppress(Field[] fields)
          Add specific fields that should be suppressed upon invocation.
 void addFieldToSuppress(Field firstField, Field... fields)
          Add specific fields that should be suppressed upon invocation.
 void addFieldTypesToSuppress(String[] fieldTypes)
          Add field types that should be suppressed.
 void addFieldTypesToSuppress(String firstType, String... additionalFieldTypes)
          Add field types that should be suppressed.
 void addMethodsToSuppress(Method[] methods)
          Add methods to suppress upon invocation.
 void addMethodsToSuppress(Method methodToSuppress, Method... additionalMethodsToSuppress)
          Add methods to suppress upon invocation.
 void addSubtituteReturnValue(Method method, Object returnObject)
          Add a method that should be intercepted and return another value ( returnObject).
 Field[] getFieldsToSuppress()
           
 String[] getFieldTypesToSuppress()
           
 Method[] getMethodsToSuppress()
           
 Map<Method,InvocationHandler> getProxiedMethods()
          Get all methods that should be proxied and the invocation handler for each method.
 Map<Method,Object> getStubbedMethods()
          Get all substitute return values and also returns an unmodifiable map of all method-object pairs the were initialized.
 Map<Method,Object> getSubstituteReturnValues()
          Get all substitute return values and also returns an unmodifiable map of all method-object pairs the were initialized.
 void proxyMethod(Method method, InvocationHandler invocationHandler)
          Proxy a method with the given invocation handler.
 void setFieldsSuppress(Field[] fields)
          Set specific fields that should be suppressed upon invocation.
 void setFieldTypesToSuppress(String[] fieldTypes)
          Set which field types that should be suppressed.
 void setMethodsToProxy(Map<Method,InvocationHandler> proxies)
          Set the methods to proxy.
 void setMethodsToStub(Map<Method,Object> substituteReturnValues)
          Set the substitute return values.
 void setMethodsToSuppress(Method[] methods)
          Set which methods to suppress.
 void setSubtituteReturnValues(Map<Method,Object> substituteReturnValues)
          Set the substitute return values.
 void stubMethod(Method method, Object returnObject)
          Add a method that should be intercepted and return another value ( returnObject) (i.e. the method is stubbed).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockPolicyInterceptionSettingsImpl

public MockPolicyInterceptionSettingsImpl()
Method Detail

addFieldTypesToSuppress

public void addFieldTypesToSuppress(String firstType,
                                    String... additionalFieldTypes)
Description copied from interface: MockPolicyInterceptionSettings
Add field types that should be suppressed.

Specified by:
addFieldTypesToSuppress in interface MockPolicyInterceptionSettings

addFieldTypesToSuppress

public void addFieldTypesToSuppress(String[] fieldTypes)
Description copied from interface: MockPolicyInterceptionSettings
Add field types that should be suppressed.

Specified by:
addFieldTypesToSuppress in interface MockPolicyInterceptionSettings

setFieldTypesToSuppress

public void setFieldTypesToSuppress(String[] fieldTypes)
Description copied from interface: MockPolicyInterceptionSettings
Set which field types that should be suppressed. Note that this overrides all previous configurations.

Specified by:
setFieldTypesToSuppress in interface MockPolicyInterceptionSettings

getFieldsToSuppress

public Field[] getFieldsToSuppress()
Specified by:
getFieldsToSuppress in interface MockPolicyInterceptionSettings
Returns:
Which fields should be suppressed (i.e. will be set to null or other default values).

getMethodsToSuppress

public Method[] getMethodsToSuppress()
Specified by:
getMethodsToSuppress in interface MockPolicyInterceptionSettings
Returns:
Which methods that should be suppressed/stubbed (i.e. return a default value when invoked).

getStubbedMethods

public Map<Method,Object> getStubbedMethods()
Description copied from interface: MockPolicyInterceptionSettings
Get all substitute return values and also returns an unmodifiable map of all method-object pairs the were initialized.

Specified by:
getStubbedMethods in interface MockPolicyInterceptionSettings

addFieldToSuppress

public void addFieldToSuppress(Field firstField,
                               Field... fields)
Description copied from interface: MockPolicyInterceptionSettings
Add specific fields that should be suppressed upon invocation.

Specified by:
addFieldToSuppress in interface MockPolicyInterceptionSettings

addFieldToSuppress

public void addFieldToSuppress(Field[] fields)
Description copied from interface: MockPolicyInterceptionSettings
Add specific fields that should be suppressed upon invocation.

Specified by:
addFieldToSuppress in interface MockPolicyInterceptionSettings

addMethodsToSuppress

public void addMethodsToSuppress(Method methodToSuppress,
                                 Method... additionalMethodsToSuppress)
Description copied from interface: MockPolicyInterceptionSettings
Add methods to suppress upon invocation.

Specified by:
addMethodsToSuppress in interface MockPolicyInterceptionSettings

addMethodsToSuppress

public void addMethodsToSuppress(Method[] methods)
Description copied from interface: MockPolicyInterceptionSettings
Add methods to suppress upon invocation.

Specified by:
addMethodsToSuppress in interface MockPolicyInterceptionSettings

stubMethod

public void stubMethod(Method method,
                       Object returnObject)
Description copied from interface: MockPolicyInterceptionSettings
Add a method that should be intercepted and return another value ( returnObject) (i.e. the method is stubbed).

Specified by:
stubMethod in interface MockPolicyInterceptionSettings

setFieldsSuppress

public void setFieldsSuppress(Field[] fields)
Description copied from interface: MockPolicyInterceptionSettings
Set specific fields that should be suppressed upon invocation. Note that this overrides all previous configurations.

Specified by:
setFieldsSuppress in interface MockPolicyInterceptionSettings

setMethodsToSuppress

public void setMethodsToSuppress(Method[] methods)
Description copied from interface: MockPolicyInterceptionSettings
Set which methods to suppress. Note that this overrides all previous configurations.

Specified by:
setMethodsToSuppress in interface MockPolicyInterceptionSettings

setMethodsToStub

public void setMethodsToStub(Map<Method,Object> substituteReturnValues)
Description copied from interface: MockPolicyInterceptionSettings
Set the substitute return values. The substitute return values is a key-value map where each key is a method that should be intercepted and each value is the new return value for that method when it's intercepted.

Note that this overrides all previous configurations.

Specified by:
setMethodsToStub in interface MockPolicyInterceptionSettings

getFieldTypesToSuppress

public String[] getFieldTypesToSuppress()
Specified by:
getFieldTypesToSuppress in interface MockPolicyInterceptionSettings
Returns:
The fully-qualified names to the fields that should be suppressed.

addSubtituteReturnValue

public void addSubtituteReturnValue(Method method,
                                    Object returnObject)
Description copied from interface: MockPolicyInterceptionSettings
Add a method that should be intercepted and return another value ( returnObject). The substitute return values is a key-value map where each key is a method that should be intercepted and each value is the new return value for that method when it's intercepted.

Specified by:
addSubtituteReturnValue in interface MockPolicyInterceptionSettings

setSubtituteReturnValues

public void setSubtituteReturnValues(Map<Method,Object> substituteReturnValues)
Description copied from interface: MockPolicyInterceptionSettings
Set the substitute return values. The substitute return values is a key-value map where each key is a method that should be intercepted and each value is the new return value for that method when it's intercepted.

Note that this overrides all previous configurations.

Specified by:
setSubtituteReturnValues in interface MockPolicyInterceptionSettings

getSubstituteReturnValues

public Map<Method,Object> getSubstituteReturnValues()
Description copied from interface: MockPolicyInterceptionSettings
Get all substitute return values and also returns an unmodifiable map of all method-object pairs the were initialized.

Specified by:
getSubstituteReturnValues in interface MockPolicyInterceptionSettings

getProxiedMethods

public Map<Method,InvocationHandler> getProxiedMethods()
Description copied from interface: MockPolicyInterceptionSettings
Get all methods that should be proxied and the invocation handler for each method.

Specified by:
getProxiedMethods in interface MockPolicyInterceptionSettings

proxyMethod

public void proxyMethod(Method method,
                        InvocationHandler invocationHandler)
Description copied from interface: MockPolicyInterceptionSettings
Proxy a method with the given invocation handler. Each call to the method will be routed to the invocationHandler instead.

Specified by:
proxyMethod in interface MockPolicyInterceptionSettings

setMethodsToProxy

public void setMethodsToProxy(Map<Method,InvocationHandler> proxies)
Description copied from interface: MockPolicyInterceptionSettings
Set the methods to proxy. The proxies are a key-value map where each key is a method that should be intercepted and routed to the invocation handler instead.

Note that this overrides all previous configurations.

Specified by:
setMethodsToProxy in interface MockPolicyInterceptionSettings


Copyright © 2007-2012. All Rights Reserved.