DefaultUserGroupDao implements UserGroupDao { @Override public List<UserGroupView> getUserGroupViews(final MultipleSearch<UserGroupView> request, final List<Long> groupsIds) { MultiplePagedSearch<List<Long>> search = new MultiplePagedSearch<>(); search.setEntity(groupsIds); String querySql = userGroupViewQueryBuilder.build(search); Query<UserGroupView> query = new Query<UserGroupView>(request.getClazz(), querySql, request.getParameters()); return persistenceManager.getMultipleResult(query); }  @Override List<UserGroupView> getUserGroupViews(final MultipleSearch<UserGroupView> request, final List<Long> groupsIds); void setUserGroupViewQueryBuilder(final QueryBuilder<List<Long>> userGroupViewQueryBuilder); void setPersistenceManager(PersistenceManager<UserGroup, Long> persistenceManager);  }
@Test public void testGetUserGroupViews() throws Exception { Map<String, Object> parameters = new HashMap<String, Object>(); Class<UserGroupView> clazz = UserGroupView.class; MultipleSearch<UserGroupView> request = new MultipleSearch<UserGroupView>(parameters, clazz); List<Long> groupsIds = Collections.emptyList(); UserGroupView userGroupView1 = new UserGroupView(); List<UserGroupView> expected = Arrays.asList(userGroupView1); String querySql = "query SQL"; Query<UserGroupView> query = new Query<UserGroupView>(UserGroupView.class, querySql, parameters); MultiplePagedSearch<List<Long>> search = new MultiplePagedSearch<>(); search.setEntity(groupsIds); when(userGroupViewQueryBuilder.build(Matchers.<MultiplePagedSearch<List<Long>>>any())).thenReturn(querySql); when(persistenceManager.getMultipleResult(Matchers.<Query<UserGroupView>>any())).thenReturn(expected); List<UserGroupView> actual = unit.getUserGroupViews(request, groupsIds); verify(persistenceManager).getMultipleResult(query); verify(userGroupViewQueryBuilder).build(search); assertEquals(expected, actual); }