From e2d33188d245dcd310132a3d9a96230b6fed7eea Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 27 Nov 2016 15:10:52 +0100 Subject: [PATCH] TripService we can refactor as much as we want because everything is under test. Creating validate method. --- .../java/org/craftedsw/tripservicekata/trip/TripService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 bd899a2..276710f 100644 --- a/TDD/src/main/java/org/craftedsw/tripservicekata/trip/TripService.java +++ b/TDD/src/main/java/org/craftedsw/tripservicekata/trip/TripService.java @@ -18,15 +18,19 @@ public class TripService { } public List getTripsByUser(User user, User loggedInUser) throws UserNotLoggedInException { - if (loggedInUser == null) { - throw new UserNotLoggedInException(); - } + validate(loggedInUser); return user.isFriendsWith(loggedInUser) ? tripsBy(user) : noTrips(); } + private void validate(User loggedInUser) { + if (loggedInUser == null) { + throw new UserNotLoggedInException(); + } + } + private ArrayList noTrips() { return new ArrayList<>(); } -- 2.1.4