Cześć, ostatnio zacząłem bawić się tworzeniem mikroserwisu do zarządzania userami w aplikacji. Korzystałem z tego poradnika
Problem polega na tym, że kod działa ale chce napisać do niego testy. Nie mam pojęcia jak zabrać się za napisanie testów do tego kontolera
Jak w tej metodzie zamokować klase oraz działanie Authentication?
@PostMapping("/login")
public ResponseEntity<?> authenticateUser(@Valid @RequestBody LoginRequest loginRequest) {
Authentication authentication = authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(
loginRequest.getEmail(),
loginRequest.getPassword()
)
);
SecurityContextHolder.getContext().setAuthentication(authentication);
String token = tokenProvider.createToken(authentication);
return ResponseEntity.ok(new AuthResponse(token));
}