@Test public void sensitiveFieldsCheckedAtMultipleLevels() { class DeeperContainer { @Sensitive @Injection ( name = "Sensitive" ) String sensitive = "very sensitive"; @Injection ( name = "NotSensitive" ) String notSensitive = "cold and unfeeling"; } class DeepContainer { @InjectionDeep DeeperContainer deeperObj = new DeeperContainer(); } Object topLevelObject = new Object() { @InjectionDeep DeepContainer deepObj = new DeepContainer(); }; List<String> sensitiveFields = StepMetaProps.sensitiveFields( topLevelObject.getClass() ); assertThat( sensitiveFields, equalTo( singletonList( "Sensitive" ) ) ); }
@VisibleForTesting static List<String> sensitiveFields( Class clazz ) { Field[] declaredFields = clazz.getDeclaredFields(); return concat( stream( declaredFields ), recurseDeep( declaredFields ) ) .filter( field -> field.getAnnotation( Sensitive.class ) != null ) .filter( field -> field.getAnnotation( Injection.class ) != null ) .map( field -> field.getAnnotation( Injection.class ).name() ) .collect( Collectors.toList() ); }
StepMetaProps { @VisibleForTesting static List<String> sensitiveFields( Class clazz ) { Field[] declaredFields = clazz.getDeclaredFields(); return concat( stream( declaredFields ), recurseDeep( declaredFields ) ) .filter( field -> field.getAnnotation( Sensitive.class ) != null ) .filter( field -> field.getAnnotation( Injection.class ) != null ) .map( field -> field.getAnnotation( Injection.class ).name() ) .collect( Collectors.toList() ); } }
StepMetaProps { @VisibleForTesting static List<String> sensitiveFields( Class clazz ) { Field[] declaredFields = clazz.getDeclaredFields(); return concat( stream( declaredFields ), recurseDeep( declaredFields ) ) .filter( field -> field.getAnnotation( Sensitive.class ) != null ) .filter( field -> field.getAnnotation( Injection.class ) != null ) .map( field -> field.getAnnotation( Injection.class ).name() ) .collect( Collectors.toList() ); } @SuppressWarnings ( "unused" ) private  StepMetaProps(); private  StepMetaProps( StepMetaInterface smi ); }
StepMetaProps { @VisibleForTesting static List<String> sensitiveFields( Class clazz ) { Field[] declaredFields = clazz.getDeclaredFields(); return concat( stream( declaredFields ), recurseDeep( declaredFields ) ) .filter( field -> field.getAnnotation( Sensitive.class ) != null ) .filter( field -> field.getAnnotation( Injection.class ) != null ) .map( field -> field.getAnnotation( Injection.class ).name() ) .collect( Collectors.toList() ); } @SuppressWarnings ( "unused" ) private  StepMetaProps(); private  StepMetaProps( StepMetaInterface smi ); static StepMetaProps from( StepMetaInterface stepMeta ); StepMetaInterface to( StepMetaInterface stepMetaInterface ); StepMetaProps withVariables( VariableSpace space ); @Override String toString(); }
StepMetaProps { @VisibleForTesting static List<String> sensitiveFields( Class clazz ) { Field[] declaredFields = clazz.getDeclaredFields(); return concat( stream( declaredFields ), recurseDeep( declaredFields ) ) .filter( field -> field.getAnnotation( Sensitive.class ) != null ) .filter( field -> field.getAnnotation( Injection.class ) != null ) .map( field -> field.getAnnotation( Injection.class ).name() ) .collect( Collectors.toList() ); } @SuppressWarnings ( "unused" ) private  StepMetaProps(); private  StepMetaProps( StepMetaInterface smi ); static StepMetaProps from( StepMetaInterface stepMeta ); StepMetaInterface to( StepMetaInterface stepMetaInterface ); StepMetaProps withVariables( VariableSpace space ); @Override String toString();  }