@Test public void fixtureNextInvoices() { List<Invoice> invoices = Fixture.from(Invoice.class).gimme(3, "nextInvoices"); assertNotNull("Invoice list should not be null", invoices); assertTrue("Invoice list should not be empty", !invoices.isEmpty()); Calendar calendar = DateTimeUtil.toCalendar("2011-04-30", new SimpleDateFormat("yyyy-MM-dd")); for (Invoice invoice : invoices) { assertEquals("Calendar should be equal", calendar, invoice.getDueDate()); calendar.add(Calendar.DAY_OF_MONTH, 1); } }
@Test public void fixturePreviousInvoices() { List<Invoice> invoices = Fixture.from(Invoice.class).gimme(3, "previousInvoices"); assertNotNull("Invoice list should not be null", invoices); assertTrue("Invoice list should not be empty", !invoices.isEmpty()); Calendar calendar = DateTimeUtil.toCalendar("2011-04-01", new SimpleDateFormat("yyyy-MM-dd")); for (Invoice invoice : invoices) { assertEquals("Calendar should be equal", calendar, invoice.getDueDate()); calendar.add(Calendar.MONTH, -1); assertTrue( "Invoice ammout should be within range", invoice.getAmmount().compareTo(new BigDecimal("45.89")) >= 0 && invoice.getAmmount().compareTo(new BigDecimal("58.67")) <= 0); } }