@ Lorsque ( "Je vérifie les champs obligatoires:") @ Given ( "I check mandatory fields:" ) public void checkMandatoryFields ( Map < String , String > mandatoryFields ) throws TechnicalException , FailureException { final List < String > errors = new ArrayList <> ( ) ; for ( final Entry < String , String > element : mandatoryFields . entrySet ( ) ) { if ( "" . equals ( element . getValue ( ) ) ) { errors . add ( element . getKey ( ) ) ; } } if ( ! errors . isEmpty ( ) ) { final StringBuilder errorMessage = new StringBuilder ( ) ; int index = errorMessage . length ( ) ; for ( int j = 0 ; j < errors . size ( ) ; j ++ ) { errorMessage . append ( Messages . format ( Messages . getMessage ( Messages . FAIL_MESSAGE_EMPTY_DATA ) , errors . get ( j ) ) ) ; if ( j == 0 ) { errorMessage . setCharAt ( index , Character . toUpperCase ( errorMessage . charAt ( index ) ) ) ; } else { errorMessage . setCharAt ( index , Character . toLowerCase ( errorMessage . charAt ( index ) ) ) ; } if ( ' ' == errorMessage . charAt ( errorMessage . length ( ) - 1 ) ) { errorMessage . deleteCharAt ( errorMessage . length ( ) - 1 ) ; } errorMessage . append ( ", " ) ; index = errorMessage . length ( ) ; } errorMessage . delete ( errorMessage . length ( ) - 2 , errorMessage . length ( ) ) ; errorMessage . append ( ' ' ) ; new Result . Failure <> ( mandatoryFields , errorMessage . toString ( ) , false , Context . getCallBack ( Callbacks . RESTART_WEB_DRIVER ) ) ; } }
Check all mandatory fields .