Skip to content

Commit

Permalink
UserController Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rhit-villencr committed Jan 29, 2025
1 parent cff7a04 commit 69ff7f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public ResponseEntity<?> registerUser(@RequestBody User user) {
// Return only username and userId
return ResponseEntity.ok(Map.of(
"email", user.getUsername(),
"name", user.getName() != null ? user.getName() : "",
"phone", user.getPhone() != null ? user.getPhone() : "",
"age", user.getAge() != null ? user.getAge() : ""
"name", "",
"phone", "",
"age", ""
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public void testLoginUser_Success() {
when(mockUser.getUsername()).thenReturn("test_username");
when(mockUser.getPassword()).thenReturn("test_password");
when(mockUser.getToken()).thenReturn("test_token");
when(mockUser.getName()).thenReturn("test_name");
when(mockUser.getPhone()).thenReturn("test_phone");
when(mockUser.getAge()).thenReturn("test_age");
when(userRepository.findByUsername("test_username")).thenReturn(Optional.of(mockUser));
when(authenticationManager.authenticate(any())).thenReturn(null);
when(userRepository.save(mockUser)).thenReturn(mockUser);
Expand Down

0 comments on commit 69ff7f0

Please sign in to comment.