Skip to content

Commit b4249e5

Browse files
committed
fix: 핀 조회 요청에 사용자 위치 검증 추가
1 parent 3925dae commit b4249e5

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

src/main/java/com/zimdugo/locker/entrypoint/dto/request/pin/LockerPinRequest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.zimdugo.locker.application.filter.LockerSizeFilterType;
77
import io.swagger.v3.oas.annotations.Parameter;
88
import io.swagger.v3.oas.annotations.media.Schema;
9+
import jakarta.validation.constraints.AssertTrue;
910
import jakarta.validation.constraints.DecimalMax;
1011
import jakarta.validation.constraints.DecimalMin;
1112
import java.util.Set;
@@ -65,6 +66,11 @@ public record LockerPinRequest(
6566
@Parameter(description = "보관함 유형 필터")
6667
Set<LockerFacilityFilterType> lockerTypes
6768
) {
69+
@AssertTrue(message = "validation.user_location_required")
70+
public boolean hasUserLocation() {
71+
return lat != null && lng != null;
72+
}
73+
6874
public LockerPinQuery toQuery() {
6975
return new LockerPinQuery(
7076
swLat,
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.zimdugo.locker.entrypoint.dto.request.pin;
2+
3+
import org.junit.jupiter.api.DisplayName;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.assertj.core.api.Assertions.assertThat;
7+
8+
class LockerPinRequestTest {
9+
10+
@Test
11+
@DisplayName("사용자 기준 좌표는 키워드와 무관하게 항상 필요하다")
12+
void rejectsMissingLocationEvenWithoutKeyword() {
13+
LockerPinRequest request = new LockerPinRequest(
14+
37.54,
15+
126.92,
16+
37.56,
17+
126.94,
18+
13.0,
19+
null,
20+
null,
21+
null,
22+
null,
23+
null,
24+
null
25+
);
26+
27+
assertThat(request.hasUserLocation()).isFalse();
28+
}
29+
30+
@Test
31+
@DisplayName("키워드 검색이면 기준 좌표가 없을 때도 유효하지 않다")
32+
void rejectsMissingKeywordLocation() {
33+
LockerPinRequest request = new LockerPinRequest(
34+
37.54,
35+
126.92,
36+
37.56,
37+
126.94,
38+
13.0,
39+
null,
40+
null,
41+
"station",
42+
null,
43+
null,
44+
null
45+
);
46+
47+
assertThat(request.hasUserLocation()).isFalse();
48+
}
49+
50+
@Test
51+
@DisplayName("사용자 기준 좌표가 모두 있으면 유효하다")
52+
void acceptsCompleteLocation() {
53+
LockerPinRequest request = new LockerPinRequest(
54+
37.54,
55+
126.92,
56+
37.56,
57+
126.94,
58+
13.0,
59+
37.55,
60+
126.93,
61+
"station",
62+
null,
63+
null,
64+
null
65+
);
66+
67+
assertThat(request.hasUserLocation()).isTrue();
68+
}
69+
}

0 commit comments

Comments
 (0)