Search in sources :

Example 1 with FieldStatement

use of org.evosuite.testcase.FieldStatement in project evosuite by EvoSuite.

the class TestExtractingVisitor method retrieveVariableReference.

private VariableReference retrieveVariableReference(QualifiedName qualifiedName) {
    try {
        Class<?> referencedClass = retrieveTypeClass(qualifiedName.getQualifier().resolveTypeBinding());
        Field field = referencedClass.getField(qualifiedName.getName().getIdentifier());
        FieldReference fieldReference = new FieldReference(testCase.getReference(), new GenericField(field, referencedClass));
        Class<?> resultClass = retrieveTypeClass(qualifiedName.resolveTypeBinding());
        FieldStatement fieldStatement = new FieldStatement(testCase.getReference(), new GenericField(field, resultClass), fieldReference);
        testCase.addStatement(fieldStatement);
        return fieldStatement.getReturnValue();
    } catch (Exception exc) {
        throw new RuntimeException(exc);
    }
}
Also used : Field(java.lang.reflect.Field) GenericField(org.evosuite.utils.GenericField) FieldReference(org.evosuite.testcase.FieldReference) FieldStatement(org.evosuite.testcase.FieldStatement) GenericField(org.evosuite.utils.GenericField) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 FieldReference (org.evosuite.testcase.FieldReference)1 FieldStatement (org.evosuite.testcase.FieldStatement)1 GenericField (org.evosuite.utils.GenericField)1