package by.stqa.pft.mantis.tests;

import by.stqa.pft.mantis.model.MailMessage;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import javax.mail.MessagingException;
import java.io.IOException;
import java.util.List;

import static org.testng.AssertJUnit.assertTrue;

/**
 * Created by artemr on 1/13/2017.
 */
public class RegistrationTests extends TestBase {
  //@BeforeMethod
  public void startMailServer(){
    app.mail().start();
  }

  @Test
  public void testRegistration() throws IOException, MessagingException {
    long now = System.currentTimeMillis();
    String user =  String.format("user%s", now);
    String email = String.format("%s@localhost.localdomain", user);
    String password = "password";
    app.james().createUser(user, password);
    app.registration().start(user, email);
//    List<MailMessage> mailMessages = app.mail().waitForMail(2, 10000);
    List<MailMessage> mailMessages = app.james().waitForMail(user, password, 30000);
    String confirmationLink = findConfirmationLink(mailMessages, email);
    app.registration().finish(confirmationLink, password);
    assertTrue(app.newSession().login(user, password));
  }

  //@AfterMethod(alwaysRun = true)
  public void stopMailServer(){
    app.mail().stop();
  }

}

@@ -734,20 +734,8 @@
 host
-.localdomain
 %22, u
@@ -1011,17 +1011,17 @@
 ssword, 
-3
+6
 0000);%0A 

fix email