@Test void updateUser() { when(userMapper.toUserTO(any())).thenReturn(getUserTO(BRANCH)); when(userMgmtRestClient.getUser()).thenReturn(ResponseEntity.ok(getUserTO(BRANCH))); when(userMgmtStaffRestClient.modifyUser(any(), any())).thenReturn(ResponseEntity.ok(getUserTO(BRANCH))); ResponseEntity<Void> user = tppUsersController.updateUser(getUser(USER_ID)); assertTrue(user.getStatusCode().is2xxSuccessful()); }
@Override public ResponseEntity<Void> updateUser(User user) { if (StringUtils.isBlank(user.getId())) { throw new TppException("User id is not present in body!", 400); } String branch = Optional.ofNullable(userMgmtRestClient.getUser().getBody()) .map(UserTO::getBranch) .orElseThrow(() -> new TppException("No tpp code present!", 400)); UserTO userTO = userMapper.toUserTO(user); userTO.setBranch(branch); userMgmtStaffRestClient.modifyUser(branch, userTO); return new ResponseEntity<>(OK); }
TppUsersController implements TppUsersRestApi { @Override public ResponseEntity<Void> updateUser(User user) { if (StringUtils.isBlank(user.getId())) { throw new TppException("User id is not present in body!", 400); } String branch = Optional.ofNullable(userMgmtRestClient.getUser().getBody()) .map(UserTO::getBranch) .orElseThrow(() -> new TppException("No tpp code present!", 400)); UserTO userTO = userMapper.toUserTO(user); userTO.setBranch(branch); userMgmtStaffRestClient.modifyUser(branch, userTO); return new ResponseEntity<>(OK); } }
TppUsersController implements TppUsersRestApi { @Override public ResponseEntity<Void> updateUser(User user) { if (StringUtils.isBlank(user.getId())) { throw new TppException("User id is not present in body!", 400); } String branch = Optional.ofNullable(userMgmtRestClient.getUser().getBody()) .map(UserTO::getBranch) .orElseThrow(() -> new TppException("No tpp code present!", 400)); UserTO userTO = userMapper.toUserTO(user); userTO.setBranch(branch); userMgmtStaffRestClient.modifyUser(branch, userTO); return new ResponseEntity<>(OK); }  }
TppUsersController implements TppUsersRestApi { @Override public ResponseEntity<Void> updateUser(User user) { if (StringUtils.isBlank(user.getId())) { throw new TppException("User id is not present in body!", 400); } String branch = Optional.ofNullable(userMgmtRestClient.getUser().getBody()) .map(UserTO::getBranch) .orElseThrow(() -> new TppException("No tpp code present!", 400)); UserTO userTO = userMapper.toUserTO(user); userTO.setBranch(branch); userMgmtStaffRestClient.modifyUser(branch, userTO); return new ResponseEntity<>(OK); }  @Override ResponseEntity<UserTO> createUser(User user); @Override ResponseEntity<CustomPageImpl<UserTO>> getAllUsers(String queryParam, int page, int size); @Override ResponseEntity<Void> updateUser(User user); @Override ResponseEntity<UserTO> getUser(String userId); @Override ResponseEntity<UserTO> getSelf(); @Override ResponseEntity<Boolean> changeStatus(String userId); }
TppUsersController implements TppUsersRestApi { @Override public ResponseEntity<Void> updateUser(User user) { if (StringUtils.isBlank(user.getId())) { throw new TppException("User id is not present in body!", 400); } String branch = Optional.ofNullable(userMgmtRestClient.getUser().getBody()) .map(UserTO::getBranch) .orElseThrow(() -> new TppException("No tpp code present!", 400)); UserTO userTO = userMapper.toUserTO(user); userTO.setBranch(branch); userMgmtStaffRestClient.modifyUser(branch, userTO); return new ResponseEntity<>(OK); }  @Override ResponseEntity<UserTO> createUser(User user); @Override ResponseEntity<CustomPageImpl<UserTO>> getAllUsers(String queryParam, int page, int size); @Override ResponseEntity<Void> updateUser(User user); @Override ResponseEntity<UserTO> getUser(String userId); @Override ResponseEntity<UserTO> getSelf(); @Override ResponseEntity<Boolean> changeStatus(String userId);  }