DefaultUserGroupService implements UserGroupService { @Override public List<UserGroupView> getUserGroupsView(final List<Long> groupsIds) { Map<String, Object> parameters = userGroupViewsParametersExtractor.getParameters(groupsIds); MultipleSearch<UserGroupView> request = new MultipleSearch<UserGroupView>(parameters, UserGroupView.class); return dao.getUserGroupViews(request, groupsIds); }  @Override List<UserGroupView> getUserGroupsView(final List<Long> groupsIds); void setUserGroupViewsParametersExtractor(final ParametersExtractor<List<Long>> userGroupViewsParametersExtractor); void setDao(UserGroupDao dao);  }
@Test public void testGetUserGroupViews() throws Exception { Map<String, Object> parameters = new HashMap<String, Object>(); Long group1 = 1L; List<Long> groupsIds = Arrays.asList(group1); UserGroupView userGroupView1 = new UserGroupView(); List<UserGroupView> expected = Arrays.asList(userGroupView1); MultipleSearch<UserGroupView> request = new MultipleSearch<UserGroupView>(parameters, UserGroupView.class); when(userGroupViewsParametersExtractor.getParameters(anyListOf(Long.class))).thenReturn(parameters); when(dao.getUserGroupViews(Matchers.<MultipleSearch<UserGroupView>>any(), anyListOf(Long.class))).thenReturn(expected); List<UserGroupView> actual = unit.getUserGroupsView(groupsIds); verify(userGroupViewsParametersExtractor).getParameters(groupsIds); verify(dao).getUserGroupViews(request, groupsIds); assertEquals(expected, actual); }