### Question:
Rental { public Rental(IUser aUser, Movie aMovie, int nofRentalDays) { this(aUser, aMovie, nofRentalDays, new Date(Calendar.getInstance().getTimeInMillis())); if (aMovie.isRented()) { throw new IllegalStateException("movie is already rented!"); } aMovie.setRented(true); } Rental(IUser aUser, Movie aMovie, int nofRentalDays); private  Rental(IUser aUser, Movie aMovie, int nofRentalDays, Date rentaldate); static Rental createRentalFromDb(IUser aUser, Movie aMovie, int nofRentalDays, Date rentalDate); int calcRemainingDaysOfRental(Date date); double getRentalFee(); int getId(); Movie getMovie(); IUser getUser(); Date getRentalDate(); int getRentalDays(); void setId(int anId); void setRentalDays(int nofRentalDays); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void testRental() throws InterruptedException { Date before = new Date(Calendar.getInstance().getTimeInMillis()); Thread.sleep(10); Rental r = new Rental(u1, m1, 42); assertNotNull(r); assertTrue(u1.getRentals().contains(r)); assertTrue(m1.isRented()); assertEquals(42, r.getRentalDays()); Thread.sleep(10); Date after = new Date(Calendar.getInstance().getTimeInMillis()); assertTrue(before.before(r.getRentalDate())); assertTrue(after.after(r.getRentalDate())); assertEquals(u1, r.getUser()); assertEquals(m1, r.getMovie()); }