@ Experimental ( name = "validActivationEmail" ) @ RetryOnFailure ( attempts = 3 , delay = 60 ) @ Conditioned @ Et ( "Je valide le mail d'activation '(.*)'[\\.|\\?]" ) @ And ( "I valid activation email '(.*)'[\\.|\\?]" ) public void validActivationEmail ( String mailHost , String mailUser , String mailPassword , String senderMail , String subjectMail , String firstCssQuery , List < GherkinStepCondition > conditions ) throws FailureException , TechnicalException { try { final Properties props = System . getProperties ( ) ; props . setProperty ( "mail.store.protocol" , "imap" ) ; final Session session = Session . getDefaultInstance ( props , null ) ; final Store store = session . getStore ( "imaps" ) ; store . connect ( mailHost , mailUser , mailPassword ) ; final Folder inbox = store . getFolder ( "Inbox" ) ; inbox . open ( Folder . READ_ONLY ) ; final SearchTerm filterA = new FlagTerm ( new Flags ( Flags . Flag . SEEN ) , false ) ; final SearchTerm filterB = new FromTerm ( new InternetAddress ( senderMail ) ) ; final SearchTerm filterC = new SubjectTerm ( subjectMail ) ; final SearchTerm [ ] filters = { filterA , filterB , filterC } ; final SearchTerm searchTerm = new AndTerm ( filters ) ; final Message [ ] messages = inbox . search ( searchTerm ) ; for ( final Message message : messages ) { validateActivationLink ( subjectMail , firstCssQuery , message ) ; } } catch ( final Exception e ) { new Result . Failure <> ( "" , Messages . format ( Messages . getMessage ( Messages . FAIL_MESSAGE_MAIL_ACTIVATION ) , subjectMail ) , false , Context . getCallBack ( Callbacks . RESTART_WEB_DRIVER ) ) ; } }
Valid activation email .