Skip to content

Commit

Permalink
Unit test fixes following upgrade to depend on 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mseaton committed May 5, 2024
1 parent 543161a commit 48c08bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}


Expand Down Expand Up @@ -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");
}

Expand Down

0 comments on commit 48c08bf

Please sign in to comment.