@@ -0,0 +1,2250 @@
+package org.croudtrip.trips;%0A%0Aimport com.google.common.collect.Lists;%0A%0Aimport org.croudtrip.api.trips.TripOffer;%0Aimport org.croudtrip.api.trips.TripOfferStatus;%0Aimport org.croudtrip.db.TripOfferDAO;%0Aimport org.croudtrip.logs.LogManager;%0Aimport org.hibernate.SessionFactory;%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0A%0Aimport mockit.Expectations;%0Aimport mockit.Mocked;%0Aimport mockit.Verifications;%0Aimport mockit.integration.junit4.JMockit;%0A%0A@RunWith(JMockit.class)%0Apublic class DisableTripOffersExecutorTest %7B%0A%0A%09@Mocked TripOfferDAO tripOfferDAO;%0A%09@Mocked TripsUtils tripsUtils;%0A%09@Mocked SessionFactory sessionFactory;%0A%09@Mocked LogManager logManager;%0A%0A%09private DisableTripOffersExecutor executor;%0A%0A%09@Before%0A%09public void setupExecutor() %7B%0A%09%09this.executor = new DisableTripOffersExecutor(tripOfferDAO, tripsUtils, sessionFactory, logManager);%0A%09%7D%0A%0A%09@Test%0A%09public void testDisableOffer() throws Exception %7B%0A%09%09final TripOffer offer1 = new TripOffer.Builder()%0A%09%09%09%09.setStatus(TripOfferStatus.FINISHED)%0A%09%09%09%09.build();%0A%09%09final TripOffer offer2 = new TripOffer.Builder()%0A%09%09%09%09.setStatus(TripOfferStatus.ACTIVE)%0A%09%09%09%09.setLastPositonUpdateInSeconds(0)%0A%09%09%09%09.build();%0A%0A%09%09new Expectations() %7B%7B%0A%09%09%09tripOfferDAO.findAll();%0A%09%09%09result = Lists.newArrayList(offer1, offer2);%0A%09%09%7D%7D;%0A%0A%09%09executor.doRun();%0A%0A%09%09new Verifications() %7B%7B%0A%09%09%09TripOffer updatedOffer;%0A%09%09%09tripOfferDAO.update(updatedOffer = withCapture());%0A%09%09%09Assert.assertEquals(TripOfferStatus.DISABLED, updatedOffer.getStatus());%0A%09%09%7D%7D;%0A%09%7D%0A%0A%09@Test%0A%09public void testEnableOffer() throws Exception %7B%0A%09%09final TripOffer offer1 = new TripOffer.Builder()%0A%09%09%09%09.setStatus(TripOfferStatus.FINISHED)%0A%09%09%09%09.build();%0A%09%09final TripOffer offer2 = new TripOffer.Builder()%0A%09%09%09%09.setStatus(TripOfferStatus.DISABLED)%0A%09%09%09%09.setLastPositonUpdateInSeconds(System.currentTimeMillis() / 1000)%0A%09%09%09%09.build();%0A%0A%09%09new Expectations() %7B%7B%0A%09%09%09tripOfferDAO.findAll();%0A%09%09%09result = Lists.newArrayList(offer1, offer2);%0A%09%09%7D%7D;%0A%0A%09%09executor.doRun();%0A%0A%09%09new Verifications() %7B%7B%0A%09%09%09TripOffer updatedOffer;%0A%09%09%09tripOfferDAO.update(updatedOffer = withCapture());%0A%09%09%09Assert.assertEquals(TripOfferStatus.ACTIVE, updatedOffer.getStatus());%0A%0A%09%09%09tripsUtils.checkAndUpdateRunningQueries(updatedOffer);%0A%09%09%7D%7D;%0A%09%7D%0A%0A%7D

add DisableTripOffersExecutorTest