private static boolean validateLocal ( String target , String name , CommandLine cmd ) throws InterruptedException { int validationCount = 0 ; Map < ValidationTask . TaskResult , Integer > results = new HashMap <> ( ) ; Map < String , String > optionsMap = new HashMap <> ( ) ; for ( Option opt : cmd . getOptions ( ) ) { optionsMap . put ( opt . getOpt ( ) , opt . getValue ( ) ) ; } Collection < ValidationTask > tasks = TARGET_TASKS . get ( target ) ; System . out . format ( "Validating %s environment...%n" , target ) ; for ( ValidationTask task : tasks ) { String taskName = TASKS . get ( task ) ; if ( name != null && ! taskName . startsWith ( name ) ) { continue ; } System . out . format ( "Validating %s...%n" , taskName ) ; ValidationTask . TaskResult result = task . validate ( optionsMap ) ; results . put ( result , results . getOrDefault ( result , 0 ) + 1 ) ; switch ( result ) { case OK : System . out . print ( Constants . ANSI_GREEN ) ; break ; case WARNING : System . out . print ( Constants . ANSI_YELLOW ) ; break ; case FAILED : System . out . print ( Constants . ANSI_RED ) ; break ; case SKIPPED : System . out . print ( Constants . ANSI_PURPLE ) ; break ; default : break ; } System . out . print ( result . name ( ) ) ; System . out . println ( Constants . ANSI_RESET ) ; validationCount ++ ; } if ( results . containsKey ( ValidationTask . TaskResult . FAILED ) ) { System . err . format ( "%d failures " , results . get ( ValidationTask . TaskResult . FAILED ) ) ; } if ( results . containsKey ( ValidationTask . TaskResult . WARNING ) ) { System . err . format ( "%d warnings " , results . get ( ValidationTask . TaskResult . WARNING ) ) ; } if ( results . containsKey ( ValidationTask . TaskResult . SKIPPED ) ) { System . err . format ( "%d skipped " , results . get ( ValidationTask . TaskResult . SKIPPED ) ) ; } System . err . println ( ) ; if ( validationCount == 0 ) { System . err . format ( "No validation task matched name \"%s\".%n" , name ) ; return false ; } if ( results . containsKey ( ValidationTask . TaskResult . FAILED ) ) { return false ; } System . out . println ( "Validation succeeded." ) ; return true ; }
runs validation tasks in local environment