Exemplo n.º 1
0
 @RequestMapping(value = "/users", method = RequestMethod.POST)
 public ResponseEntity<User> createUser(@RequestBody User user) {
   HttpStatus status = HttpStatus.OK;
   if (!userRepository.exists(user.getEmail())) {
     status = HttpStatus.CREATED;
   }
   User saved = userRepository.save(user);
   return new ResponseEntity<>(saved, status);
 }
Exemplo n.º 2
0
 @RequestMapping(value = "/user/{email}", method = RequestMethod.DELETE)
 public ResponseEntity<User> deleteUser(@PathVariable String email)
     throws EntityNotFoundException {
   userRepository.delete(email);
   return new ResponseEntity<>(HttpStatus.OK);
 }
Exemplo n.º 3
0
 @RequestMapping(value = "/user/{email}", method = RequestMethod.PUT)
 public ResponseEntity<User> updateUser(@PathVariable String email, @RequestBody User user)
     throws EntityNotFoundException {
   User saved = userRepository.update(email, user);
   return new ResponseEntity<>(saved, HttpStatus.OK);
 }
Exemplo n.º 4
0
 @RequestMapping(value = "/users", method = RequestMethod.GET)
 public List<User> findAll() {
   return userRepository.findAll();
 }
 @Before
 public void setup() {
   this.mockMvc =
       MockMvcBuilders.webAppContextSetup(this.wac).addFilter(springSecurityFilter).build();
   userRepository.reset(new User("*****@*****.**"));
 }