use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class UserManagementServiceImplTest method testUpdatePassword.
@Test
public void testUpdatePassword() {
String credentials = "encryptedPassword";
Integer userId = 1;
UserDetail userDetail = mock(UserDetail.class);
UserIndex userIndex = mock(UserIndex.class);
UserRole userRole = mock(UserRole.class);
Set<UserIndex> userIndices = new HashSet<UserIndex>();
userIndices.add(userIndex);
Set<UserRole> userRoles = new HashSet<UserRole>();
userRoles.add(userRole);
when(userRole.getName()).thenReturn("ROLE_ADMINISTRATOR");
buildUserDetail(userId, userDetail, "password");
when(userService.getUserForId(userId)).thenReturn(user);
when(passwordEncoder.encodePassword("password", "admin")).thenReturn(credentials);
when(user.getUserIndices()).thenReturn(userIndices);
when(user.getRoles()).thenReturn(userRoles);
boolean success = service.updateUser(userDetail);
assertTrue("User's password updated successfully", success);
verify(passwordEncoder).encodePassword("password", "admin");
verify(authoritiesService, times(0)).getAdministratorRole();
verify(userDao).saveOrUpdateUser(user);
}
use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class ManageUsersAction method activateUser.
public String activateUser() {
UserDetail userDetail = gsonTool.readJson(new StringReader(userData), UserDetail.class);
boolean success = userManagementService.activateUser(userDetail);
if (success) {
updateUserMessage = "User activated successfully";
} else {
updateUserMessage = "Error activating user : '" + username + "'";
}
return "updateUser";
}
use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class ManageUsersAction method inactivateUser.
public String inactivateUser() {
UserDetail userDetail = gsonTool.readJson(new StringReader(userData), UserDetail.class);
boolean success = userManagementService.inactivateUser(userDetail);
if (success) {
updateUserMessage = "User inactivated successfully";
} else {
updateUserMessage = "Error inactivating user : '" + username + "'";
}
return "updateUser";
}
use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class ManageUsersAction method deleteUser.
public String deleteUser() {
UserDetail userDetail = gsonTool.readJson(new StringReader(userData), UserDetail.class);
boolean success = userManagementService.deactivateUser(userDetail);
if (success) {
updateUserMessage = "User deleted successfully";
} else {
updateUserMessage = "Error deleting user : '" + username + "'";
}
return "updateUser";
}
use of org.onebusaway.admin.model.ui.UserDetail in project onebusaway-application-modules by camsys.
the class ManageUsersAction method editUser.
/**
* Edits a user in the system
* @return
*/
public String editUser() {
UserDetail userDetail = gsonTool.readJson(new StringReader(userData), UserDetail.class);
boolean success = userManagementService.updateUser(userDetail);
if (success) {
updateUserMessage = "User '" + userDetail.getUsername() + "' edited successfully";
} else {
updateUserMessage = "Error editing user : '" + userDetail.getUsername() + "'";
}
return "updateUser";
}
Aggregations