Geeksforgeeks - Java Backend Development ((install)) -
@GetMapping("/id") public ResponseEntity<UserDto> getUser(@PathVariable Long id) return ResponseEntity.ok(userService.findById(id));
@ExtendWith(MockitoExtension.class) class UserServiceTest @Mock private UserRepository repo; @InjectMocks private UserService service; @Test void testGetUserById() when(repo.findById(1L)).thenReturn(Optional.of(new User())); assertNotNull(service.getUser(1L)); GeeksForGeeks - JAVA Backend Development