import org.junit.Before;\r
import org.junit.Test;\r
import org.junit.runner.RunWith;\r
+import org.mockito.InjectMocks;\r
import org.mockito.Mock;\r
+import org.mockito.Spy;\r
import org.mockito.runners.MockitoJUnitRunner;\r
\r
@RunWith(MockitoJUnitRunner.class)\r
private static final Trip TO_BERLIN = new Trip();\r
\r
@Mock TripDAO tripDAO;\r
- private TripService realTripService;\r
+ @InjectMocks @Spy private TripService realTripService = new TripService();\r
private TripService tripService;\r
\r
@Before\r
\r
@Test(expected=UserNotLoggedInException.class) public void\r
throw_an_exception_when_user_is_not_logged_in() { \r
- tripService.getTripsByUser(UNUSED_USER, GUEST);\r
+ realTripService.getTripsByUser(UNUSED_USER, GUEST);\r
}\r
\r
@Test public void\r
.withTrips(TO_BRAZIL)\r
.build();\r
\r
- List<Trip> friendTrips = tripService.getTripsByUser(friend, REGISTERED_USER); \r
+ List<Trip> friendTrips = realTripService.getTripsByUser(friend, REGISTERED_USER); \r
// You must always begin writing the assert.\r
// Remember: the assert must match the unit test method's name!!\r
// In this case, no trips must be returned.\r
.withTrips(TO_BRAZIL, TO_BERLIN)\r
.build();\r
\r
- List<Trip> friendTrips = tripService.getTripsByUser(friend, REGISTERED_USER); \r
+ List<Trip> friendTrips = realTripService.getTripsByUser(friend, REGISTERED_USER); \r
// You must always begin writing the assert.\r
// Remember: the assert must match the unit test method's name!!\r
// In this case, no trips must be returned.\r