diff --git a/backend/src/main/java/dev/tripdraw/domain/trip/Route.java b/backend/src/main/java/dev/tripdraw/domain/trip/Route.java index 59bdb48c4..03efb6512 100644 --- a/backend/src/main/java/dev/tripdraw/domain/trip/Route.java +++ b/backend/src/main/java/dev/tripdraw/domain/trip/Route.java @@ -47,4 +47,10 @@ public void deletePointById(Long pointId) { pointToDelete.delete(); } + + public List points() { + return points.stream() + .filter(point -> !point.isDeleted()) + .toList(); + } } diff --git a/backend/src/main/java/dev/tripdraw/domain/trip/Trip.java b/backend/src/main/java/dev/tripdraw/domain/trip/Trip.java index a426cbbd2..a72e18023 100644 --- a/backend/src/main/java/dev/tripdraw/domain/trip/Trip.java +++ b/backend/src/main/java/dev/tripdraw/domain/trip/Trip.java @@ -152,9 +152,7 @@ public void deletePointById(Long pointId) { } public List points() { - return route.points().stream() - .filter(point -> !point.isDeleted()) - .toList(); + return route.points(); } public String nameValue() { diff --git a/backend/src/test/java/dev/tripdraw/application/TripServiceTest.java b/backend/src/test/java/dev/tripdraw/application/TripServiceTest.java index 2a656cfc8..56eb8db03 100644 --- a/backend/src/test/java/dev/tripdraw/application/TripServiceTest.java +++ b/backend/src/test/java/dev/tripdraw/application/TripServiceTest.java @@ -117,13 +117,10 @@ void setUp() { tripService.deletePoint(loginUser, response.pointId(), trip.id()); // then - Point deletedPoint = trip.route().points() + assertThat(trip.route().points() .stream() - .filter(point -> Objects.equals(point.id(), response.pointId())) - .findFirst() - .get(); - - assertThat(deletedPoint.isDeleted()).isTrue(); + .anyMatch(point -> Objects.equals(point.id(), response.pointId()))) + .isFalse(); } @Test diff --git a/backend/src/test/java/dev/tripdraw/domain/trip/RouteTest.java b/backend/src/test/java/dev/tripdraw/domain/trip/RouteTest.java index ba252bc65..9f4277037 100644 --- a/backend/src/test/java/dev/tripdraw/domain/trip/RouteTest.java +++ b/backend/src/test/java/dev/tripdraw/domain/trip/RouteTest.java @@ -102,5 +102,21 @@ class RouteTest { .isInstanceOf(TripException.class) .hasMessage(POINT_NOT_FOUND.message()); } + + @Test + void 삭제된_위치정보는_반환하지_않는다() { + // given + Route route = new Route(); + Point point1 = new Point(1L, 1.1, 2.1, false, LocalDateTime.now()); + Point point2 = new Point(2L, 3.1, 4.1, false, LocalDateTime.now()); + route.add(point1); + route.add(point2); + + // when + route.deletePointById(1L); + + // then + assertThat(route.points()).containsExactly(point2); + } }