@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))); }
@Override public boolean matches(Object userroleToMatch) { return ((UserRole) userroleToMatch).getUserId().equals(userRole.getUserId()) && ((UserRole) userroleToMatch).getRoleName().equals(userRole.getRoleName()); }