Package org.powermock.mockpolicies.impl
Class MockPolicyInterceptionSettingsImpl
- java.lang.Object
-
- org.powermock.mockpolicies.impl.MockPolicyInterceptionSettingsImpl
-
- All Implemented Interfaces:
MockPolicyInterceptionSettings
public class MockPolicyInterceptionSettingsImpl extends java.lang.Object implements MockPolicyInterceptionSettings
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.lang.reflect.Field>
fieldsToSuppress
private java.util.Set<java.lang.String>
fieldsTypesToSuppress
private java.util.Set<java.lang.reflect.Method>
methodsToSuppress
private java.util.Map<java.lang.reflect.Method,java.lang.reflect.InvocationHandler>
proxies
private java.util.Map<java.lang.reflect.Method,java.lang.Object>
substituteReturnValues
-
Constructor Summary
Constructors Constructor Description MockPolicyInterceptionSettingsImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFieldToSuppress(java.lang.reflect.Field[] fields)
Add specific fields that should be suppressed upon invocation.void
addFieldToSuppress(java.lang.reflect.Field firstField, java.lang.reflect.Field... fields)
Add specific fields that should be suppressed upon invocation.void
addFieldTypesToSuppress(java.lang.String[] fieldTypes)
Add field types that should be suppressed.void
addFieldTypesToSuppress(java.lang.String firstType, java.lang.String... additionalFieldTypes)
Add field types that should be suppressed.void
addMethodsToSuppress(java.lang.reflect.Method[] methods)
Add methods to suppress upon invocation.void
addMethodsToSuppress(java.lang.reflect.Method methodToSuppress, java.lang.reflect.Method... additionalMethodsToSuppress)
Add methods to suppress upon invocation.void
addSubtituteReturnValue(java.lang.reflect.Method method, java.lang.Object returnObject)
Add a method that should be intercepted and return another value (returnObject
).java.lang.reflect.Field[]
getFieldsToSuppress()
java.lang.String[]
getFieldTypesToSuppress()
java.lang.reflect.Method[]
getMethodsToSuppress()
java.util.Map<java.lang.reflect.Method,java.lang.reflect.InvocationHandler>
getProxiedMethods()
Get all methods that should be proxied and the invocation handler for each method.java.util.Map<java.lang.reflect.Method,java.lang.Object>
getStubbedMethods()
Get all substitute return values and also returns an unmodifiable map of all method-object pairs the were initialized.java.util.Map<java.lang.reflect.Method,java.lang.Object>
getSubstituteReturnValues()
Get all substitute return values and also returns an unmodifiable map of all method-object pairs the were initialized.void
proxyMethod(java.lang.reflect.Method method, java.lang.reflect.InvocationHandler invocationHandler)
Proxy a method with the given invocation handler.void
setFieldsSuppress(java.lang.reflect.Field[] fields)
Set specific fields that should be suppressed upon invocation.void
setFieldTypesToSuppress(java.lang.String[] fieldTypes)
Set which field types that should be suppressed.void
setMethodsToProxy(java.util.Map<java.lang.reflect.Method,java.lang.reflect.InvocationHandler> proxies)
Set the methods to proxy.void
setMethodsToStub(java.util.Map<java.lang.reflect.Method,java.lang.Object> substituteReturnValues)
Set the substitute return values.void
setMethodsToSuppress(java.lang.reflect.Method[] methods)
Set which methods to suppress.void
setSubtituteReturnValues(java.util.Map<java.lang.reflect.Method,java.lang.Object> substituteReturnValues)
Set the substitute return values.void
stubMethod(java.lang.reflect.Method method, java.lang.Object returnObject)
Add a method that should be intercepted and return another value (returnObject
) (i.e.
-
-
-
Field Detail
-
fieldsToSuppress
private java.util.Set<java.lang.reflect.Field> fieldsToSuppress
-
methodsToSuppress
private java.util.Set<java.lang.reflect.Method> methodsToSuppress
-
substituteReturnValues
private java.util.Map<java.lang.reflect.Method,java.lang.Object> substituteReturnValues
-
fieldsTypesToSuppress
private java.util.Set<java.lang.String> fieldsTypesToSuppress
-
proxies
private java.util.Map<java.lang.reflect.Method,java.lang.reflect.InvocationHandler> proxies
-
-
Method Detail
-
addFieldTypesToSuppress
public void addFieldTypesToSuppress(java.lang.String firstType, java.lang.String... additionalFieldTypes)
Description copied from interface:MockPolicyInterceptionSettings
Add field types that should be suppressed.- Specified by:
addFieldTypesToSuppress
in interfaceMockPolicyInterceptionSettings
-
addFieldTypesToSuppress
public void addFieldTypesToSuppress(java.lang.String[] fieldTypes)
Description copied from interface:MockPolicyInterceptionSettings
Add field types that should be suppressed.- Specified by:
addFieldTypesToSuppress
in interfaceMockPolicyInterceptionSettings
-
setFieldTypesToSuppress
public void setFieldTypesToSuppress(java.lang.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 interfaceMockPolicyInterceptionSettings
-
getFieldsToSuppress
public java.lang.reflect.Field[] getFieldsToSuppress()
- Specified by:
getFieldsToSuppress
in interfaceMockPolicyInterceptionSettings
- Returns:
- Which fields should be suppressed (i.e. will be set to
null
or other default values).
-
getMethodsToSuppress
public java.lang.reflect.Method[] getMethodsToSuppress()
- Specified by:
getMethodsToSuppress
in interfaceMockPolicyInterceptionSettings
- Returns:
- Which methods that should be suppressed/stubbed (i.e. return a default value when invoked).
-
getStubbedMethods
public java.util.Map<java.lang.reflect.Method,java.lang.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 interfaceMockPolicyInterceptionSettings
-
addFieldToSuppress
public void addFieldToSuppress(java.lang.reflect.Field firstField, java.lang.reflect.Field... fields)
Description copied from interface:MockPolicyInterceptionSettings
Add specific fields that should be suppressed upon invocation.- Specified by:
addFieldToSuppress
in interfaceMockPolicyInterceptionSettings
-
addFieldToSuppress
public void addFieldToSuppress(java.lang.reflect.Field[] fields)
Description copied from interface:MockPolicyInterceptionSettings
Add specific fields that should be suppressed upon invocation.- Specified by:
addFieldToSuppress
in interfaceMockPolicyInterceptionSettings
-
addMethodsToSuppress
public void addMethodsToSuppress(java.lang.reflect.Method methodToSuppress, java.lang.reflect.Method... additionalMethodsToSuppress)
Description copied from interface:MockPolicyInterceptionSettings
Add methods to suppress upon invocation.- Specified by:
addMethodsToSuppress
in interfaceMockPolicyInterceptionSettings
-
addMethodsToSuppress
public void addMethodsToSuppress(java.lang.reflect.Method[] methods)
Description copied from interface:MockPolicyInterceptionSettings
Add methods to suppress upon invocation.- Specified by:
addMethodsToSuppress
in interfaceMockPolicyInterceptionSettings
-
stubMethod
public void stubMethod(java.lang.reflect.Method method, java.lang.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 interfaceMockPolicyInterceptionSettings
-
setFieldsSuppress
public void setFieldsSuppress(java.lang.reflect.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 interfaceMockPolicyInterceptionSettings
-
setMethodsToSuppress
public void setMethodsToSuppress(java.lang.reflect.Method[] methods)
Description copied from interface:MockPolicyInterceptionSettings
Set which methods to suppress. Note that this overrides all previous configurations.- Specified by:
setMethodsToSuppress
in interfaceMockPolicyInterceptionSettings
-
setMethodsToStub
public void setMethodsToStub(java.util.Map<java.lang.reflect.Method,java.lang.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 interfaceMockPolicyInterceptionSettings
-
getFieldTypesToSuppress
public java.lang.String[] getFieldTypesToSuppress()
- Specified by:
getFieldTypesToSuppress
in interfaceMockPolicyInterceptionSettings
- Returns:
- The fully-qualified names to the fields that should be suppressed.
-
addSubtituteReturnValue
public void addSubtituteReturnValue(java.lang.reflect.Method method, java.lang.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 interfaceMockPolicyInterceptionSettings
-
setSubtituteReturnValues
public void setSubtituteReturnValues(java.util.Map<java.lang.reflect.Method,java.lang.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 interfaceMockPolicyInterceptionSettings
-
getSubstituteReturnValues
public java.util.Map<java.lang.reflect.Method,java.lang.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 interfaceMockPolicyInterceptionSettings
-
getProxiedMethods
public java.util.Map<java.lang.reflect.Method,java.lang.reflect.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 interfaceMockPolicyInterceptionSettings
-
proxyMethod
public void proxyMethod(java.lang.reflect.Method method, java.lang.reflect.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 interfaceMockPolicyInterceptionSettings
-
setMethodsToProxy
public void setMethodsToProxy(java.util.Map<java.lang.reflect.Method,java.lang.reflect.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 interfaceMockPolicyInterceptionSettings
-
-