package org.craftedsw.tripservicekata.trip;\r
\r
+import static org.junit.Assert.assertThat;\r
+import static org.hamcrest.core.Is.is;\r
+\r
+import java.util.List;\r
+\r
import org.craftedsw.tripservicekata.exception.UserNotLoggedInException;\r
import org.craftedsw.tripservicekata.user.User;\r
import org.junit.Test;\r
\r
private static final User GUEST = null;\r
private static final User UNUSED_USER = null;\r
+ private static final User REGISTERED_USER = new User();\r
+ private static final User ANOTHER_USER = new User();\r
+ private static final Trip TO_BRAZIL = new Trip();\r
private User loggedInUser;\r
\r
@Test(expected=UserNotLoggedInException.class) public void\r
tripService.getTripsByUser(UNUSED_USER);\r
}\r
\r
+ @Test public void\r
+ not_return_any_trips_when_users_are_not_friends() {\r
+ TesteableTripService tripService = new TesteableTripService();\r
+ \r
+ loggedInUser = REGISTERED_USER;\r
+ \r
+ User friend = new User();\r
+ friend.addFriend(ANOTHER_USER);\r
+ friend.addTrip(TO_BRAZIL);\r
+ \r
+ List<Trip> friendTrips = tripService.getTripsByUser(friend); \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
+ assertThat(friendTrips.size(), is(0));\r
+ }\r
+ \r
private class TesteableTripService extends TripService {\r
\r
@Override\r