}
@SuppressWarnings("unchecked")
@Test
public void canDistributeResourcesPerDay() {
ResourcesPerDayDistributor distributor = ResourcesPerDay.distributor(
ResourcesPerDay.amount(new BigDecimal(0.8)), ResourcesPerDay
.amount(new BigDecimal(0.2)));
Object[][] examples = {
{ ResourcesPerDay.amount(10),
readsAs(8, 0), readsAs(2, 0) },
{ ResourcesPerDay.amount(1),
readsAs(0, 8000), readsAs(0, 2000) },
{ ResourcesPerDay.amount(new BigDecimal(0.5)),
readsAs(0, 4000),readsAs(0, 1000) } };
for (Object[] eachExample : examples) {
ResourcesPerDay toDistribute = (ResourcesPerDay) eachExample[0];
Matcher<ResourcesPerDay> firstMatcher = (Matcher<ResourcesPerDay>) eachExample[1];
Matcher<ResourcesPerDay> secondMatcher = (Matcher<ResourcesPerDay>) eachExample[2];
ResourcesPerDay[] distribute = distributor.distribute(toDistribute);
assertThat(distribute[0], firstMatcher);
assertThat(distribute[1], secondMatcher);
}
}