net.jakubholy.jeeutils.jsfelcheck.validator
Class MockingPropertyResolver
java.lang.Object
javax.faces.el.PropertyResolver
net.jakubholy.jeeutils.jsfelcheck.validator.MockingPropertyResolver
- All Implemented Interfaces:
- PredefinedVariableResolver.NewVariableEncounteredListener
public final class MockingPropertyResolver
- extends javax.faces.el.PropertyResolver
- implements PredefinedVariableResolver.NewVariableEncounteredListener
Automatically return a Mockito mock for any property that is valid, otherwise throw a PropertyNotFoundException.
The mocked type is determined automatically but may be forced via definePropertyTypeOverride(String, Class),
which is useful e.g. for Maps that return just Objects.
|
Method Summary |
void |
addElExpressionFilter(ElExpressionFilter elExpressionFilter)
Throw ExpressionRejectedByFilterException for any expression not accepted by the supplied filter. |
void |
clearElExpressionFilters()
|
void |
definePropertyTypeOverride(String elExpression,
Class<?> newType)
Define what type to produce for a JSF EL expression. |
Class<?> |
getType(Object target,
int index)
|
Class<?> |
getType(Object target,
Object property)
|
Object |
getValue(Object target,
int property)
|
Object |
getValue(Object target,
Object property)
|
void |
handleNewVariableEncountered(String variableName)
|
boolean |
isReadOnly(Object arg0,
int arg1)
|
boolean |
isReadOnly(Object arg0,
Object arg1)
|
void |
setValue(Object arg0,
int arg1,
Object arg2)
|
void |
setValue(Object arg0,
Object arg1,
Object arg2)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MockingPropertyResolver
public MockingPropertyResolver()
definePropertyTypeOverride
public void definePropertyTypeOverride(String elExpression,
Class<?> newType)
- Define what type to produce for a JSF EL expression.
There are two types of overrides:
(1) property overrides: pass in the complete property, ex: bean.property1.property2
(2) collection component type overrides: for all sub-properties of a variable/property
(unless there is also a property override for it), used for arrays etc. Ex: bean.mapProperty.* =>
bean.mapProperty['someKey'] and bean.mapProperty.anotherProperty will be both affected by the override
- Parameters:
elExpression - The expression where to override the guessed type with only names and dots; i.e.
'var.prop becomes var.propnewType - (required)
getType
public Class<?> getType(Object target,
Object property)
throws javax.faces.el.EvaluationException,
javax.faces.el.PropertyNotFoundException
- Specified by:
getType in class javax.faces.el.PropertyResolver
- Throws:
javax.faces.el.EvaluationException
javax.faces.el.PropertyNotFoundException
getType
public Class<?> getType(Object target,
int index)
throws javax.faces.el.EvaluationException,
javax.faces.el.PropertyNotFoundException
- Specified by:
getType in class javax.faces.el.PropertyResolver
- Throws:
javax.faces.el.EvaluationException
javax.faces.el.PropertyNotFoundException
getValue
public Object getValue(Object target,
Object property)
throws javax.faces.el.EvaluationException,
javax.faces.el.PropertyNotFoundException
- Specified by:
getValue in class javax.faces.el.PropertyResolver
- Throws:
javax.faces.el.EvaluationException
javax.faces.el.PropertyNotFoundException
getValue
public Object getValue(Object target,
int property)
throws javax.faces.el.EvaluationException,
javax.faces.el.PropertyNotFoundException
- Specified by:
getValue in class javax.faces.el.PropertyResolver
- Throws:
javax.faces.el.EvaluationException
javax.faces.el.PropertyNotFoundException
isReadOnly
public boolean isReadOnly(Object arg0,
Object arg1)
throws javax.faces.el.EvaluationException,
javax.faces.el.PropertyNotFoundException
- Specified by:
isReadOnly in class javax.faces.el.PropertyResolver
- Throws:
javax.faces.el.EvaluationException
javax.faces.el.PropertyNotFoundException
isReadOnly
public boolean isReadOnly(Object arg0,
int arg1)
throws javax.faces.el.EvaluationException,
javax.faces.el.PropertyNotFoundException
- Specified by:
isReadOnly in class javax.faces.el.PropertyResolver
- Throws:
javax.faces.el.EvaluationException
javax.faces.el.PropertyNotFoundException
setValue
public void setValue(Object arg0,
Object arg1,
Object arg2)
throws javax.faces.el.EvaluationException,
javax.faces.el.PropertyNotFoundException
- Specified by:
setValue in class javax.faces.el.PropertyResolver
- Throws:
javax.faces.el.EvaluationException
javax.faces.el.PropertyNotFoundException
setValue
public void setValue(Object arg0,
int arg1,
Object arg2)
throws javax.faces.el.EvaluationException,
javax.faces.el.PropertyNotFoundException
- Specified by:
setValue in class javax.faces.el.PropertyResolver
- Throws:
javax.faces.el.EvaluationException
javax.faces.el.PropertyNotFoundException
handleNewVariableEncountered
public void handleNewVariableEncountered(String variableName)
- Specified by:
handleNewVariableEncountered in interface PredefinedVariableResolver.NewVariableEncounteredListener
addElExpressionFilter
public void addElExpressionFilter(ElExpressionFilter elExpressionFilter)
- Throw
ExpressionRejectedByFilterException for any expression not accepted by the supplied filter.
- Parameters:
elExpressionFilter - (required)
clearElExpressionFilters
public void clearElExpressionFilters()
Copyright © 2011. All Rights Reserved.