Commit 7603ab4d94a4d8adc0cd441290f590e94ed9ca56

Authored by Thomas Ziemer
1 parent 35cdab48

test: Tests (außer Delete-Tests) fertig gemacht

README.md
@@ -222,4 +222,14 @@ Quelle: https://tools.jboss.org/downloads/jbosstools/neon/4.4.3.Final.html @@ -222,4 +222,14 @@ Quelle: https://tools.jboss.org/downloads/jbosstools/neon/4.4.3.Final.html
222 222
223 ## Projekt verwenden 223 ## Projekt verwenden
224 224
225 -Beim Deployen des Projekts auf den Application Server wird automatisch der Benutzer "admin" mit dem Kennwort "admin" erstellt und diesem die Rolle "Adminrolle" zugewiesen. Mit ihm kann man sich anmelden und erste Übungen vornehmen.  
226 \ No newline at end of file 225 \ No newline at end of file
  226 +In der Entwicklungsumgebung:
  227 +
  228 +Beim Deployen des Projekts auf den Application Server wird durch einen Data Bootstrapping-Mechanismus automatisch der Benutzer "admin" mit dem Kennwort "admin" erstellt und diesem die Rolle "Adminrolle" zugewiesen. Mit ihm kann man sich anmelden und erste Übungen vornehmen. Hierzu verwendet man den REST-Client "Advanced Rest Client Application" für den Chrome Browser.
  229 +
  230 +Nach der Implementierung von JUnit-Tests auf der Kommandozeile:
  231 +
  232 +> mvn clean install
  233 +
  234 +Das Projekt wird gebaut und die Tests werden ausgeführt. Möchte man die Tests gelegentlich mal nicht ausführen, macht man:
  235 +
  236 +> mvn clean install -DskipTests
227 \ No newline at end of file 237 \ No newline at end of file
src/test/java/net/ziemers/swxercise/lg/user/service/UserServiceTest.java
1 package net.ziemers.swxercise.lg.user.service; 1 package net.ziemers.swxercise.lg.user.service;
2 2
3 import java.util.Arrays; 3 import java.util.Arrays;
  4 +import java.util.Collection;
4 import java.util.HashSet; 5 import java.util.HashSet;
5 import java.util.Set; 6 import java.util.Set;
6 import javax.inject.Inject; 7 import javax.inject.Inject;
@@ -27,6 +28,8 @@ import org.junit.runner.RunWith; @@ -27,6 +28,8 @@ import org.junit.runner.RunWith;
27 * To test classes in isolation we shouldn't be using their dependencies. 28 * To test classes in isolation we shouldn't be using their dependencies.
28 * Instead we should be using a mock. There are many mocking libraries out 29 * Instead we should be using a mock. There are many mocking libraries out
29 * there, however CDI-Unit has extra support for Mockito @Mock annotations. 30 * there, however CDI-Unit has extra support for Mockito @Mock annotations.
  31 + *
  32 + * Quelle: http://jglue.org/cdi-unit-user-guide/
