From: Gustavo Martin Morcuende Date: Wed, 23 Nov 2016 20:31:23 +0000 (+0100) Subject: Removing duplicated code X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=c6bdbe6308d90ef0a01549ea26e3e94a5e33930a;p=JavaForFun Removing duplicated code --- 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 136c953..7243417 100644 --- a/TDD/src/test/java/org/craftedsw/tripservicekata/trip/TripServiceShould.java +++ b/TDD/src/test/java/org/craftedsw/tripservicekata/trip/TripServiceShould.java @@ -1,12 +1,13 @@ package org.craftedsw.tripservicekata.trip; -import static org.junit.Assert.assertThat; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; import java.util.List; import org.craftedsw.tripservicekata.exception.UserNotLoggedInException; import org.craftedsw.tripservicekata.user.User; +import org.junit.Before; import org.junit.Test; public class TripServiceShould { @@ -17,20 +18,22 @@ public class TripServiceShould { private static final User ANOTHER_USER = new User(); private static final Trip TO_BRAZIL = new Trip(); private User loggedInUser; + private TripService tripService; + + @Before + public void setUp() { + tripService = new TesteableTripService(); + } @Test(expected=UserNotLoggedInException.class) public void throw_an_exception_when_user_is_not_logged_in() { - TripService tripService = new TesteableTripService(); - loggedInUser = GUEST; tripService.getTripsByUser(UNUSED_USER); } @Test public void - not_return_any_trips_when_users_are_not_friends() { - TesteableTripService tripService = new TesteableTripService(); - + not_return_any_trips_when_users_are_not_friends() { loggedInUser = REGISTERED_USER; User friend = new User();