}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testEntitleWithADate() throws Exception {
Product product = TestUtil.createProduct();
List<Pool> pools = Util.newList();
Pool pool1 = TestUtil.createPool(product);
pools.add(pool1);
Pool pool2 = TestUtil.createPool(product);
pools.add(pool2);
Date now = new Date();
ValidationResult result = mock(ValidationResult.class);
Page page = mock(Page.class);
when(page.getPageData()).thenReturn(pools);
when(mockPoolCurator.listAvailableEntitlementPools(any(Consumer.class),
any(Owner.class), any(String.class), eq(now), anyBoolean(),
any(PoolFilterBuilder.class), any(PageRequest.class),
anyBoolean())).thenReturn(page);
when(mockPoolCurator.lockAndLoad(any(Pool.class))).thenReturn(pool1);
when(enforcerMock.preEntitlement(any(Consumer.class), any(Pool.class), anyInt(),
any(CallerType.class))).thenReturn(result);
when(result.isSuccessful()).thenReturn(true);
List<PoolQuantity> bestPools = new ArrayList<PoolQuantity>();
bestPools.add(new PoolQuantity(pool1, 1));
when(autobindRules.selectBestPools(any(Consumer.class), any(String[].class),
any(List.class), any(ComplianceStatus.class), any(String.class),
any(Set.class), eq(false)))
.thenReturn(bestPools);
AutobindData data = AutobindData.create(TestUtil.createConsumer(o))
.forProducts(new String[] { product.getId() }).on(now);
List<Entitlement> e = manager.entitleByProducts(data);
assertNotNull(e);
assertEquals(e.size(), 1);
}