-
Notifications
You must be signed in to change notification settings - Fork 0
/
ApplicationTest.java
83 lines (67 loc) · 2.93 KB
/
ApplicationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.salesforcedevorgcreation;
import com.salesforcedevorgcreation.email.EmailFilter;
import com.salesforcedevorgcreation.email.EmailFilterService;
import com.salesforcedevorgcreation.selenium.SeleniumRunnerProperties;
import com.salesforcedevorgcreation.selenium.SeleniumService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.mail.MessagingException;
import java.io.IOException;
import java.util.Arrays;
import static com.salesforcedevorgcreation.selenium.SeleniumRunnerProperties.CHANGE_PASSWORD_URL;
import static com.salesforcedevorgcreation.selenium.SeleniumService.Type.*;
@Slf4j
@SpringBootTest
@RunWith(SpringRunner.class)
public class ApplicationTest {
@Autowired
private EmailFilterService emailFilterService;
@Autowired
private SeleniumService seleniumServiceTest;
@Test
public void test_Application() throws Throwable {
String username = seleniumServiceTest
.buildRunner(NEW_DEVELOPER_ORG)
.run();
idle(10);
String verificationUrl = emailFilterService.findTextInEmail(
EmailFilter.builder()
.from("developer@salesforce.com")
.subject("Salesforce: Verificar su cuenta")
.bodyLines(Arrays.asList("Le damos la bienvenida a Salesforce Developer Edition", username))
.beforeStr("Haga clic en ")
.afterStr(" para iniciar sesión ahora")
.build());
String password = seleniumServiceTest
.buildRunner(CHANGE_PASSWORD)
.addProperty(CHANGE_PASSWORD_URL, verificationUrl)
.run();
seleniumServiceTest
.buildRunner(CHANGE_LANGUAGE)
.run();
seleniumServiceTest
.buildRunner(RESET_SECURITY_TOKEN)
.run();
idle(5);
String securityToken = emailFilterService.findTextInEmail(
EmailFilter.builder()
.from("support@emea.salesforce.com")
.subject("Your new Salesforce security token")
.bodyLines(Arrays.asList("you recently changed your password or requested to reset your security token", username))
.beforeStr("Security token \\(case-sensitive\\):")
.afterStr("(\\s)*For more")
.build());
log.info("CREATED username: {}, password: {}, token: {}", username, password, securityToken);
}
private void idle(int seconds) {
try {
Thread.sleep(1000 * seconds);
} catch (InterruptedException e) {
log.error("Exception: ", e);
}
}
}