ProductSkuServiceImpl extends BaseGenericServiceImpl<ProductSku> implements ProductSkuService { @Override public void removeAllPrices(final long productId) { final List<ProductSku> skus = getGenericDao().findByCriteria(" where e.product.productId = ?1" , productId); for (ProductSku sku : skus) { removeAllPrices( sku); } } ProductSkuServiceImpl(final GenericFTSCapableDAO<ProductSku, Long, Object> productSkuDao,
                                 final GenericFTSCapableDAO<Product, Long, Object> productDao,
                                 final GenericDAO<SkuPrice, Long> skuPriceDao); @Override Collection<ProductSku> getAllProductSkus(final long productId); @Override ProductSku findProductSkuBySkuCode(final String skuCode); @Override List<ProductSku> findProductSkus(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findProductSkuCount(final Map<String, List> filter); @Override ProductSku getProductSkuBySkuCode(final String skuCode); @Override ProductSkuSearchResultPageDTO getProductSkuSearchResultDTOByQuery(final NavigationContext context); @Override List<Pair<String, SkuPrice>> getAllPrices(final long productId); @Override List<Pair<String, SkuWarehouse>> getAllInventory(final long productId); @Override void removeAllPrices(final long productId); @Override void removeAllPrices(final ProductSku sku); @Override void removeAllInventory(final long productId); @Override void removeAllInventory(final ProductSku sku); @Override void removeAllWishLists(final ProductSku sku); @Override void removeAllOptions(final long productId); @Override void removeAllOptions(final ProductSku sku);  }
@Test public void testRemoveAllPrices() { ProductSkuService productSkuService = (ProductSkuService) ctx().getBean(ServiceSpringKeys.PRODUCT_SKU_SERVICE); Collection<ProductSku> skus = productSkuService.getAllProductSkus(REMOVE_ME_PK); assertEquals(2, skus.size()); final Set<String> skuCodes = new HashSet<>(); for (final ProductSku sku : skus) { skuCodes.add(sku.getCode()); } List<Pair<String, SkuPrice>> prices = productSkuService.getAllPrices(REMOVE_ME_PK); assertEquals(4, prices.size()); for (Pair<String, SkuPrice> sku : prices) { assertTrue(skuCodes.contains(sku.getFirst())); assertNotNull(sku.getSecond()); assertNotNull(sku.getSecond().getRegularPrice()); } productSkuService.removeAllPrices(REMOVE_ME_PK); skus = productSkuService.getAllProductSkus(REMOVE_ME_PK); assertEquals(2, skus.size()); prices = productSkuService.getAllPrices(REMOVE_ME_PK); assertTrue("Prices must be removed for sku", prices.isEmpty()); }