@Test
  public void shouldUpdateUserRoleWhenInvokeAuthoriseUser() {
    UserRole updatedUserRole = new UserRole();
    updatedUserRole.setUserId(1L);
    updatedUserRole.setRoleName("ROLE_ADMIN");

    when(userRoleMapper.get(userRole.getUserId())).thenReturn(userRole);

    userService.authoriseUser(userRole.getUserId());
    verify(userRoleMapper).get(userRole.getUserId());
    verify(userRoleMapper).update(argThat(new UserRoleMatcher(updatedUserRole)));
  }
  @Before
  public void setup() {
    session = mock(SqlSession.class);
    userMapper = mock(UserMapper.class);
    userRoleMapper = mock(UserRoleMapper.class);

    sessionFactory = mock(SqlSessionFactory.class);

    when(sessionFactory.openSession()).thenReturn(session);
    when(session.getMapper(UserMapper.class)).thenReturn(userMapper);
    when(session.getMapper(UserRoleMapper.class)).thenReturn(userRoleMapper);

    userService = new UserServiceImpl(sessionFactory);

    user = new User();
    user.setUserName("user");
    user.setPasswordHash("password");
    user.setId(1L);

    userRole = new UserRole();
    userRole.setUserId(1L);
    userRole.setRoleName("ROLE_REGULAR");
  }