DeviationDAOCachedMergingMySQL extends AbstractTableCreatingDroppingDAOImpl implements DeviationDAO { @Nonnull public Set<TenantItem> getItemIds(final int tenantId, final TIntSet itemTypeIds) { TIntIterator iterator = itemTypeIds.iterator(); Set<TenantItem> result = Sets.newHashSet(); while (iterator.hasNext()) { int itemTypeId = iterator.next(); Object[] args = new Object[]{tenantId, itemTypeId, tenantId, itemTypeId}; List<Integer> itemIds = QUERY_GET_ITEMIDS.execute(args); for (Integer itemId : itemIds) result.add(new TenantItem(itemId, itemTypeId)); } return result; } DeviationDAOCachedMergingMySQL(DataSource dataSource, SqlScriptService sqlScriptService); void starting(); void endUpdate(); void finished(final int tenantId, final int itemTypeId); synchronized Deviation getDeviation(final int tenantId, final int item1Id, final int item1TypeId,
                                               final int item2Id, int item2TypeId); List<Deviation> getDeviationsOrdered(final int tenantId, final int itemTypeId, final int itemId,
                                                final Long minCountConstraint,
                                                final Integer maxNumberOfDeviationsConstraint); @Nonnull Set<TenantItem> getItemIds(final int tenantId, final TIntSet itemTypeIds); synchronized int insertDeviation(final Deviation deviation); synchronized int insertDeviations(final List<Deviation> deviations); @Override String getDefaultTableName(); @Override String getTableCreatingSQLScriptName(); @Override void dropTable(); static final int[] NO_TYPES; }
@Test public void getItemIds_shouldReturnAllItems() { TIntSet itemTypeIds = new TIntHashSet(new int[]{1}); Set<TenantItem> items = cachedMergingMySqlDeviationDAO.getItemIds(1, itemTypeIds); assertThat(items.size(), is(3)); assertThat(items, hasItem(new TenantItem(1, 1))); assertThat(items, hasItem(new TenantItem(2, 1))); assertThat(items, hasItem(new TenantItem(3, 1))); }