Skip to content

Commit f82a896

Browse files
committed
refactor: duplicated code 제거
1 parent e22de4a commit f82a896

File tree

2 files changed

+116
-128
lines changed

2 files changed

+116
-128
lines changed

src/test/java/com/somemore/common/fixture/RecruitBoardFixture.java

Lines changed: 110 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -11,259 +11,247 @@
1111

1212
public class RecruitBoardFixture {
1313

14+
public static final String REGION = "경기";
15+
public static final int RECRUITMENT_COUNT = 1;
16+
public static final LocalDateTime START_DATE_TIME = createStartDateTime();
17+
public static final LocalDateTime END_DATE_TIME = START_DATE_TIME.plusHours(1);
18+
public static final boolean ADMITTED = true;
19+
public static final long LOCATION_ID = 1L;
20+
public static final String TITLE = "봉사모집제목";
21+
public static final String CONTENT = "봉사모집내용";
22+
public static final String IMG_URL = "https://image.domain.com/links";
23+
public static final VolunteerType VOLUNTEER_TYPE = OTHER;
24+
1425
private RecruitBoardFixture() {
1526
}
1627

1728
public static RecruitBoard createRecruitBoard() {
18-
LocalDateTime startDateTime = createStartDateTime();
19-
LocalDateTime endDateTime = startDateTime.plusHours(1);
2029

2130
RecruitmentInfo recruitmentInfo = RecruitmentInfo.builder()
22-
.region("경기")
23-
.recruitmentCount(1)
24-
.volunteerStartDateTime(startDateTime)
25-
.volunteerEndDateTime(endDateTime)
26-
.volunteerType(OTHER)
27-
.admitted(true)
31+
.region(REGION)
32+
.recruitmentCount(RECRUITMENT_COUNT)
33+
.volunteerStartDateTime(START_DATE_TIME)
34+
.volunteerEndDateTime(END_DATE_TIME)
35+
.volunteerType(VOLUNTEER_TYPE)
36+
.admitted(ADMITTED)
2837
.build();
2938

3039
return RecruitBoard.builder()
3140
.centerId(UUID.randomUUID())
32-
.locationId(1L)
33-
.title("봉사모집제목")
34-
.content("봉사모집내용")
35-
.imgUrl("https://image.domain.com/links")
41+
.locationId(LOCATION_ID)
42+
.title(TITLE)
43+
.content(CONTENT)
44+
.imgUrl(IMG_URL)
3645
.recruitmentInfo(recruitmentInfo)
3746
.build();
3847
}
3948

4049
public static RecruitBoard createRecruitBoard(String title) {
41-
LocalDateTime startDateTime = createStartDateTime();
42-
LocalDateTime endDateTime = startDateTime.plusHours(1);
4350

4451
RecruitmentInfo recruitmentInfo = RecruitmentInfo.builder()
45-
.region("경기")
46-
.recruitmentCount(1)
47-
.volunteerStartDateTime(startDateTime)
48-
.volunteerEndDateTime(endDateTime)
49-
.volunteerType(OTHER)
50-
.admitted(true)
52+
.region(REGION)
53+
.recruitmentCount(RECRUITMENT_COUNT)
54+
.volunteerStartDateTime(START_DATE_TIME)
55+
.volunteerEndDateTime(END_DATE_TIME)
56+
.volunteerType(VOLUNTEER_TYPE)
57+
.admitted(ADMITTED)
5158
.build();
5259

5360
return RecruitBoard.builder()
5461
.centerId(UUID.randomUUID())
55-
.locationId(1L)
56-
.title(title)
57-
.content("봉사모집내용")
58-
.imgUrl("https://image.domain.com/links")
62+
.locationId(LOCATION_ID)
63+
.title(TITLE)
64+
.content(CONTENT)
65+
.imgUrl(IMG_URL)
5966
.recruitmentInfo(recruitmentInfo)
6067
.build();
6168
}
6269

6370
public static RecruitBoard createRecruitBoard(String title, UUID centerId, Long locationId) {
64-
LocalDateTime startDateTime = createStartDateTime();
65-
LocalDateTime endDateTime = startDateTime.plusHours(1);
6671

6772
RecruitmentInfo recruitmentInfo = RecruitmentInfo.builder()
68-
.region("경기")
69-
.recruitmentCount(1)
70-
.volunteerStartDateTime(startDateTime)
71-
.volunteerEndDateTime(endDateTime)
72-
.volunteerType(OTHER)
73-
.admitted(true)
73+
.region(REGION)
74+
.recruitmentCount(RECRUITMENT_COUNT)
75+
.volunteerStartDateTime(START_DATE_TIME)
76+
.volunteerEndDateTime(END_DATE_TIME)
77+
.volunteerType(VOLUNTEER_TYPE)
78+
.admitted(ADMITTED)
7479
.build();
7580

7681
return RecruitBoard.builder()
7782
.centerId(centerId)
7883
.locationId(locationId)
7984
.title(title)
80-
.content("봉사모집내용")
81-
.imgUrl("https://image.domain.com/links")
85+
.content(CONTENT)
86+
.imgUrl(IMG_URL)
8287
.recruitmentInfo(recruitmentInfo)
8388
.build();
8489
}
8590

8691
public static RecruitBoard createRecruitBoard(String title, UUID centerId) {
87-
LocalDateTime startDateTime = createStartDateTime();
88-
LocalDateTime endDateTime = startDateTime.plusHours(1);
8992

9093
RecruitmentInfo recruitmentInfo = RecruitmentInfo.builder()
91-
.region("경기")
92-
.recruitmentCount(1)
93-
.volunteerStartDateTime(startDateTime)
94-
.volunteerEndDateTime(endDateTime)
95-
.volunteerType(OTHER)
96-
.admitted(true)
94+
.region(REGION)
95+
.recruitmentCount(RECRUITMENT_COUNT)
96+
.volunteerStartDateTime(START_DATE_TIME)
97+
.volunteerEndDateTime(END_DATE_TIME)
98+
.volunteerType(VOLUNTEER_TYPE)
99+
.admitted(ADMITTED)
97100
.build();
98101

99102
return RecruitBoard.builder()
100103
.centerId(centerId)
101-
.locationId(1L)
104+
.locationId(LOCATION_ID)
102105
.title(title)
103-
.content("봉사모집내용")
104-
.imgUrl("https://image.domain.com/links")
106+
.content(CONTENT)
107+
.imgUrl(IMG_URL)
105108
.recruitmentInfo(recruitmentInfo)
106109
.build();
107110
}
108111

109112
public static RecruitBoard createRecruitBoard(VolunteerType type, UUID centerId) {
110-
LocalDateTime startDateTime = createStartDateTime();
111-
LocalDateTime endDateTime = startDateTime.plusHours(1);
112113

113114
RecruitmentInfo recruitmentInfo = RecruitmentInfo.builder()
114-
.region("경기")
115-
.recruitmentCount(1)
116-
.volunteerStartDateTime(startDateTime)
117-
.volunteerEndDateTime(endDateTime)
115+
.region(REGION)
116+
.recruitmentCount(RECRUITMENT_COUNT)
117+
.volunteerStartDateTime(START_DATE_TIME)
118+
.volunteerEndDateTime(END_DATE_TIME)
118119
.volunteerType(type)
119-
.admitted(true)
120+
.admitted(ADMITTED)
120121
.build();
121122

122123
return RecruitBoard.builder()
123124
.centerId(centerId)
124-
.locationId(1L)
125-
.title("봉사모집제목")
126-
.content("봉사모집내용")
127-
.imgUrl("https://image.domain.com/links")
125+
.locationId(LOCATION_ID)
126+
.title(TITLE)
127+
.content(CONTENT)
128+
.imgUrl(IMG_URL)
128129
.recruitmentInfo(recruitmentInfo)
129130
.build();
130131
}
131132

132133
public static RecruitBoard createRecruitBoard(Boolean admitted, UUID centerId) {
133-
LocalDateTime startDateTime = createStartDateTime();
134-
LocalDateTime endDateTime = startDateTime.plusHours(1);
135134

136135
RecruitmentInfo recruitmentInfo = RecruitmentInfo.builder()
137-
.region("경기")
138-
.recruitmentCount(1)
139-
.volunteerStartDateTime(startDateTime)
140-
.volunteerEndDateTime(endDateTime)
141-
.volunteerType(OTHER)
136+
.region(REGION)
137+
.recruitmentCount(RECRUITMENT_COUNT)
138+
.volunteerStartDateTime(START_DATE_TIME)
139+
.volunteerEndDateTime(END_DATE_TIME)
140+
.volunteerType(VOLUNTEER_TYPE)
142141
.admitted(admitted)
143142
.build();
144143

145144
return RecruitBoard.builder()
146145
.centerId(centerId)
147-
.locationId(1L)
148-
.title("봉사모집제목")
149-
.content("봉사모집내용")
150-
.imgUrl("https://image.domain.com/links")
146+
.locationId(LOCATION_ID)
147+
.title(TITLE)
148+
.content(CONTENT)
149+
.imgUrl(IMG_URL)
151150
.recruitmentInfo(recruitmentInfo)
152151
.build();
153152
}
154153

155-
156154
public static RecruitBoard createRecruitBoard(Long locationId) {
157-
LocalDateTime startDateTime = createStartDateTime();
158-
LocalDateTime endDateTime = startDateTime.plusHours(1);
159155

160156
RecruitmentInfo recruitmentInfo = RecruitmentInfo.builder()
161-
.region("경기")
162-
.recruitmentCount(1)
163-
.volunteerStartDateTime(startDateTime)
164-
.volunteerEndDateTime(endDateTime)
165-
.volunteerType(OTHER)
166-
.admitted(true)
157+
.region(REGION)
158+
.recruitmentCount(RECRUITMENT_COUNT)
159+
.volunteerStartDateTime(START_DATE_TIME)
160+
.volunteerEndDateTime(END_DATE_TIME)
161+
.volunteerType(VOLUNTEER_TYPE)
162+
.admitted(ADMITTED)
167163
.build();
168164

169165
return RecruitBoard.builder()
170166
.centerId(UUID.randomUUID())
171167
.locationId(locationId)
172-
.title("봉사모집제목")
173-
.content("봉사모집내용")
174-
.imgUrl("https://image.domain.com/links")
168+
.title(TITLE)
169+
.content(CONTENT)
170+
.imgUrl(IMG_URL)
175171
.recruitmentInfo(recruitmentInfo)
176172
.build();
177173
}
178174

179175
public static RecruitBoard createRecruitBoard(UUID centerId) {
180-
LocalDateTime startDateTime = createStartDateTime();
181-
LocalDateTime endDateTime = startDateTime.plusHours(1);
182176

183177
RecruitmentInfo recruitmentInfo = RecruitmentInfo.builder()
184-
.region("경기")
185-
.recruitmentCount(1)
186-
.volunteerStartDateTime(startDateTime)
187-
.volunteerEndDateTime(endDateTime)
188-
.volunteerType(OTHER)
189-
.admitted(true)
178+
.region(REGION)
179+
.recruitmentCount(RECRUITMENT_COUNT)
180+
.volunteerStartDateTime(START_DATE_TIME)
181+
.volunteerEndDateTime(END_DATE_TIME)
182+
.volunteerType(VOLUNTEER_TYPE)
183+
.admitted(ADMITTED)
190184
.build();
191185

192186
return RecruitBoard.builder()
193187
.centerId(centerId)
194-
.locationId(1L)
195-
.title("봉사모집제목")
196-
.content("봉사모집내용")
197-
.imgUrl("https://image.domain.com/links")
188+
.locationId(LOCATION_ID)
189+
.title(TITLE)
190+
.content(CONTENT)
191+
.imgUrl(IMG_URL)
198192
.recruitmentInfo(recruitmentInfo)
199193
.build();
200194
}
201195

202196
public static RecruitBoard createRecruitBoard(UUID centerId, Long locationId) {
203-
LocalDateTime startDateTime = createStartDateTime();
204-
LocalDateTime endDateTime = startDateTime.plusHours(1);
205197

206198
RecruitmentInfo recruitmentInfo = RecruitmentInfo.builder()
207-
.region("경기")
208-
.recruitmentCount(1)
209-
.volunteerStartDateTime(startDateTime)
210-
.volunteerEndDateTime(endDateTime)
211-
.volunteerType(OTHER)
212-
.admitted(true)
199+
.region(REGION)
200+
.recruitmentCount(RECRUITMENT_COUNT)
201+
.volunteerStartDateTime(START_DATE_TIME)
202+
.volunteerEndDateTime(END_DATE_TIME)
203+
.volunteerType(VOLUNTEER_TYPE)
204+
.admitted(ADMITTED)
213205
.build();
214206

215207
return RecruitBoard.builder()
216208
.centerId(centerId)
217209
.locationId(locationId)
218-
.title("봉사모집제목")
219-
.content("봉사모집내용")
220-
.imgUrl("https://image.domain.com/links")
210+
.title(TITLE)
211+
.content(CONTENT)
212+
.imgUrl(IMG_URL)
221213
.recruitmentInfo(recruitmentInfo)
222214
.build();
223215
}
224216

225217
public static RecruitBoard createRecruitBoard(String region, VolunteerType volunteerType) {
226-
LocalDateTime startDateTime = createStartDateTime();
227-
LocalDateTime endDateTime = startDateTime.plusHours(1);
228218

229219
RecruitmentInfo recruitmentInfo = RecruitmentInfo.builder()
230220
.region(region)
231-
.recruitmentCount(1)
232-
.volunteerStartDateTime(startDateTime)
233-
.volunteerEndDateTime(endDateTime)
221+
.recruitmentCount(RECRUITMENT_COUNT)
222+
.volunteerStartDateTime(START_DATE_TIME)
223+
.volunteerEndDateTime(END_DATE_TIME)
234224
.volunteerType(volunteerType)
235-
.admitted(true)
225+
.admitted(ADMITTED)
236226
.build();
237227

238228
return RecruitBoard.builder()
239229
.centerId(UUID.randomUUID())
240-
.locationId(1L)
241-
.title("봉사모집제목")
242-
.content("봉사모집내용")
243-
.imgUrl("https://image.domain.com/links")
230+
.locationId(LOCATION_ID)
231+
.title(TITLE)
232+
.content(CONTENT)
233+
.imgUrl(IMG_URL)
244234
.recruitmentInfo(recruitmentInfo)
245235
.build();
246236
}
247237

248238
public static RecruitBoard createRecruitBoard(Long locationId, String title) {
249-
LocalDateTime startDateTime = createStartDateTime();
250-
LocalDateTime endDateTime = startDateTime.plusHours(1);
251239

252240
RecruitmentInfo recruitmentInfo = RecruitmentInfo.builder()
253-
.region("경기")
254-
.recruitmentCount(1)
255-
.volunteerStartDateTime(startDateTime)
256-
.volunteerEndDateTime(endDateTime)
257-
.volunteerType(OTHER)
258-
.admitted(true)
241+
.region(REGION)
242+
.recruitmentCount(RECRUITMENT_COUNT)
243+
.volunteerStartDateTime(START_DATE_TIME)
244+
.volunteerEndDateTime(END_DATE_TIME)
245+
.volunteerType(VOLUNTEER_TYPE)
246+
.admitted(ADMITTED)
259247
.build();
260248

261249
return RecruitBoard.builder()
262250
.centerId(UUID.randomUUID())
263251
.locationId(locationId)
264252
.title(title)
265-
.content("봉사모집내용")
266-
.imgUrl("https://image.domain.com/links")
253+
.content(CONTENT)
254+
.imgUrl(IMG_URL)
267255
.recruitmentInfo(recruitmentInfo)
268256
.build();
269257
}

0 commit comments

Comments
 (0)