30 */ 33 */
31 @RunWith(CdiRunner.class) 34 @RunWith(CdiRunner.class)
32 public class UserServiceTest extends JpaTestUtils { 35 public class UserServiceTest extends JpaTestUtils {
@@ -42,6 +45,8 @@ public class UserServiceTest extends JpaTestUtils { @@ -42,6 +45,8 @@ public class UserServiceTest extends JpaTestUtils {
42 45
43 private boolean actual; 46 private boolean actual;
44 47
  48 + private Collection<User> actualUsers;
  49 +
45 private User actualUser; 50 private User actualUser;
46 51
47 @Inject 52 @Inject
@@ -65,10 +70,11 @@ public class UserServiceTest extends JpaTestUtils { @@ -65,10 +70,11 @@ public class UserServiceTest extends JpaTestUtils {
65 /* 70 /*
66 * In order to inject @SessionScoped beans, one has to annotate the function or class with @InRequestScope 71 * In order to inject @SessionScoped beans, one has to annotate the function or class with @InRequestScope
67 * as only this annotation guarantees to have the session scope active always. 72 * as only this annotation guarantees to have the session scope active always.
  73 + * Quelle: https://github.com/BrynCooke/cdi-unit/issues/82
68 */ 74 */
69 @Test 75 @Test
70 @InRequestScope 76 @InRequestScope
71 - public void testLoginUserReturnsSuccess() { 77 + public void testLoginUserSucceeds() {
72 78
73 given() 79 given()
74 .userDto(EXISTING_USERNAME_TEST); 80 .userDto(EXISTING_USERNAME_TEST);
@@ -77,12 +83,12 @@ public class UserServiceTest extends JpaTestUtils { @@ -77,12 +83,12 @@ public class UserServiceTest extends JpaTestUtils {
77 .loginUser(EXISTING_PASSWORD_TEST); 83 .loginUser(EXISTING_PASSWORD_TEST);
78 84
79 then() 85 then()
80 - .assertLoginSuccess(); 86 + .assertLoginUserSucceeded();
81 } 87 }
82 88
83 @Test 89 @Test
84 @InRequestScope 90 @InRequestScope
85 - public void testLogoutUserSuccess() { 91 + public void testLogoutUserSucceeds() {
86 92
87 given() 93 given()
88 .userDto(EXISTING_USERNAME_TEST) 94 .userDto(EXISTING_USERNAME_TEST)
@@ -92,22 +98,22 @@ public class UserServiceTest extends JpaTestUtils { @@ -92,22 +98,22 @@ public class UserServiceTest extends JpaTestUtils {
92 .logoutUser(); 98 .logoutUser();
93 99
94 then() 100 then()
95 - .assertLogoutSuccess(); 101 + .assertLogoutUserSucceeded();
96 } 102 }
97 103
98 @Test 104 @Test
99 - public void testFindUserById() { 105 + public void testFindUserByIdSucceeds() {
100 106
101 when() 107 when()
102 .findUser(EXISTING_USER_ID); 108 .findUser(EXISTING_USER_ID);
103 109
104 then() 110 then()
105 - .assertFindUserByIdSuccess(EXISTING_USER_ID); 111 + .assertFindUserByIdSucceeded(EXISTING_USER_ID);
106 } 112 }
107 113
108 @Test 114 @Test
109 @InRequestScope 115 @InRequestScope
110 - public void testFindUser() { 116 + public void testFindSessionUserSucceeds() {
111 117
112 given() 118 given()
113 .userDto(EXISTING_USERNAME_TEST) 119 .userDto(EXISTING_USERNAME_TEST)
@@ -117,16 +123,21 @@ public class UserServiceTest extends JpaTestUtils { @@ -117,16 +123,21 @@ public class UserServiceTest extends JpaTestUtils {
117 .findUser(); 123 .findUser();
118 124
119 then() 125 then()
120 - .assertFindUserByIdSuccess(EXISTING_USER_ID); 126 + .assertFindUserByIdSucceeded(EXISTING_USER_ID);
121 } 127 }
122 128
123 @Test 129 @Test
124 - public void testFindAllUsers() {  
125 - // TODO Test ist noch zu implementieren 130 + public void testFindAllUsersSucceeds() {
  131 +
  132 + when()
  133 + .findAllUsers();
  134 +
  135 + then()
  136 + .assertFindAllUsersSucceeded();
126 } 137 }
127 138
128 @Test 139 @Test
129 - public void testCreateUserReturnsSuccess() { 140 + public void testCreateUserSucceeds() {
130 141
131 given() 142 given()
132 .userDto(USERNAME_TEST); 143 .userDto(USERNAME_TEST);
@@ -135,11 +146,11 @@ public class UserServiceTest extends JpaTestUtils { @@ -135,11 +146,11 @@ public class UserServiceTest extends JpaTestUtils {
135 .createUser(); 146 .createUser();
136 147
137 then() 148 then()
138 - .assertCreateSuccess(); 149 + .assertCreateUserSucceeded();
139 } 150 }
140 151
141 @Test 152 @Test
142 - public void testCreateUserReturnsFailure() { 153 + public void testCreateAlreadyExistingUserFails() {
143 154
144 given() 155 given()
145 .userDto(EXISTING_USERNAME_TEST); 156 .userDto(EXISTING_USERNAME_TEST);
@@ -148,7 +159,7 @@ public class UserServiceTest extends JpaTestUtils { @@ -148,7 +159,7 @@ public class UserServiceTest extends JpaTestUtils {
148 .createUser(); 159 .createUser();
149 160
150 then() 161 then()
151 - .assertCreateFailure(); 162 + .assertCreateUserFailed();
152 } 163 }
153 164
154 @Test 165 @Test
@@ -161,49 +172,49 @@ public class UserServiceTest extends JpaTestUtils { @@ -161,49 +172,49 @@ public class UserServiceTest extends JpaTestUtils {
161 .updateUser(EXISTING_USER_ID); 172 .updateUser(EXISTING_USER_ID);
162 173
163 then() 174 then()
164 - .assertUpdateSuccess(); 175 + .assertUpdateUserSucceeded();
165 } 176 }
166 177
167 @Test 178 @Test
168 - public void testDeleteUserByIdReturnsSuccess() { 179 + public void testDeleteUserByIdSucceeds() {
169 // TODO Test ist noch zu implementieren 180 // TODO Test ist noch zu implementieren
170 } 181 }
171 182
172 @Test 183 @Test
173 - public void testDeleteUnknownUserByIdReturnsFailure() { 184 + public void testDeleteUnknownUserByIdFails() {
174 // TODO Test ist noch zu implementieren 185 // TODO Test ist noch zu implementieren
175 } 186 }
176 187
177 @Test 188 @Test
178 - public void testDeleteSessionUserReturnsSuccess() { 189 + public void testDeleteSessionUserSucceeds() {
179 // TODO Test ist noch zu implementieren 190 // TODO Test ist noch zu implementieren
180 } 191 }
181 192
182 @Test 193 @Test
183 @InRequestScope 194 @InRequestScope
184 - public void testIsNotLoggedInUserAllowedReturnsSuccess() { 195 + public void testIsNotLoggedInUserAllowedWithNotLoggedInRightSucceeds() {
185 196
186 when() 197 when()
187 .isUserAllowed(new HashSet<String>(Arrays.asList("NOT_LOGGED_IN"))); 198 .isUserAllowed(new HashSet<String>(Arrays.asList("NOT_LOGGED_IN")));
188 199
189 then() 200 then()
190 - .assertIsUserAllowedSuccess(); 201 + .assertIsUserAllowedSucceeded();
191 } 202 }
192 203
193 @Test 204 @Test
194 @InRequestScope 205 @InRequestScope
195 - public void testIsNotLoggedInUserAllowedReturnsFailure() { 206 + public void testIsNotLoggedInUserAllowedWithLoggedInRightFails() {
196 207
197 when() 208 when()
198 .isUserAllowed(new HashSet<String>(Arrays.asList("LOGGED_IN"))); 209 .isUserAllowed(new HashSet<String>(Arrays.asList("LOGGED_IN")));
199 210
200 then() 211 then()
201 - .assertIsUserAllowedFailure(); 212 + .assertIsUserAllowedFailed();
202 } 213 }
203 214
204 @Test 215 @Test
205 @InRequestScope 216 @InRequestScope
206 - public void testIsSessionUserAllowedReturnsSuccess() { 217 + public void testIsSessionUserAllowedWithLoggedInRightSucceeds() {
207 218
208 given() 219 given()
209 .userDto(EXISTING_USERNAME_TEST) 220 .userDto(EXISTING_USERNAME_TEST)
@@ -213,12 +224,27 @@ public class UserServiceTest extends JpaTestUtils { @@ -213,12 +224,27 @@ public class UserServiceTest extends JpaTestUtils {
213 .isUserAllowed(new HashSet<String>(Arrays.asList("LOGGED_IN"))); 224 .isUserAllowed(new HashSet<String>(Arrays.asList("LOGGED_IN")));
214 225
215 then() 226 then()
216 - .assertIsUserAllowedSuccess(); 227 + .assertIsUserAllowedSucceeded();
217 } 228 }
218 229
219 @Test 230 @Test
220 @InRequestScope 231 @InRequestScope
221 - public void testIsAdminUserAllowedReturnsSuccess() { 232 + public void testIsSessionUserAllowedWithNotLoggedInRightFails() {
  233 +
  234 + given()
  235 + .userDto(EXISTING_USERNAME_TEST)
  236 + .loginUser(EXISTING_PASSWORD_TEST);
  237 +
  238 + when()
  239 + .isUserAllowed(new HashSet<String>(Arrays.asList("NOT_LOGGED_IN")));
  240 +
  241 + then()
  242 + .assertIsUserAllowedFailed();
  243 + }
  244 +
  245 + @Test
  246 + @InRequestScope
  247 + public void testIsAdminUserAllowedWithAdminRightSucceeds() {
222 248
223 given() 249 given()
224 .userDto(EXISTING_USERNAME_TEST) 250 .userDto(EXISTING_USERNAME_TEST)
@@ -228,12 +254,12 @@ public class UserServiceTest extends JpaTestUtils { @@ -228,12 +254,12 @@ public class UserServiceTest extends JpaTestUtils {
228 .isUserAllowed(new HashSet<String>(Arrays.asList("ADMIN"))); 254 .isUserAllowed(new HashSet<String>(Arrays.asList("ADMIN")));
229 255
230 then() 256 then()
231 - .assertIsUserAllowedSuccess(); 257 + .assertIsUserAllowedSucceeded();
232 } 258 }
233 259
234 @Test 260 @Test
235 @InRequestScope 261 @InRequestScope
236 - public void testIsUserWithUnknownRoleAllowedReturnsFailure() { 262 + public void testIsUserWithUnknownRoleAllowedFails() {
237 263
238 given() 264 given()
239 .userDto(EXISTING_USERNAME_TEST) 265 .userDto(EXISTING_USERNAME_TEST)
@@ -243,7 +269,7 @@ public class UserServiceTest extends JpaTestUtils { @@ -243,7 +269,7 @@ public class UserServiceTest extends JpaTestUtils {
243 .isUserAllowed(new HashSet<String>(Arrays.asList("UNKNOWN_ROLE"))); 269 .isUserAllowed(new HashSet<String>(Arrays.asList("UNKNOWN_ROLE")));
244 270
245 then() 271 then()
246 - .assertIsUserAllowedFailure(); 272 + .assertIsUserAllowedFailed();
247 } 273 }
248 274
249 // given 275 // given
@@ -302,6 +328,11 @@ public class UserServiceTest extends JpaTestUtils { @@ -302,6 +328,11 @@ public class UserServiceTest extends JpaTestUtils {
302 return this; 328 return this;
303 } 329 }
304 330
  331 + private UserServiceTest findAllUsers() {
  332 + actualUsers = underTest.findAllUsers();
  333 + return this;
  334 + }
  335 +
305 private UserServiceTest isUserAllowed(final Set<String> rightsSet) { 336 private UserServiceTest isUserAllowed(final Set<String> rightsSet) {
306 actual = underTest.isUserAllowed(rightsSet); 337 actual = underTest.isUserAllowed(rightsSet);
307 return this; 338 return this;
@@ -313,44 +344,50 @@ public class UserServiceTest extends JpaTestUtils { @@ -313,44 +344,50 @@ public class UserServiceTest extends JpaTestUtils {
313 return this; 344 return this;
314 } 345 }
315 346
316 - private void assertLoginSuccess() { 347 + private void assertLoginUserSucceeded() {
317 // die Login-Methode lieferte Erfolg zurück, und es gibt einen angemeldeten Benutzer 348 // die Login-Methode lieferte Erfolg zurück, und es gibt einen angemeldeten Benutzer
318 assertTrue(actual); 349 assertTrue(actual);
319 assertNotNull(sessionContext.getUser()); 350 assertNotNull(sessionContext.getUser());
320 } 351 }
321 352
322 - private void assertLogoutSuccess() { 353 + private void assertLogoutUserSucceeded() {
323 // die Logout-Methode lieferte Erfolg zurück, und es gibt keinen angemeldeten Benutzer 354 // die Logout-Methode lieferte Erfolg zurück, und es gibt keinen angemeldeten Benutzer
324 assertTrue(actual); 355 assertTrue(actual);
325 assertNull(sessionContext.getUser()); 356 assertNull(sessionContext.getUser());
326 } 357 }
327 358
328 - private void assertFindUserByIdSuccess(final Long expectedId) { 359 + private void assertFindUserByIdSucceeded(final Long expectedId) {
329 assertEquals(expectedId, actualUser.getId()); 360 assertEquals(expectedId, actualUser.getId());
330 } 361 }
331 362
332 - private void assertCreateSuccess() { 363 + private void assertFindAllUsersSucceeded() {
  364 + // in unseren Testdaten befinden sich zwei Benutzer
  365 + final int EXISTING_USERS_COUNT = 2;
  366 + assertEquals(EXISTING_USERS_COUNT, actualUsers.size());
  367 + }
  368 +
  369 + private void assertCreateUserSucceeded() {
333 // wir suchen den soeben erstellten Benutzer; wenn er existiert, ist alles gut 370 // wir suchen den soeben erstellten Benutzer; wenn er existiert, ist alles gut
334 final User user = userDao.findByUsername(USERNAME_TEST); 371 final User user = userDao.findByUsername(USERNAME_TEST);
335 assertNotNull(user); 372 assertNotNull(user);
336 } 373 }
337 374
338 - private void assertCreateFailure() { 375 + private void assertCreateUserFailed() {
339 // es darf kein neuer Benutzer mit identischem Benutzernamen erstellt worden sein 376 // es darf kein neuer Benutzer mit identischem Benutzernamen erstellt worden sein
340 assertFalse(actual); 377 assertFalse(actual);
341 } 378 }
342 379
343 - private void assertUpdateSuccess() { 380 + private void assertUpdateUserSucceeded() {
344 // wir suchen den soeben aktualisierten Benutzer; wenn sein Benutzername unverändert ist, ist alles gut 381 // wir suchen den soeben aktualisierten Benutzer; wenn sein Benutzername unverändert ist, ist alles gut
345 final User user = userDao.findById(EXISTING_USER_ID); 382 final User user = userDao.findById(EXISTING_USER_ID);
346 assertEquals(EXISTING_USERNAME_TEST, user.getProfile().getUsername()); 383 assertEquals(EXISTING_USERNAME_TEST, user.getProfile().getUsername());
347 } 384 }
348 385
349 - private void assertIsUserAllowedSuccess() { 386 + private void assertIsUserAllowedSucceeded() {
350 assertTrue(actual); 387 assertTrue(actual);
351 } 388 }
352 389
353 - private void assertIsUserAllowedFailure() { 390 + private void assertIsUserAllowedFailed() {
354 assertFalse(actual); 391 assertFalse(actual);
355 } 392 }
356 393
src/test/java/net/ziemers/swxercise/ui/UserViewControllerTest.java
@@ -47,10 +47,13 @@ public class UserViewControllerTest { @@ -47,10 +47,13 @@ public class UserViewControllerTest {
47 private User actualUser; 47 private User actualUser;
48 48
49 @Test 49 @Test
50 - public void testJUnitFrameworkReturnsTrue() { 50 + public void testJUnitFrameworkSucceeds() {
51 assertTrue(true); 51 assertTrue(true);
52 } 52 }
53 53
  54 + /**
  55 + * Hier sieht man eine erwartete Exception
  56 + */
54 @Test(expected = AssertionError.class) 57 @Test(expected = AssertionError.class)
55 public void testJUnitFrameworkThrowsException() { 58 public void testJUnitFrameworkThrowsException() {
56 assertTrue(false); 59 assertTrue(false);
@@ -63,7 +66,7 @@ public class UserViewControllerTest { @@ -63,7 +66,7 @@ public class UserViewControllerTest {
63 .getAllUsers(); 66 .getAllUsers();
64 67
65 then() 68 then()
66 - .assertGetAllUsersSuccess(); 69 + .assertGetAllUsersSucceeded();
67 } 70 }
68 71
69 @Test 72 @Test
@@ -73,21 +76,21 @@ public class UserViewControllerTest { @@ -73,21 +76,21 @@ public class UserViewControllerTest {
73 .getUserById(EXISTING_USER_ID); 76 .getUserById(EXISTING_USER_ID);
74 77
75 then() 78 then()
76 - .assertGetUserByIdSuccess(); 79 + .assertGetUserByIdSucceeded();
77 } 80 }
78 81
79 @Test 82 @Test
80 - public void testGetSessionUserReturnsUserJson() { 83 + public void testGetSessionUserReturnsSessionUserJson() {
81 84
82 doing() 85 doing()
83 .getUser(); 86 .getUser();
84 87
85 then() 88 then()
86 - .assertGetUserSuccess(); 89 + .assertGetUserSucceeded();
87 } 90 }
88 91
89 @Test 92 @Test
90 - public void testCreateUserReturnsSuccess() { 93 + public void testCreateUserSucceeds() {
91 94
92 given() 95 given()
93 .userDto(); 96 .userDto();
@@ -96,11 +99,11 @@ public class UserViewControllerTest { @@ -96,11 +99,11 @@ public class UserViewControllerTest {
96 .createUser(true); 99 .createUser(true);
97 100
98 then() 101 then()
99 - .assertCreateSuccess(); 102 + .assertCreateUserSucceeded();
100 } 103 }
101 104
102 @Test 105 @Test
103 - public void testCreateUserReturnsFailure() { 106 + public void testCreateUserFails() {
104 107
105 given() 108 given()
106 .userDto(); 109 .userDto();
@@ -109,11 +112,11 @@ public class UserViewControllerTest { @@ -109,11 +112,11 @@ public class UserViewControllerTest {
109 .createUser(false); 112 .createUser(false);
110 113
111 then() 114 then()
112 - .assertCreateFailure(); 115 + .assertCreateUserFailed();
113 } 116 }
114 117
115 @Test 118 @Test
116 - public void testUpdateSessionUserReturnsSuccess() { 119 + public void testUpdateSessionUserSucceeds() {
117 120
118 given() 121 given()
119 .userDto(); 122 .userDto();
@@ -122,11 +125,11 @@ public class UserViewControllerTest { @@ -122,11 +125,11 @@ public class UserViewControllerTest {
122 .updateUser(); 125 .updateUser();
123 126
124 then() 127 then()
125 - .assertUpdateSuccess(); 128 + .assertUpdateUserSucceeded();
126 } 129 }
127 130
128 @Test 131 @Test
129 - public void testUpdateUserByIdReturnsSuccess() { 132 + public void testUpdateUserByIdSucceeds() {
130 133
131 given() 134 given()
132 .userDto(); 135 .userDto();
@@ -135,26 +138,26 @@ public class UserViewControllerTest { @@ -135,26 +138,26 @@ public class UserViewControllerTest {
135 .updateUser(EXISTING_USER_ID); 138 .updateUser(EXISTING_USER_ID);
136 139
137 then() 140 then()
138 - .assertUpdateSuccess(); 141 + .assertUpdateUserSucceeded();
139 } 142 }
140 143
141 @Test 144 @Test
142 - public void testDeleteUserByIdReturnsSuccess() { 145 + public void testDeleteUserByIdSucceeds() {
143 // TODO Test ist noch zu implementieren 146 // TODO Test ist noch zu implementieren
144 } 147 }
145 148
146 @Test 149 @Test
147 - public void testDeleteUnknownUserByIdReturnsFailure() { 150 + public void testDeleteUnknownUserByIdFails() {
148 // TODO Test ist noch zu implementieren 151 // TODO Test ist noch zu implementieren
149 } 152 }
150 153
151 @Test 154 @Test
152 - public void testDeleteSessionUserReturnsSuccess() { 155 + public void testDeleteSessionUserSucceeds() {
153 // TODO Test ist noch zu implementieren 156 // TODO Test ist noch zu implementieren
154 } 157 }
155 158
156 @Test 159 @Test
157 - public void testLoginUserReturnsSuccess() { 160 + public void testLoginUserSucceeds() {
158 161
159 given() 162 given()
160 .userDto(); 163 .userDto();
@@ -163,11 +166,11 @@ public class UserViewControllerTest { @@ -163,11 +166,11 @@ public class UserViewControllerTest {
163 .loginUser(true); 166 .loginUser(true);
164 167
165 then() 168 then()
166 - .assertLoginSuccess(); 169 + .assertLoginUserSucceeded();
167 } 170 }
168 171
169 @Test 172 @Test
170 - public void testLoginUserReturnsFailure() { 173 + public void testLoginUserFails() {
171 174
172 given() 175 given()
173 .userDto(); 176 .userDto();
@@ -176,17 +179,17 @@ public class UserViewControllerTest { @@ -176,17 +179,17 @@ public class UserViewControllerTest {
176 .loginUser(false); 179 .loginUser(false);
177 180
178 then() 181 then()
179 - .assertLoginFailure(); 182 + .assertLoginUserFailed();
180 } 183 }
181 184
182 @Test 185 @Test
183 - public void testLogoutUserReturnsSuccess() { 186 + public void testLogoutUserSucceeds() {
184 187
185 doing() 188 doing()
186 .logoutUser(); 189 .logoutUser();
187 190
188 then() 191 then()
189 - .assertLogoutSuccess(); 192 + .assertLogoutUserSucceeded();
190 } 193 }
191 194
192 // given 195 // given
@@ -264,45 +267,45 @@ public class UserViewControllerTest { @@ -264,45 +267,45 @@ public class UserViewControllerTest {
264 return this; 267 return this;
265 } 268 }
266 269
267 - private void assertCreateSuccess() { 270 + private void assertCreateUserSucceeded() {
268 final RestResponse expected = new RestResponse(); 271 final RestResponse expected = new RestResponse();
269 assertEquals(expected, actual); 272 assertEquals(expected, actual);
270 } 273 }
271 274
272 - private void assertCreateFailure() { 275 + private void assertCreateUserFailed() {
273 final RestResponse expected = new RestResponse(ResponseState.ALREADY_EXISTING); 276 final RestResponse expected = new RestResponse(ResponseState.ALREADY_EXISTING);
274 assertEquals(expected, actual); 277 assertEquals(expected, actual);
275 } 278 }
276 279
277 - private void assertGetAllUsersSuccess() { 280 + private void assertGetAllUsersSucceeded() {
278 final Collection<User> expectedCollection = new ArrayList<>(); 281 final Collection<User> expectedCollection = new ArrayList<>();
279 assertEquals(expectedCollection, actualCollection); 282 assertEquals(expectedCollection, actualCollection);
280 } 283 }
281 284
282 - private void assertGetUserByIdSuccess() { 285 + private void assertGetUserByIdSucceeded() {
283 assertEquals(USER_FIRSTNAME, actualUser.getFirstname()); 286 assertEquals(USER_FIRSTNAME, actualUser.getFirstname());
284 } 287 }
285 288
286 - private void assertGetUserSuccess() { 289 + private void assertGetUserSucceeded() {
287 assertEquals(USER_FIRSTNAME, actualUser.getFirstname()); 290 assertEquals(USER_FIRSTNAME, actualUser.getFirstname());
288 } 291 }
289 292
290 - private void assertUpdateSuccess() { 293 + private void assertUpdateUserSucceeded() {
291 final RestResponse expected = new RestResponse(); 294 final RestResponse expected = new RestResponse();
292 assertEquals(expected, actual); 295 assertEquals(expected, actual);
293 } 296 }
294 297
295 - private void assertLoginSuccess() { 298 + private void assertLoginUserSucceeded() {
296 final RestResponse expected = new RestResponse(); 299 final RestResponse expected = new RestResponse();
297 assertEquals(expected, actual); 300 assertEquals(expected, actual);
298 } 301 }
299 302
300 - private void assertLoginFailure() { 303 + private void assertLoginUserFailed() {
301 final RestResponse expected = new RestResponse(ResponseState.FAILED); 304 final RestResponse expected = new RestResponse(ResponseState.FAILED);
302 assertEquals(expected, actual); 305 assertEquals(expected, actual);
303 } 306 }
304 307
305 - private void assertLogoutSuccess() { 308 + private void assertLogoutUserSucceeded() {
306 final RestResponse expected = new RestResponse(); 309 final RestResponse expected = new RestResponse();
307 assertEquals(expected, actual); 310 assertEquals(expected, actual);
308 } 311 }
src/test/resources/net/ziemers/swxercise/testdata/UserServiceTestData.xml
@@ -7,4 +7,5 @@ @@ -7,4 +7,5 @@
7 <!-- das Kennwort ist "secret" --> 7 <!-- das Kennwort ist "secret" -->
8 <Profile id="1" role_id="4" username="username_profile" passwordHash="9EOZEsheQcXixUO/XW/vPwRlZh9NMyHppli2qKe3U9+Y0EHhtJU1AA56pkduCGsSbp8VZ7so/62+3cftxBhJGg==" hashAlgorithm="SHA512" salt="FuQll2Av59se1r1Dc4WEPDmzZw4="/> 8 <Profile id="1" role_id="4" username="username_profile" passwordHash="9EOZEsheQcXixUO/XW/vPwRlZh9NMyHppli2qKe3U9+Y0EHhtJU1AA56pkduCGsSbp8VZ7so/62+3cftxBhJGg==" hashAlgorithm="SHA512" salt="FuQll2Av59se1r1Dc4WEPDmzZw4="/>
9 <User id="2" firstname="firstname_user" lastname="lastname_user" profile_id="1"/> 9 <User id="2" firstname="firstname_user" lastname="lastname_user" profile_id="1"/>
  10 + <User id="5" firstname="firstname_user2" lastname="lastname_user2"/>
10 </dataset> 11 </dataset>