@Test public void shouldReturnAllUsersWhithRoleWhenInvoked() { List<User> users = new ArrayList<User>(); users.add(user); when(userMapper.findAllUsers()).thenReturn(users); when(userRoleMapper.get(user.getId())).thenReturn(userRole); Map<User, String> result = userService.getAllUsersWithRole(); Map<User, String> expect = new HashMap<User, String>(); expect.put(user, userRole.getRoleName()); assertEquals(result, expect); verify(userMapper).findAllUsers(); verify(userRoleMapper).get(user.getId()); }
@Override public boolean matches(Object userroleToMatch) { return ((UserRole) userroleToMatch).getUserId().equals(userRole.getUserId()) && ((UserRole) userroleToMatch).getRoleName().equals(userRole.getRoleName()); }