We test the next branch.
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 20 Nov 2016 22:44:01 +0000 (23:44 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Sun, 20 Nov 2016 22:45:46 +0000 (23:45 +0100)
Remember: the assert must match the unit test method's name!!
In this case, no trips must be returned.

TDD/src/test/java/org/craftedsw/tripservicekata/trip/TripServiceShould.java

index 58ee787..136c953 100644 (file)
@@ -1,5 +1,10 @@
 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
@@ -8,6 +13,9 @@ public class TripServiceShould {
        \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
@@ -19,6 +27,23 @@ public class TripServiceShould {
                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