use of groovy.lang.PropertyValue in project groovy-core by groovy.
the class Inspector method getPropertyInfo.
/**
* Get info about Properties (Java and Groovy alike).
*
* @return Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
*/
public Object[] getPropertyInfo() {
List props = DefaultGroovyMethods.getMetaPropertyValues(objectUnderInspection);
Object[] result = new Object[props.size()];
int i = 0;
for (Iterator iter = props.iterator(); iter.hasNext(); i++) {
PropertyValue pv = (PropertyValue) iter.next();
result[i] = fieldInfo(pv);
}
return result;
}
use of groovy.lang.PropertyValue in project groovy-core by groovy.
the class InspectorTest method testInspectUninspectableProperty.
// TODO: if our code can never access inspect in this way, it would be better
// to move this to a boundary class and then we wouldn't need this test
public void testInspectUninspectableProperty() {
Object dummyInstance = new Object();
Inspector inspector = getTestableInspector(dummyInstance);
Class[] paramTypes = { Object.class, MetaProperty.class };
Object[] params = { null, null };
Mock mock = mock(PropertyValue.class, paramTypes, params);
mock.expects(once()).method("getType");
mock.expects(once()).method("getName");
mock.expects(once()).method("getValue").will(throwException(new RuntimeException()));
PropertyValue propertyValue = (PropertyValue) mock.proxy();
String[] result = inspector.fieldInfo(propertyValue);
assertEquals(Inspector.NOT_APPLICABLE, result[Inspector.MEMBER_VALUE_IDX]);
}
use of groovy.lang.PropertyValue in project groovy by apache.
the class Inspector method getPropertyInfo.
/**
* Get info about Properties (Java and Groovy alike).
*
* @return Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
*/
public Object[] getPropertyInfo() {
List props = DefaultGroovyMethods.getMetaPropertyValues(objectUnderInspection);
Object[] result = new Object[props.size()];
int i = 0;
for (Iterator iter = props.iterator(); iter.hasNext(); i++) {
PropertyValue pv = (PropertyValue) iter.next();
result[i] = fieldInfo(pv);
}
return result;
}
use of groovy.lang.PropertyValue in project groovy by apache.
the class InspectorTest method testInspectUninspectableProperty.
// TODO: if our code can never access inspect in this way, it would be better
// to move this to a boundary class and then we wouldn't need this test
public void testInspectUninspectableProperty() {
Object dummyInstance = new Object();
Inspector inspector = getTestableInspector(dummyInstance);
Class[] paramTypes = { Object.class, MetaProperty.class };
Object[] params = { null, null };
Mock mock = mock(PropertyValue.class, paramTypes, params);
mock.expects(once()).method("getType");
mock.expects(once()).method("getName");
mock.expects(once()).method("getValue").will(throwException(new RuntimeException()));
PropertyValue propertyValue = (PropertyValue) mock.proxy();
String[] result = inspector.fieldInfo(propertyValue);
assertEquals(Inspector.NOT_APPLICABLE, result[Inspector.MEMBER_VALUE_IDX]);
}
Aggregations