Signup method using API and spring boot JWT

hi! I’m using spring boot and JWT for authentication & authorization so I faced a problem when I’m testing signup method it returns “role not found” even the variable is not null it contains the role name but exception stoped the registration, please can someone help me.
Auth.controller

@PostMapping("/signup")
    public ResponseEntity<?> registerUser(@Valid @RequestBody RegistrationForm signUpRequest) {
       if (utilisateurRepository.existsByUsername(signUpRequest.getUsername())) {
            return ResponseEntity
                    .badRequest()
                    .body("Error: Username is already taken!");
        }

        if (utilisateurRepository.existsByEmail(signUpRequest.getEmail())) {
            return ResponseEntity
                    .badRequest()
                    .body("Error: Email is already in use!");
        }
        // Create new user's account
        Utilisateur user = new Utilisateur(signUpRequest.getUsername(),
                signUpRequest.getEmail(),
                passwordEncoder.encode(signUpRequest.getPassword()));

        Set<String> strRoles = signUpRequest.getRoles();
        Set<Role> roles = new HashSet<>();

        if (strRoles == null) {
            Role userRole = roleRepository.findByName(ERole.ROLE_USER)
                    .orElseThrow(() -> new RuntimeException("Error: Role is not found0."));
            roles.add(userRole);
        } else {
            strRoles.forEach(role -> {
                switch (role) {
                    case "ADMIN":
                        Role adminRole = roleRepository.findByName(ERole.ROLE_ADMIN)
                                .orElseThrow(() -> new RuntimeException("Error: Role is not found."));
                        roles.add(adminRole);

                        break;
                    case "MEDECIN":
                        Role medRole = roleRepository.findByName(ERole.ROLE_MEDECIN)
                                .orElseThrow(() -> new RuntimeException("Error: Role is not found."));
                        roles.add(medRole);

                        break;

                    case "PATIENT":
                        Role patRole = roleRepository.findByName(ERole.ROLE_PATIENT)
                                .orElseThrow(() -> new RuntimeException("Error: Role is not found."));
                        roles.add(patRole);

                        break;


                    case "ASSISTANT":
                        Role assisRole = roleRepository.findByName(ERole.ROLE_ASSISTANT)
                                .orElseThrow(() -> new RuntimeException("Error: Role is not found."));
                        roles.add(assisRole);

                        break;
                    default:
                        Role aideRole = roleRepository.findByName(ERole.ROLE_AIDESOIGNANTE )
                                .orElseThrow(() -> new RuntimeException("Error: Role is not found."));
                        roles.add(aideRole);
                }
            });
        }

        user.setRoles(roles);
        utilisateurRepository.save(user);

        return ResponseEntity.ok("User registered successfully!");
    }

Registrationform.Model

public class RegistrationForm {


    @Size(min = 3, max = 20)
    private String username;


    @Size(max = 50)
    @Email
    private String email;


    private Set<String> roles;


    @Size(min = 6, max = 40)
    private String password;
}

Role.Model

@Document(collection = "roles")
public class Role {

    @Id
    private String id;
    private ERole name;
}

Results.postman

{
    "timestamp": "2020-04-10T19:22:17.657+0000",
    "status": 500,
    "error": "Internal Server Error",
    "message": "Error: Role is not found.",
    "trace": "java.lang.RuntimeException: Error: Role is not found.\r\n\tat com.suivi.app.Controller.UtilisateurController.lambda$null$1(UtilisateurController.java:156)\r\n\tat java.util.Optional.orElseThrow(Optional.java:290)\r\n\tat

Habe das gleiche Problem , Wurde das schon gelöst?

[quote=“kindtaher, post:1, topic:40858”]
I removed the line 14 (Utilisateur user = new…) Before I set roles & save userRepositories I added this line I hope that help you

 // Create new user's account
        Utilisateur user = new Utilisateur(signUpRequest.getUsername(),
                signUpRequest.getEmail(),
                passwordEncoder.encode(signUpRequest.getPassword()));

Plz elaborate, i am having the same prb