@@ -119,7 +119,7 @@ public void changePasswordWithSuccess() throws Exception {
119119 .params (params ))
120120 .andExpect (status ().isOk ());
121121
122- User user = userRepository .getById (USERID_USER );
122+ User user = userRepository .findById (USERID_USER ). orElseThrow ( );
123123 assertEquals (user .getPassword (), "5c29a959abce4eda5f0e7a4e7ea53dce4fa0f0abbe8eaa63717e2fed5f193d31" );
124124 }
125125
@@ -367,7 +367,7 @@ public void changeUsernameWithWrongScope() throws Exception {
367367
368368 @ Test
369369 public void changeUsernameSuccess () throws Exception {
370- assertThat (userRepository .getById ( 1 ).getLogin (), is (AUTH_USER ));
370+ assertThat (userRepository .findById ( 1 ). orElseThrow ( ).getLogin (), is (AUTH_USER ));
371371
372372 MultiValueMap <String , String > params = new HttpHeaders ();
373373 params .add ("newUsername" , NEW_USER );
@@ -378,12 +378,12 @@ public void changeUsernameSuccess() throws Exception {
378378 .params (params ))
379379 .andExpect (status ().isOk ());
380380
381- assertThat (userRepository .getById ( 1 ).getLogin (), is (NEW_USER ));
381+ assertThat (userRepository .findById ( 1 ). orElseThrow ( ).getLogin (), is (NEW_USER ));
382382 }
383383
384384 @ Test
385385 public void changeUsernameForcedByUser () throws Exception {
386- assertThat (userRepository .getById ( 1 ).getLogin (), is (AUTH_USER ));
386+ assertThat (userRepository .findById ( 1 ). orElseThrow ( ).getLogin (), is (AUTH_USER ));
387387
388388 MultiValueMap <String , String > params = new HttpHeaders ();
389389 params .add ("newUsername" , NEW_USER );
@@ -395,7 +395,7 @@ public void changeUsernameForcedByUser() throws Exception {
395395 .andExpect (status ().is4xxClientError ())
396396 .andReturn ();
397397
398- assertThat (userRepository .getById ( 1 ).getLogin (), is (not (NEW_USER )));
398+ assertThat (userRepository .findById ( 1 ). orElseThrow ( ).getLogin (), is (not (NEW_USER )));
399399 }
400400
401401 @ Test
@@ -409,7 +409,7 @@ public void changeUsernameForcedByModerator() throws Exception {
409409 .params (params ))
410410 .andExpect (status ().isOk ());
411411
412- assertThat (userRepository .getById ( 2 ).getLogin (), is (NEW_USER ));
412+ assertThat (userRepository .findById ( 2 ). orElseThrow ( ).getLogin (), is (NEW_USER ));
413413 }
414414
415415 @ Test
@@ -438,7 +438,7 @@ public void changeUsernameForcedByModeratorWithoutRole() throws Exception {
438438
439439 @ Test
440440 public void changeUsernameTooEarly () throws Exception {
441- assertThat (userRepository .getById ( 2 ).getLogin (), is (AUTH_MODERATOR ));
441+ assertThat (userRepository .findById ( 2 ). orElseThrow ( ).getLogin (), is (AUTH_MODERATOR ));
442442
443443 MultiValueMap <String , String > params = new HttpHeaders ();
444444 params .add ("newUsername" , NEW_USER );
@@ -452,7 +452,7 @@ public void changeUsernameTooEarly() throws Exception {
452452
453453 assertApiError (result , ErrorCode .USERNAME_CHANGE_TOO_EARLY );
454454
455- assertThat (userRepository .getById ( 2 ).getLogin (), is (AUTH_MODERATOR ));
455+ assertThat (userRepository .findById ( 2 ). orElseThrow ( ).getLogin (), is (AUTH_MODERATOR ));
456456 }
457457
458458 @ Test
@@ -467,7 +467,7 @@ public void changeUsernameTooEarlyButForced() throws Exception {
467467 .andExpect (status ().isOk ())
468468 .andReturn ();
469469
470- assertThat (userRepository .getById ( 2 ).getLogin (), is (NEW_USER ));
470+ assertThat (userRepository .findById ( 2 ). orElseThrow ( ).getLogin (), is (NEW_USER ));
471471 }
472472
473473 @ Test
0 commit comments