@Test public void testUpdateSuccess() { when(roleService.findRole(updateRoleCmd.getRoleId())).thenReturn(role); when(role.getId()).thenReturn(1L); when(role.getUuid()).thenReturn("12345-abcgdkajd"); when(role.getDescription()).thenReturn("Defualt user"); when(role.getName()).thenReturn("User"); when(role.getRoleType()).thenReturn(RoleType.User); when(roleService.updateRole(role,updateRoleCmd.getRoleName(),updateRoleCmd.getRoleType(),updateRoleCmd.getRoleDescription())).thenReturn(role); when(role.getId()).thenReturn(1L); when(role.getDescription()).thenReturn("Description Initial"); when(role.getName()).thenReturn("User"); updateRoleCmd.execute(); RoleResponse response = (RoleResponse) updateRoleCmd.getResponseObject(); assertEquals((String)ReflectionTestUtils.getField(response, "roleName"),role.getName()); assertEquals((String)ReflectionTestUtils.getField(response, "roleDescription"),role.getDescription()); } }
@Override public void execute() { Role role = roleService.findRole(getRoleId()); if (role == null) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role id provided"); } CallContext.current().setEventDetails("Role: " + getRoleName() + ", type:" + getRoleType() + ", description: " + getRoleDescription()); role = roleService.updateRole(role, getRoleName(), getRoleType(), getRoleDescription()); setupResponse(role); } }