Search in sources :

Example 1 with PrimitiveFieldAssertion

use of org.evosuite.assertion.PrimitiveFieldAssertion in project evosuite by EvoSuite.

the class DefaultTestCase method assertionsNeedDownCast.

private boolean assertionsNeedDownCast(Statement s, VariableReference var, Class<?> abstractClass) {
    for (Assertion assertion : s.getAssertions()) {
        if (assertion instanceof InspectorAssertion && assertion.getSource().equals(var)) {
            InspectorAssertion inspectorAssertion = (InspectorAssertion) assertion;
            Method inspectorMethod = inspectorAssertion.getInspector().getMethod();
            if (!ClassUtils.hasMethod(abstractClass, inspectorMethod.getName(), inspectorMethod.getParameterTypes())) {
                return true;
            }
        } else if (assertion instanceof PrimitiveFieldAssertion && assertion.getSource().equals(var)) {
            PrimitiveFieldAssertion fieldAssertion = (PrimitiveFieldAssertion) assertion;
            if (!fieldAssertion.getField().getDeclaringClass().isAssignableFrom(abstractClass)) {
                return true;
            }
        }
    }
    return false;
}
Also used : InspectorAssertion(org.evosuite.assertion.InspectorAssertion) Assertion(org.evosuite.assertion.Assertion) InspectorAssertion(org.evosuite.assertion.InspectorAssertion) PrimitiveFieldAssertion(org.evosuite.assertion.PrimitiveFieldAssertion) PrimitiveFieldAssertion(org.evosuite.assertion.PrimitiveFieldAssertion) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)1 Assertion (org.evosuite.assertion.Assertion)1 InspectorAssertion (org.evosuite.assertion.InspectorAssertion)1 PrimitiveFieldAssertion (org.evosuite.assertion.PrimitiveFieldAssertion)1