@@ -0,0 +1,1805 @@
+package org.croudtrip.trips;%0A%0Aimport org.croudtrip.api.trips.TripQuery;%0Aimport org.croudtrip.api.trips.TripReservation;%0Aimport org.croudtrip.db.TripReservationDAO;%0Aimport org.croudtrip.logs.LogManager;%0Aimport org.hibernate.SessionFactory;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport mockit.Expectations;%0Aimport mockit.Mocked;%0Aimport mockit.Verifications;%0Aimport mockit.integration.junit4.JMockit;%0A%0A@RunWith(JMockit.class)%0Apublic class TripReservationGarbageCollectorTest %7B%0A%0A%09@Mocked TripReservationDAO tripReservationDAO;%0A%09@Mocked SessionFactory sessionFactory;%0A%09@Mocked LogManager logManager;%0A%0A%09private  TripReservationGarbageCollector collector;%0A%0A%09@Before%0A%09public void setupCollector() %7B%0A%09%09collector = new TripReservationGarbageCollector(tripReservationDAO, sessionFactory, logManager);%0A%09%7D%0A%0A%0A%09@Test%0A%09public void testDoRun() %7B%0A%09%09long currentTimestamp = System.currentTimeMillis() / 1000;%0A%09%09final List%3CTripReservation%3E reservations = new ArrayList%3C%3E();%0A%09%09final TripReservation newReservation = createReservation(currentTimestamp - 10, 1000);%0A%09%09final TripReservation oldReservation = createReservation(currentTimestamp - 10000, 10);%0A%09%09reservations.add(newReservation);%0A%09%09reservations.add(oldReservation);%0A%0A%09%09new Expectations() %7B%7B%0A%09%09%09tripReservationDAO.findAll();%0A%09%09%09result = reservations;%0A%09%09%7D%7D;%0A%0A%09%09collector.doRun();%0A%0A%09%09new Verifications() %7B%7B%0A%09%09%09tripReservationDAO.delete(oldReservation); times = 1;%0A%09%09%09tripReservationDAO.delete(newReservation); times = 0;%0A%09%09%7D%7D;%0A%09%7D%0A%0A%0A%09private TripReservation createReservation(long creationTimestamp, long maxWaitingTime) %7B%0A%09%09return new TripReservation(0,%0A%09%09%09%09new TripQuery(null, null, null, maxWaitingTime, null),%0A%09%09%09%090,%0A%09%09%09%090,%0A%09%09%09%090,%0A%09%09%09%09null,%0A%09%09%09%09creationTimestamp);%0A%09%7D%0A%7D%0A

add TripReservationGarbageCollectorTest