ActionDAOMysqlImpl extends AbstractTableCreatingDroppingDAOImpl implements ActionDAO { public List<Integer> getUsers(int tenantId, TIntSet itemTypeIds, Date since) { String query = QUERY_USER; TIntList argt = new TIntArrayList(ARGT_USER); List<Object> args = new ArrayList<Object>(2); args.add(tenantId); if (since != null) { query += QUERY_USER_ACTIONTIME; argt.add(ARGT_USER_ACTIONTIME); args.add(since); } query = query.replace("@@@", generateItemTypeInClause(itemTypeIds)); return getJdbcTemplate().queryForList(query, args.toArray(), argt.toArray(), Integer.class); } ActionDAOMysqlImpl(DataSource dataSource, SqlScriptService sqlScriptService); void setActionDAO(final org.easyrec.store.dao.core.ActionDAO actionDAO); int generateActions(int tenantId, TIntSet itemTypeIds, int actionTypeId, Date since); List<RatingVO<Integer, Integer>> getRatings(int tenantId, TIntSet itemTypeIds,
                                                                         int userId); List<Integer> getUsers(int tenantId, TIntSet itemTypeIds, Date since); int insertAction(ActionVO<Integer, Integer> action); int insertActions(List<ActionVO<Integer, Integer>> actions); @Override String getDefaultTableName(); @Override String getTableCreatingSQLScriptName(); static final int[] ARGT_NEWEST; }
@Test public void getUsers_shouldReturnUsersSinceDate() { TIntSet itemTypeIds = new TIntHashSet(new int[]{1}); List<Integer> users = actionDAO.getUsers(1, itemTypeIds, createDate("2007-04-15 12:10:00.0")); assertThat(users.size(), is(2)); assertThat(users, hasItem(equalTo(1))); assertThat(users, hasItem(equalTo(2))); users = actionDAO.getUsers(1, itemTypeIds, createDate("2007-04-15 12:15:00.0")); assertThat(users.size(), is(1)); assertThat(users, not(hasItem(equalTo(1)))); assertThat(users, hasItem(equalTo(2))); }