Removing loggedInUser from Test.
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Fri, 25 Nov 2016 00:15:11 +0000 (01:15 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Fri, 25 Nov 2016 00:15:11 +0000 (01:15 +0100)
Less variables makes our code more simple.

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

index 139ae0a..e2aced9 100644 (file)
@@ -5,7 +5,6 @@ import java.util.List;
 \r
 import org.craftedsw.tripservicekata.exception.UserNotLoggedInException;\r
 import org.craftedsw.tripservicekata.user.User;\r
-import org.craftedsw.tripservicekata.user.UserSession;\r
 \r
 public class TripService {\r
 \r
index 73f2c24..9836194 100644 (file)
@@ -19,19 +19,15 @@ public class TripServiceShould {
        private static final User ANOTHER_USER = new User();\r
        private static final Trip TO_BRAZIL = new Trip();\r
        private static final Trip TO_BERLIN = new Trip();\r
-       private User loggedInUser;\r
        private TripService tripService;\r
        \r
        @Before\r
        public void setUp() {\r
                tripService = new TesteableTripService();\r
-               loggedInUser = REGISTERED_USER;\r
        }\r
 \r
        @Test(expected=UserNotLoggedInException.class) public void\r
-       throw_an_exception_when_user_is_not_logged_in() {\r
-               loggedInUser = GUEST;\r
-               \r
+       throw_an_exception_when_user_is_not_logged_in() {               \r
                tripService.getTripsByUser(UNUSED_USER, GUEST);\r
        }\r
        \r
@@ -42,7 +38,7 @@ public class TripServiceShould {
                                                .withTrips(TO_BRAZIL)\r
                                                .build();\r
                \r
-               List<Trip> friendTrips = tripService.getTripsByUser(friend, loggedInUser); \r
+               List<Trip> friendTrips = tripService.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
@@ -52,11 +48,11 @@ public class TripServiceShould {
        @Test public void\r
        return_friend_trips_when_users_are_friends() {\r
                User friend = UserBuilder.aUser()\r
-                                               .friendsWith(ANOTHER_USER, loggedInUser)\r
+                                               .friendsWith(ANOTHER_USER, REGISTERED_USER)\r
                                                .withTrips(TO_BRAZIL, TO_BERLIN)\r
                                                .build();\r
                \r
-               List<Trip> friendTrips = tripService.getTripsByUser(friend, loggedInUser); \r
+               List<Trip> friendTrips = tripService.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