File tree Expand file tree Collapse file tree
main/java/com/zimdugo/locker/entrypoint/dto/request/pin
test/java/com/zimdugo/locker/entrypoint/dto/request/pin Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66import com .zimdugo .locker .application .filter .LockerSizeFilterType ;
77import io .swagger .v3 .oas .annotations .Parameter ;
88import io .swagger .v3 .oas .annotations .media .Schema ;
9+ import jakarta .validation .constraints .AssertTrue ;
910import jakarta .validation .constraints .DecimalMax ;
1011import jakarta .validation .constraints .DecimalMin ;
1112import 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 ,
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments