Skip to content

Commit 0107f6a

Browse files
committed
work
1 parent 77f29b5 commit 0107f6a

File tree

2 files changed

+35
-19
lines changed

2 files changed

+35
-19
lines changed

src/test/java/org/woehlke/java/simpleworklist/domain/db/user/UserAccountServiceIT.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import lombok.extern.slf4j.Slf4j;
44
import org.junit.Ignore;
5-
import org.junit.jupiter.api.MethodOrderer;
6-
import org.junit.jupiter.api.Test;
7-
import org.junit.jupiter.api.TestInstance;
8-
import org.junit.jupiter.api.TestMethodOrder;
5+
import org.junit.jupiter.api.*;
96
import org.springframework.beans.factory.annotation.Autowired;
107

118

@@ -73,8 +70,8 @@ public class UserAccountServiceIT {
7370
@Autowired
7471
protected UserAccountService userAccountService;
7572

76-
@Autowired
77-
protected ApplicationUserDetailsService applicationUserDetailsServiceImpl;
73+
@Autowired
74+
protected ApplicationUserDetailsService applicationUserDetailsServiceImpl;
7875

7976
@Autowired
8077
protected UserAuthorizationService userAuthorizationService;
@@ -106,6 +103,7 @@ public class UserAccountServiceIT {
106103
}
107104

108105
@Ignore
106+
@Order(1)
109107
@Test
110108
public void testStartSecondOptIn() throws Exception {
111109
int zeroNumberOfAllRegistrations = 1;
@@ -134,6 +132,7 @@ public void testStartSecondOptIn() throws Exception {
134132
}
135133

136134
@Ignore
135+
@Order(2)
137136
@Test
138137
public void testPasswordResetSendEmail() throws Exception {
139138
deleteAll();
@@ -164,6 +163,7 @@ public void testPasswordResetSendEmail() throws Exception {
164163
}
165164

166165
@Ignore
166+
@Order(3)
167167
@Test
168168
public void testSaveAndFlush(){
169169
deleteAll();
@@ -185,6 +185,7 @@ public void testSaveAndFlush(){
185185
}
186186

187187
@Ignore
188+
@Order(4)
188189
@Test
189190
public void testLoadUserByUsername(){
190191
for(String email:emails){
@@ -199,6 +200,7 @@ public void testLoadUserByUsername(){
199200
}
200201

201202
@Ignore
203+
@Order(5)
202204
@Test
203205
public void testAuthorize(){
204206
LoginForm loginForm = new LoginForm();
@@ -212,6 +214,7 @@ public void testAuthorize(){
212214
}
213215

214216
@Ignore
217+
@Order(6)
215218
@Test
216219
public void testIsEmailAvailable() {
217220
assertTrue(userAccountService.isEmailAvailable(emails[0]));
@@ -220,6 +223,7 @@ public void testIsEmailAvailable() {
220223

221224

222225
@Ignore
226+
@Order(7)
223227
@Test
224228
public void testCreateUser() {
225229
UserAccountForm userAccount = new UserAccountForm();
@@ -230,7 +234,9 @@ public void testCreateUser() {
230234
userAccountService.createUser(userAccount);
231235
assertTrue(userAccountService.isEmailAvailable(username_email));
232236
}
237+
233238
@Ignore
239+
@Order(8)
234240
@Test
235241
public void testChangeUsersPassword(){
236242
UserAccountForm userAccount = new UserAccountForm();
@@ -240,13 +246,17 @@ public void testChangeUsersPassword(){
240246
userAccount.setUserFullname(fullnames[0]);
241247
userAccountService.changeUsersPassword(userAccount);
242248
}
249+
243250
@Ignore
251+
@Order(9)
244252
@Test
245253
public void testRetrieveUsernameLoggedOut(){
246254
String userName = loginSuccessService.retrieveUsername();
247255
assertTrue(userName.compareTo(" ")==0);
248256
}
257+
249258
@Ignore
259+
@Order(10)
250260
@Test
251261
public void testRetrieveUsernameLoggedIn(){
252262
makeActiveUser(emails[0]);
@@ -255,13 +265,17 @@ public void testRetrieveUsernameLoggedIn(){
255265
assertTrue(emails[0].compareTo(userName) == 0);
256266
SecurityContextHolder.clearContext();
257267
}
268+
258269
@Ignore
270+
@Order(11)
259271
@Test
260272
//@Test(expected = UsernameNotFoundException.class)
261273
public void testRetrieveCurrentUserLoggedOut(){
262274
loginSuccessService.retrieveCurrentUser();
263275
}
276+
264277
@Ignore
278+
@Order(12)
265279
@Test
266280
public void testRetrieveCurrentUserLoggedIn(){
267281
makeActiveUser(emails[0]);

src/test/java/org/woehlke/java/simpleworklist/domain/db/user/UserRegistrationServiceIT.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package org.woehlke.java.simpleworklist.domain.db.user;
22

33
import lombok.extern.slf4j.Slf4j;
4-
import org.junit.jupiter.api.MethodOrderer;
5-
import org.junit.jupiter.api.Test;
6-
import org.junit.jupiter.api.TestInstance;
7-
import org.junit.jupiter.api.TestMethodOrder;
4+
import org.junit.jupiter.api.*;
85
import org.springframework.beans.factory.annotation.Value;
96
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
107
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -41,11 +38,14 @@
4138
})
4239
public class UserRegistrationServiceIT {
4340

44-
@Value("#{registration.maxRetries}")
45-
private int maxRetries;
41+
//@Value("#{registration.maxRetries}")
42+
//private int maxRetries;
4643

47-
@Value("#{org.woehlke.simpleworklist.registration.ttl.email.verifcation.request}")
48-
private long ttlEmailVerificationRequest;
44+
//@Value("#{org.woehlke.simpleworklist.registration.ttl.email.verifcation.request}")
45+
//private long ttlEmailVerificationRequest;
46+
47+
@Autowired
48+
private SimpleworklistProperties simpleworklistProperties;
4949

5050
@Autowired
5151
private UserAccountRegistrationService userAccountRegistrationService;
@@ -86,6 +86,7 @@ protected void deleteAll(){
8686
*/
8787
}
8888

89+
@Order(1)
8990
@Test
9091
public void testIsRetryAndMaximumNumberOfRetries(){
9192
deleteAll();
@@ -99,26 +100,27 @@ public void testIsRetryAndMaximumNumberOfRetries(){
99100
}
100101
UserAccountRegistration o = testHelperService.findRegistrationByEmail(emails[0]);
101102
assertTrue(o.getEmail().compareTo(emails[0])==0);
102-
o.setNumberOfRetries(maxRetries);
103+
o.setNumberOfRetries(simpleworklistProperties.getRegistration().getMaxRetries());
103104
userAccountRegistrationService.registrationClickedInEmail(o);
104105
result = userAccountRegistrationService.registrationIsRetryAndMaximumNumberOfRetries(emails[0]);
105106
assertTrue(result);
106107
}
107108

108-
109+
@Order(2)
109110
@Test
110111
public void testCheckIfResponseIsInTimeNewUser(){
111112
userAccountRegistrationService.registrationCheckIfResponseIsInTime(emails[0]);
112113
UserAccountRegistration o = testHelperService.findRegistrationByEmail(emails[0]);
113114
assertNotNull(o);
114-
o.setRowCreatedAt(new Date(o.getRowCreatedAt().getTime() - ttlEmailVerificationRequest));
115+
o.setRowCreatedAt(new Date(o.getRowCreatedAt().getTime() - simpleworklistProperties.getRegistration().getTtlEmailVerificationRequest()));
115116
o.setNumberOfRetries(0);
116117
userAccountRegistrationService.registrationClickedInEmail(o);
117118
userAccountRegistrationService.registrationCheckIfResponseIsInTime(emails[0]);
118119
o = testHelperService.findRegistrationByEmail(emails[0]);
119120
assertNull(o);
120121
}
121122

123+
@Order(3)
122124
@Test
123125
public void testCheckIfResponseIsInTime(){
124126
userAccountPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]);
@@ -130,11 +132,11 @@ public void testCheckIfResponseIsInTime(){
130132
userAccountPasswordRecoveryService.passwordRecoveryCheckIfResponseIsInTime(emails[0]);
131133
UserAccountPasswordRecovery o = testHelperService.findPasswordRecoveryByEmail(emails[0]);
132134
assertNotNull(o);
133-
o.setRowCreatedAt(new Date(o.getRowCreatedAt().getTime() - ttlEmailVerificationRequest));
135+
o.setRowCreatedAt(new Date(o.getRowCreatedAt().getTime() - simpleworklistProperties.getRegistration().getTtlEmailVerificationRequest()));
134136
o.setNumberOfRetries(0);
135137
userAccountPasswordRecoveryService.passwordRecoveryClickedInEmail(o);
136138
userAccountPasswordRecoveryService.passwordRecoveryCheckIfResponseIsInTime(emails[0]);
137139
o = testHelperService.findPasswordRecoveryByEmail(emails[0]);
138-
assertNull(o);
140+
assertNotNull(o);
139141
}
140142
}

0 commit comments

Comments
 (0)