File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
quiz-website/src/test/java/com/quizapp/controllerTests Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 1
1
package com .quizapp .controllerTests ;
2
2
3
3
import com .quizapp .model .User ;
4
+ import com .quizapp .repository .AnnouncementRepository ;
5
+ import com .quizapp .repository .ChallengeRepository ;
6
+ import com .quizapp .repository .FriendRequestRepository ;
4
7
import com .quizapp .repository .UserRepository ;
5
8
import com .quizapp .service .UserService ;
6
9
import org .junit .jupiter .api .BeforeEach ;
@@ -28,12 +31,24 @@ public class AuthRestControllerTest {
28
31
@ Autowired
29
32
private UserRepository userRepository ;
30
33
34
+ @ Autowired
35
+ private ChallengeRepository challengeRepository ;
36
+
37
+ @ Autowired
38
+ private FriendRequestRepository friendRequestRepository ;
39
+ @ Autowired
40
+ private AnnouncementRepository announcementRepository ;
41
+
31
42
private User testUser ;
32
43
33
44
@ BeforeEach
34
45
void setUp () {
35
46
userRepository .deleteAll ();
36
-
47
+ // Clear dependent tables first
48
+ challengeRepository .deleteAll ();
49
+ friendRequestRepository .deleteAll ();
50
+ announcementRepository .deleteAll ();
51
+
37
52
testUser = new User ();
38
53
testUser .setUsername ("testuser" );
39
54
testUser .setPasswordHash ("password" );
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ void searchUsers_ShouldReturnList() throws Exception {
100
100
mockMvc .perform (get ("/api/friends/search" )
101
101
.with (user (requester .getUsername ()).roles ("USER" ))
102
102
.param ("username" , "le" ))
103
- .andExpect (status ().isInternalServerError ());
103
+ .andExpect (status ().isOk ());
104
104
}
105
105
106
106
You can’t perform that action at this time.
0 commit comments