Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

도시 중복 조회 오류 수정 #765

Merged
merged 2 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/src/main/java/hanglog/trip/domain/TripCity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
import jakarta.persistence.ManyToOne;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

@Entity
@Getter
@NoArgsConstructor(access = PROTECTED)
@SQLDelete(sql = "UPDATE trip_city SET status = 'DELETED' WHERE id = ?")
@Where(clause = "status = 'USABLE'")
public class TripCity extends BaseEntity {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,49 @@ void getTrip() {
);
}


@DisplayName("Trip을 수정한다. (도시 수정)")
@Test
void updateTrip_City() {
// given
final ExtractableResponse<Response> tripCreateResponse = requestCreateTrip(memberTokens, TRIP_CREATE_REQUEST);
final Long tripId = Long.parseLong(parseUri(tripCreateResponse.header("Location")));

final TripUpdateRequest tripUpdateRequest = new TripUpdateRequest(
"수정된 여행 제목",
null,
LocalDate.of(2023, 8, 1),
LocalDate.of(2023, 8, 3),
"매번 색다르고 즐거운 서유럽 여행",
List.of(1L, 3L)
);

// when
final ExtractableResponse<Response> response = requestUpdateTrip(memberTokens, tripId, tripUpdateRequest);
final TripDetailResponse tripDetailResponse = requestGetTrip(memberTokens, tripId).as(TripDetailResponse.class);

// then
assertSoftly(
softly -> {
softly.assertThat(response.statusCode()).isEqualTo(HttpStatus.NO_CONTENT.value());
softly.assertThat(tripDetailResponse)
.usingRecursiveComparison()
.comparingOnlyFields("title", "startDate", "endDate", "description", "cities")
.ignoringFieldsMatchingRegexes(".*latitude", ".*longitude")
.isEqualTo(tripUpdateRequest);
softly.assertThat(tripDetailResponse.getCities())
.size()
.isEqualTo(2);
softly.assertThat(tripDetailResponse.getDayLogs())
.size()
.isEqualTo(4);
softly.assertThat(tripDetailResponse.getDayLogs())
.extracting("ordinal")
.containsExactly(1, 2, 3, 4);
}
);
}

@DisplayName("Trip을 수정한다. (여행 기간 감소)")
@Test
void updateTrip_DecreasePeriod() {
Expand Down