public void testGetQuantityAvailableToBeUsedAsTarget() throws Exception {
int quantity = priceDetail1.getQuantityAvailableToBeUsedAsTarget(candidateOffer);
//no previous qualifiers, so all quantity is available
assertTrue(quantity == 2);
PromotionDiscount discount = new PromotionDiscount();
discount.setPromotion(offer);
discount.setQuantity(1);
priceDetail1.getPromotionDiscounts().add(discount);
quantity = priceDetail1.getQuantityAvailableToBeUsedAsTarget(candidateOffer);
//items that have already received this promotion cannot get it again
assertTrue(quantity==1);
Offer tempOffer = new OfferImpl();
tempOffer.setCombinableWithOtherOffers(true);
tempOffer.setOfferItemQualifierRuleType(OfferItemRestrictionRuleType.NONE);
tempOffer.setOfferItemTargetRuleType(OfferItemRestrictionRuleType.NONE);
discount.setPromotion(tempOffer);
quantity = priceDetail1.getQuantityAvailableToBeUsedAsTarget(candidateOffer);
//this item received a different promotion, but the restriction rule is NONE, so this item cannot be a qualifier
//for this promotion
assertTrue(quantity==1);