From: Gustavo Martin Morcuende Date: Fri, 25 Nov 2016 00:15:11 +0000 (+0100) Subject: Removing loggedInUser from Test. X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=4d6fe926c1b9289ead83506996578508416770a1;p=JavaForFun Removing loggedInUser from Test. Less variables makes our code more simple. --- diff --git a/TDD/src/main/java/org/craftedsw/tripservicekata/trip/TripService.java b/TDD/src/main/java/org/craftedsw/tripservicekata/trip/TripService.java index 139ae0a..e2aced9 100644 --- a/TDD/src/main/java/org/craftedsw/tripservicekata/trip/TripService.java +++ b/TDD/src/main/java/org/craftedsw/tripservicekata/trip/TripService.java @@ -5,7 +5,6 @@ import java.util.List; import org.craftedsw.tripservicekata.exception.UserNotLoggedInException; import org.craftedsw.tripservicekata.user.User; -import org.craftedsw.tripservicekata.user.UserSession; public class TripService { diff --git a/TDD/src/test/java/org/craftedsw/tripservicekata/trip/TripServiceShould.java b/TDD/src/test/java/org/craftedsw/tripservicekata/trip/TripServiceShould.java index 73f2c24..9836194 100644 --- a/TDD/src/test/java/org/craftedsw/tripservicekata/trip/TripServiceShould.java +++ b/TDD/src/test/java/org/craftedsw/tripservicekata/trip/TripServiceShould.java @@ -19,19 +19,15 @@ public class TripServiceShould { private static final User ANOTHER_USER = new User(); private static final Trip TO_BRAZIL = new Trip(); private static final Trip TO_BERLIN = new Trip(); - private User loggedInUser; private TripService tripService; @Before public void setUp() { tripService = new TesteableTripService(); - loggedInUser = REGISTERED_USER; } @Test(expected=UserNotLoggedInException.class) public void - throw_an_exception_when_user_is_not_logged_in() { - loggedInUser = GUEST; - + throw_an_exception_when_user_is_not_logged_in() { tripService.getTripsByUser(UNUSED_USER, GUEST); } @@ -42,7 +38,7 @@ public class TripServiceShould { .withTrips(TO_BRAZIL) .build(); - List friendTrips = tripService.getTripsByUser(friend, loggedInUser); + List friendTrips = tripService.getTripsByUser(friend, REGISTERED_USER); // You must always begin writing the assert. // Remember: the assert must match the unit test method's name!! // In this case, no trips must be returned. @@ -52,11 +48,11 @@ public class TripServiceShould { @Test public void return_friend_trips_when_users_are_friends() { User friend = UserBuilder.aUser() - .friendsWith(ANOTHER_USER, loggedInUser) + .friendsWith(ANOTHER_USER, REGISTERED_USER) .withTrips(TO_BRAZIL, TO_BERLIN) .build(); - List friendTrips = tripService.getTripsByUser(friend, loggedInUser); + List friendTrips = tripService.getTripsByUser(friend, REGISTERED_USER); // You must always begin writing the assert. // Remember: the assert must match the unit test method's name!! // In this case, no trips must be returned.