@Test public void testCriteriaMet_itemsInList() { // setup Transaction transaction = TransactionTestUtils.createTransaction( toothBrush, milkCarton, toothBrush, chips, toothBrush, toothBrush); Set<Integer> alreadyClaimedProducts = Sets.newHashSet(1, 3); // test boolean result = promotionElement.criteriaMet(transaction, alreadyClaimedProducts); // verify assertThat(result, is(false)); assertThat(alreadyClaimedProducts, IsIterableContainingInAnyOrder.containsInAnyOrder(1, 3)); }
private void testCriteriaMet( String reason, Transaction transaction, boolean expected, Integer... ids) { // setup Set<Integer> alreadyClaimedProducts = Sets.newHashSet(); // test boolean result = promotionElement.criteriaMet(transaction, alreadyClaimedProducts); // verify checkThat(reason, result, equalTo(expected)); if (expected) { checkThat( reason, alreadyClaimedProducts, IsIterableContainingInAnyOrder.containsInAnyOrder(ids)); } else { checkThat(reason, alreadyClaimedProducts, IsCollectionWithSize.hasSize(0)); } }