Skip to content

Commit f812399

Browse files
committed
work: Unit Tests and Integration Tests
1 parent bb1eb6e commit f812399

File tree

5 files changed

+31
-28
lines changed

5 files changed

+31
-28
lines changed

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

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

33

44
import lombok.extern.slf4j.Slf4j;
5+
import org.junit.jupiter.api.Test;
56
import org.springframework.boot.test.context.SpringBootTest;
67
import org.springframework.security.crypto.password.PasswordEncoder;
78
import org.woehlke.java.simpleworklist.config.AbstractIntegrationTest;
@@ -20,15 +21,15 @@ public class UserAccountPasswordEncodedIntegrationTest extends AbstractIntegrati
2021
@Autowired
2122
private PasswordEncoder encoder;
2223

23-
//@Test
24+
@Test
2425
public void testEncoderIsWired(){
2526
assertTrue(encoder != null);
2627
}
2728

2829
/**
2930
* This Test is obsolete now due to changed encoder from MD5 to BCrypt (20.02.2016).
3031
*/
31-
//@Test
32+
@Test
3233
public void testGetUserPasswordEncoded(){
3334
UserAccountForm u = new UserAccountForm();
3435
u.setUserEmail("test01//@Test.de");
@@ -39,7 +40,7 @@ public void testGetUserPasswordEncoded(){
3940
assertTrue(encodedPassword.compareTo(encoder.encode(u.getUserPassword()))==0);
4041
}
4142

42-
//@Test
43+
@Test
4344
public void testPasswordsAreTheSame(){
4445
UserAccountForm u = new UserAccountForm();
4546
u.setUserEmail("test01//@Test.de");

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

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

33
import lombok.extern.slf4j.Slf4j;
4+
import org.junit.jupiter.api.Test;
45
import org.springframework.beans.factory.annotation.Autowired;
56
import org.springframework.boot.test.context.SpringBootTest;
67
import org.woehlke.java.simpleworklist.config.AbstractIntegrationTest;
7-
import org.woehlke.java.simpleworklist.domain.db.user.UserAccountPasswordRecovery;
88
import org.woehlke.java.simpleworklist.domain.db.user.passwordrecovery.UserAccountPasswordRecoveryService;
99
import org.woehlke.java.simpleworklist.domain.db.user.passwordrecovery.UserAccountPasswordRecoveryStatus;
1010

@@ -23,21 +23,21 @@ public class UserAccountPasswordRecoveryServiceIT extends AbstractIntegrationTes
2323
@Autowired
2424
private UserAccountPasswordRecoveryService userAccountPasswordRecoveryService;
2525

26-
//@Test
26+
@Test
2727
public void testResetPassword() throws Exception {
2828
this.mockMvc.perform(
2929
get("/user/resetPassword")).andDo(print())
3030
.andExpect(view().name(containsString("user/resetPassword/resetPasswordForm")));
3131
}
3232

33-
//@Test
33+
@Test
3434
public void testEnterNewPasswordFormular() throws Exception {
3535
this.mockMvc.perform(
3636
get("/user/resetPassword/confirm/ASDF")).andDo(print())
3737
.andExpect(view().name(containsString("user/resetPassword/resetPasswordNotConfirmed")));
3838
}
3939

40-
//@Test
40+
@Test
4141
public void testEnterNewPasswordFormularWithToken() throws Exception {
4242
userAccountPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]);
4343
try {
@@ -58,7 +58,7 @@ public void testEnterNewPasswordFormularWithToken() throws Exception {
5858
userAccountPasswordRecoveryService.passwordRecoveryDone(o);
5959
}
6060

61-
//@Test
61+
@Test
6262
public void finish(){
6363
super.deleteAll();
6464
}

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

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

33
import lombok.extern.slf4j.Slf4j;
4+
import org.junit.jupiter.api.Test;
45
import org.springframework.beans.factory.annotation.Autowired;
56

67

@@ -11,7 +12,6 @@
1112
import org.springframework.security.core.userdetails.UserDetails;
1213
import org.springframework.security.core.userdetails.UsernameNotFoundException;
1314
import org.woehlke.java.simpleworklist.config.AbstractIntegrationTest;
14-
import org.woehlke.java.simpleworklist.domain.db.user.UserAccount;
1515
import org.woehlke.java.simpleworklist.domain.db.user.account.UserAccountForm;
1616
import org.woehlke.java.simpleworklist.domain.db.user.passwordrecovery.UserAccountPasswordRecoveryService;
1717
import org.woehlke.java.simpleworklist.domain.db.user.signup.UserAccountRegistrationService;
@@ -30,7 +30,7 @@ public class UserAccountServiceIT extends AbstractIntegrationTest {
3030
@Autowired
3131
private UserAccountPasswordRecoveryService userAccountPasswordRecoveryService;
3232

33-
//@Test
33+
@Test
3434
public void testStartSecondOptIn() throws Exception {
3535
int zeroNumberOfAllRegistrations = 0;
3636
deleteAll();
@@ -57,7 +57,7 @@ public void testStartSecondOptIn() throws Exception {
5757
assertEquals(zeroNumberOfAllRegistrations, testHelperService.getNumberOfAllRegistrations());
5858
}
5959

60-
//@Test
60+
@Test
6161
public void testPasswordResetSendEmail() throws Exception {
6262
deleteAll();
6363
for(UserAccount userAccount:testUser){
@@ -86,7 +86,7 @@ public void testPasswordResetSendEmail() throws Exception {
8686
assertEquals(zeroNumberOfAllRegistrations, testHelperService.getNumberOfAllRegistrations());
8787
}
8888

89-
//@Test
89+
@Test
9090
public void testSaveAndFlush(){
9191
deleteAll();
9292
for(UserAccount userAccount:testUser){
@@ -106,7 +106,7 @@ public void testSaveAndFlush(){
106106
}
107107
}
108108

109-
//@Test
109+
@Test
110110
public void testLoadUserByUsername(){
111111
for(String email:emails){
112112
UserDetails userDetails = applicationUserDetailsService.loadUserByUsername(email);
@@ -120,7 +120,7 @@ public void testLoadUserByUsername(){
120120
}
121121
}
122122

123-
//@Test
123+
@Test
124124
public void testAuthorize(){
125125
LoginForm loginForm = new LoginForm();
126126
loginForm.setUserEmail(emails[0]);
@@ -132,13 +132,13 @@ public void testAuthorize(){
132132
assertFalse(userAuthorizationService.authorize(loginForm));
133133
}
134134

135-
//@Test
135+
@Test
136136
public void testIsEmailAvailable() {
137137
assertFalse(userAccountService.isEmailAvailable(emails[0]));
138138
assertTrue(userAccountService.isEmailAvailable(username_email));
139139
}
140140

141-
//@Test
141+
@Test
142142
public void testCreateUser() {
143143
UserAccountForm userAccount = new UserAccountForm();
144144
userAccount.setUserEmail(username_email);
@@ -149,7 +149,7 @@ public void testCreateUser() {
149149
assertFalse(userAccountService.isEmailAvailable(username_email));
150150
}
151151

152-
//@Test
152+
@Test
153153
public void testChangeUsersPassword(){
154154
UserAccountForm userAccount = new UserAccountForm();
155155
userAccount.setUserEmail(emails[0]);
@@ -159,13 +159,13 @@ public void testChangeUsersPassword(){
159159
userAccountService.changeUsersPassword(userAccount);
160160
}
161161

162-
//@Test
162+
@Test
163163
public void testRetrieveUsernameLoggedOut(){
164164
String userName = loginSuccessService.retrieveUsername();
165165
assertTrue(userName.compareTo(" ")==0);
166166
}
167167

168-
//@Test
168+
@Test
169169
public void testRetrieveUsernameLoggedIn(){
170170
makeActiveUser(emails[0]);
171171
String userName = loginSuccessService.retrieveUsername();
@@ -174,13 +174,13 @@ public void testRetrieveUsernameLoggedIn(){
174174
SecurityContextHolder.clearContext();
175175
}
176176

177-
//@Test
178-
////@Test(expected = UsernameNotFoundException.class)
177+
@Test
178+
//@Test(expected = UsernameNotFoundException.class)
179179
public void testRetrieveCurrentUserLoggedOut(){
180180
loginSuccessService.retrieveCurrentUser();
181181
}
182182

183-
//@Test
183+
@Test
184184
public void testRetrieveCurrentUserLoggedIn(){
185185
makeActiveUser(emails[0]);
186186
UserAccount userAccount = loginSuccessService.retrieveCurrentUser();

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

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

33

44

5+
import org.junit.jupiter.api.Test;
56
import org.springframework.security.core.GrantedAuthority;
67
import org.woehlke.java.simpleworklist.domain.security.access.UserDetailsDto;
78

@@ -12,7 +13,7 @@
1213

1314
public class UserDetailsBeanUT {
1415

15-
//@Test
16+
@Test
1617
public void testGetAuthorities(){
1718
UserAccount account = new UserAccount();
1819
UserDetailsDto b = new UserDetailsDto(account);
@@ -23,7 +24,7 @@ public void testGetAuthorities(){
2324
}
2425
}
2526

26-
//@Test
27+
@Test
2728
public void testDefaultBooleans(){
2829
UserAccount account = new UserAccount();
2930
UserDetailsDto b = new UserDetailsDto(account);
@@ -33,7 +34,7 @@ public void testDefaultBooleans(){
3334
assertTrue(b.isEnabled());
3435
}
3536

36-
//@Test
37+
@Test
3738
public void testHashCodeAndEquals(){
3839
UserAccount account1 = new UserAccount();
3940
UserAccount account2 = new UserAccount();

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

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

33
import lombok.extern.slf4j.Slf4j;
4+
import org.junit.jupiter.api.Test;
45
import org.springframework.beans.factory.annotation.Value;
56
import org.springframework.boot.test.context.SpringBootTest;
67
import org.woehlke.java.simpleworklist.config.AbstractIntegrationTest;
@@ -29,7 +30,7 @@ public class UserRegistrationServiceIT extends AbstractIntegrationTest {
2930
@Autowired
3031
private UserAccountPasswordRecoveryService userAccountPasswordRecoveryService;
3132

32-
//@Test
33+
@Test
3334
public void testIsRetryAndMaximumNumberOfRetries(){
3435
deleteAll();
3536
boolean result = userAccountRegistrationService.registrationIsRetryAndMaximumNumberOfRetries(username_email);
@@ -49,7 +50,7 @@ public void testIsRetryAndMaximumNumberOfRetries(){
4950
}
5051

5152

52-
//@Test
53+
@Test
5354
public void testCheckIfResponseIsInTimeNewUser(){
5455
userAccountRegistrationService.registrationCheckIfResponseIsInTime(emails[0]);
5556
UserAccountRegistration o = testHelperService.findRegistrationByEmail(emails[0]);
@@ -62,7 +63,7 @@ public void testCheckIfResponseIsInTimeNewUser(){
6263
assertNull(o);
6364
}
6465

65-
//@Test
66+
@Test
6667
public void testCheckIfResponseIsInTime(){
6768
userAccountPasswordRecoveryService.passwordRecoverySendEmailTo(emails[0]);
6869
try {

0 commit comments

Comments
 (0)