CollectionDao extends HibernateDao<Collection, String> { public List<Long> getProductIds (final String collection_uuid, User user) { if (collection_uuid == null) { return Collections.emptyList (); } List<Long> result = new ArrayList<> (); Iterator<Product> it = read (collection_uuid).getProducts ().iterator (); while (it.hasNext ()) { Product product = it.next (); if (product != null) { result.add (product.getId ()); } } return result; }  @Override void delete(final Collection collection); @Override void deleteAll(); boolean contains(final String cid, final Long pid); void removeProduct(final String cid, final Long pid, User user); void removeProducts(final String cid, final Long[] pids, User user); @SuppressWarnings ("unchecked") List<Collection> getCollectionsOfProduct(final Long product_id); List<Long> getProductIds(final String collection_uuid, User user); @SuppressWarnings("unchecked") List<String> getCollectionsUUID(); String getCollectionUUIDByName(final String collection_name); Collection getByName(final String name); Iterator<Collection> getAllCollections(); final static String HIDDEN_PREFIX; final static String COLLECTION_ROOT_NAME; }
@Test public void getProductIds () { String cid = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1"; String uid = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa2"; User user = udao.read (uid); List<Long> pids = dao.getProductIds (cid, user); Assert.assertNotNull (pids); Assert.assertEquals (pids.size (), 5); Assert.assertTrue (pids.contains (0L)); Assert.assertTrue (pids.contains (2L)); Assert.assertTrue (pids.contains (3L)); Assert.assertTrue (pids.contains (5L)); }