Removing duplicated code
authorGustavo Martin Morcuende <gustavo.martin@scmspain.com>
Wed, 23 Nov 2016 20:31:23 +0000 (21:31 +0100)
committerGustavo Martin Morcuende <gustavo.martin@scmspain.com>
Wed, 23 Nov 2016 20:31:23 +0000 (21:31 +0100)
TDD/src/test/java/org/craftedsw/tripservicekata/trip/TripServiceShould.java

index 136c953..7243417 100644 (file)
@@ -1,12 +1,13 @@
 package org.craftedsw.tripservicekata.trip;\r
 \r
-import static org.junit.Assert.assertThat;\r
 import static org.hamcrest.core.Is.is;\r
+import static org.junit.Assert.assertThat;\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.Before;\r
 import org.junit.Test;\r
 \r
 public class TripServiceShould {\r
@@ -17,20 +18,22 @@ public class TripServiceShould {
        private static final User ANOTHER_USER = new User();\r
        private static final Trip TO_BRAZIL = new Trip();\r
        private User loggedInUser;\r
+       private TripService tripService;\r
+       \r
+       @Before\r
+       public void setUp() {\r
+               tripService = new TesteableTripService();\r
+       }\r
 \r
        @Test(expected=UserNotLoggedInException.class) public void\r
        throw_an_exception_when_user_is_not_logged_in() {\r
-               TripService tripService = new TesteableTripService();\r
-               \r
                loggedInUser = GUEST;\r
                \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
+       not_return_any_trips_when_users_are_not_friends() {             \r
                loggedInUser = REGISTERED_USER;\r
                \r
                User friend = new User();\r