private List < Object > getRuleInstances ( Object testInstance ) throws Exception { List < Object > ruleInstances = new ArrayList < Object > ( ) ; List < Field > fieldsWithRuleAnnotation = SecurityActions . getFieldsWithAnnotation ( testInstance . getClass ( ) , Rule . class ) ; if ( fieldsWithRuleAnnotation . isEmpty ( ) ) { List < Method > methodsWithAnnotation = SecurityActions . getMethodsWithAnnotation ( testInstance . getClass ( ) , Rule . class ) ; if ( methodsWithAnnotation . isEmpty ( ) ) { // there isn't any rule in the test class return null ; } else { log . warning ( "Please note that methods annotated with @Rule are not fully supported in Arquillian. " + "Specifically, if you want to enrich a field in your Rule implementation class." ) ; return ruleInstances ; } } else { for ( Field field : fieldsWithRuleAnnotation ) { Object fieldInstance = field . get ( testInstance ) ; if ( isRule ( fieldInstance ) ) { ruleInstances . add ( fieldInstance ) ; } } } return ruleInstances ; }
Retrieves instances of the TestRule and MethodRule classes