diff --git a/api/src/main/java/org/openmrs/module/emrapi/account/AccountDomainWrapper.java b/api/src/main/java/org/openmrs/module/emrapi/account/AccountDomainWrapper.java index 65bd40e42..c5c079b78 100644 --- a/api/src/main/java/org/openmrs/module/emrapi/account/AccountDomainWrapper.java +++ b/api/src/main/java/org/openmrs/module/emrapi/account/AccountDomainWrapper.java @@ -338,15 +338,7 @@ public void unlock() { } user.removeUserProperty(OpenmrsConstants.USER_PROPERTY_LOCKOUT_TIMESTAMP); user.removeUserProperty(OpenmrsConstants.USER_PROPERTY_LOGIN_ATTEMPTS); - - // hack to work-around change to service methods for saving users in Core 2.x - try { - Method saveUser = UserService.class.getDeclaredMethod("saveUser", User.class); - saveUser.invoke(userService, user); - } - catch (Exception e) { - userService.createUser(user, password); - }; + userService.saveUser(user); } public void save() { @@ -362,14 +354,7 @@ public void save() { userService.createUser(user, password); } else { - // hack to work-around change to service methods for saving users in Core 2.x - try { - Method saveUser = UserService.class.getDeclaredMethod("saveUser", User.class); - saveUser.invoke(userService, user); - } - catch (Exception e) { - userService.createUser(user, password); - } + userService.saveUser(user); } // the saveUser(user, password) method will *only* set a password for a new user, it won't change an existing one diff --git a/api/src/test/java/org/openmrs/module/emrapi/account/AccountDomainWrapperTest.java b/api/src/test/java/org/openmrs/module/emrapi/account/AccountDomainWrapperTest.java index c4dc38c73..582bb92d7 100644 --- a/api/src/test/java/org/openmrs/module/emrapi/account/AccountDomainWrapperTest.java +++ b/api/src/test/java/org/openmrs/module/emrapi/account/AccountDomainWrapperTest.java @@ -411,7 +411,7 @@ public void testUnlockingAccount() throws Exception { assertThat(account.getUser().getUserProperty(USER_PROPERTY_LOCKOUT_TIMESTAMP), is("")); assertThat(account.getUser().getUserProperty(USER_PROPERTY_LOGIN_ATTEMPTS), is("")); - verify(userService).createUser(account.getUser(), null); + verify(userService).saveUser(account.getUser()); } @@ -475,7 +475,7 @@ public void testSaveAccountWithPasswordChangeForExistingUser() throws Exception account.getUser().setUserId(1); // mimic making this user persistent account.save(); - verify(userService).createUser(account.getUser(), "abc"); + verify(userService).saveUser(account.getUser()); verify(userService).changePassword(account.getUser(), "abc"); }