Skip to content

Commit c04d2a0

Browse files
committed
chore: sonarqube 이슈 해결
1 parent 1e2481f commit c04d2a0

File tree

1 file changed

+24
-35
lines changed

1 file changed

+24
-35
lines changed

src/test/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryServiceTest.java

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ void getByIdWhenDoesNotExist() {
8080
void getByRecruitIdAndVolunteerId() {
8181
// given
8282
// when
83-
VolunteerApply apply = volunteerApplyQueryService.getByRecruitIdAndVolunteerId(recruitBoardId, volunteerId);
83+
VolunteerApply findApply = volunteerApplyQueryService.getByRecruitIdAndVolunteerId(recruitBoardId, volunteerId);
8484

8585
// then
86-
assertThat(apply.getRecruitBoardId()).isEqualTo(recruitBoardId);
87-
assertThat(apply.getVolunteerId()).isEqualTo(volunteerId);
86+
assertThat(findApply.getRecruitBoardId()).isEqualTo(recruitBoardId);
87+
assertThat(findApply.getVolunteerId()).isEqualTo(volunteerId);
8888
}
8989

9090
@DisplayName("존재하지 않는 모집글 아이디와 봉사자 아이디로 조회할 수 있다")
@@ -110,21 +110,21 @@ void getSummaryByRecruitBoardId() {
110110
long approveCount = 10;
111111
long rejectCount = 2;
112112
long waitingCount = 5;
113-
long recruitBoardId = 100L;
113+
long recruitId = 100L;
114114

115115
for (int i = 0; i < waitingCount; i++) {
116-
volunteerApplyRepository.save(createApply(UUID.randomUUID(), recruitBoardId, WAITING));
116+
volunteerApplyRepository.save(createApply(UUID.randomUUID(), recruitId, WAITING));
117117
}
118118
for (int i = 0; i < approveCount; i++) {
119-
volunteerApplyRepository.save(createApply(UUID.randomUUID(), recruitBoardId, APPROVED));
119+
volunteerApplyRepository.save(createApply(UUID.randomUUID(), recruitId, APPROVED));
120120
}
121121
for (int i = 0; i < rejectCount; i++) {
122-
volunteerApplyRepository.save(createApply(UUID.randomUUID(), recruitBoardId, REJECTED));
122+
volunteerApplyRepository.save(createApply(UUID.randomUUID(), recruitId, REJECTED));
123123
}
124124

125125
// when
126-
VolunteerApplySummaryResponseDto dto = volunteerApplyQueryService.getSummaryByRecruitId(
127-
recruitBoardId);
126+
VolunteerApplySummaryResponseDto dto = volunteerApplyQueryService.getSummaryByRecruitId(recruitId);
127+
128128
// then
129129
assertThat(dto.waiting()).isEqualTo(waitingCount);
130130
assertThat(dto.approve()).isEqualTo(approveCount);
@@ -135,18 +135,12 @@ void getSummaryByRecruitBoardId() {
135135
@Test
136136
void getVolunteerApplyByRecruitIdAndVolunteerId() {
137137
// given
138-
Long recruitId = 1234L;
139-
UUID volunteerId = UUID.randomUUID();
140-
141-
VolunteerApply newApply = createApply(volunteerId, recruitId);
142-
volunteerApplyRepository.save(newApply);
143-
144138
// when
145139
VolunteerApplyResponseDto dto = volunteerApplyQueryService.getVolunteerApplyByRecruitIdAndVolunteerId(
146-
recruitId, volunteerId);
140+
recruitBoardId, volunteerId);
147141

148142
// then
149-
assertThat(dto.recruitBoardId()).isEqualTo(recruitId);
143+
assertThat(dto.recruitBoardId()).isEqualTo(recruitBoardId);
150144
assertThat(dto.volunteerId()).isEqualTo(volunteerId);
151145
}
152146

@@ -164,8 +158,7 @@ void getAllByRecruitId() {
164158
.build();
165159

166160
// when
167-
Page<VolunteerApply> applies = volunteerApplyQueryService.getAllByRecruitId(boardId,
168-
condition);
161+
Page<VolunteerApply> applies = volunteerApplyQueryService.getAllByRecruitId(boardId, condition);
169162

170163
// then
171164
assertThat(applies).hasSize(2);
@@ -175,11 +168,11 @@ void getAllByRecruitId() {
175168
@Test
176169
void getVolunteerAppliesByVolunteerId() {
177170
// given
178-
UUID volunteerId = UUID.randomUUID();
171+
UUID volunteerOneId = UUID.randomUUID();
179172

180-
VolunteerApply apply1 = createApply(volunteerId, 200L);
181-
VolunteerApply apply2 = createApply(volunteerId, 201L);
182-
VolunteerApply apply3 = createApply(volunteerId, 202L);
173+
VolunteerApply apply1 = createApply(volunteerOneId, 200L);
174+
VolunteerApply apply2 = createApply(volunteerOneId, 201L);
175+
VolunteerApply apply3 = createApply(volunteerOneId, 202L);
183176
VolunteerApply apply4 = createApply(UUID.randomUUID(), 203L);
184177
volunteerApplyRepository.saveAll(List.of(apply1, apply2, apply3, apply4));
185178

@@ -189,7 +182,7 @@ void getVolunteerAppliesByVolunteerId() {
189182

190183
// when
191184
Page<VolunteerApply> applies = volunteerApplyQueryService.getAllByVolunteerId(
192-
volunteerId, condition);
185+
volunteerOneId, condition);
193186

194187
// then
195188
assertThat(applies).hasSize(3);
@@ -199,16 +192,12 @@ void getVolunteerAppliesByVolunteerId() {
199192
@Test
200193
void getAllByIds() {
201194
// given
202-
Long recruitBoardId = 1L;
195+
Long recruitId = 1L;
203196

204-
VolunteerApply apply1 = volunteerApplyRepository.save(
205-
createApply(UUID.randomUUID(), recruitBoardId));
206-
VolunteerApply apply2 = volunteerApplyRepository.save(
207-
createApply(UUID.randomUUID(), recruitBoardId));
208-
VolunteerApply apply3 = volunteerApplyRepository.save(
209-
createApply(UUID.randomUUID(), recruitBoardId));
210-
VolunteerApply apply4 = volunteerApplyRepository.save(
211-
createApply(UUID.randomUUID(), recruitBoardId));
197+
VolunteerApply apply1 = volunteerApplyRepository.save(createApply(UUID.randomUUID(), recruitId));
198+
VolunteerApply apply2 = volunteerApplyRepository.save(createApply(UUID.randomUUID(), recruitId));
199+
VolunteerApply apply3 = volunteerApplyRepository.save(createApply(UUID.randomUUID(), recruitId));
200+
VolunteerApply apply4 = volunteerApplyRepository.save(createApply(UUID.randomUUID(), recruitId));
212201

213202
List<Long> ids = List.of(apply1.getId(), apply2.getId(), apply3.getId(), apply4.getId());
214203

@@ -258,8 +247,8 @@ void getByRecruitIdAndVolunteerIdWhenNotExist() {
258247
// then
259248
assertThatThrownBy(
260249
() -> volunteerApplyQueryService.getByRecruitIdAndVolunteerId(wrongBoardId,
261-
wrongVolunteerId)
262-
).isInstanceOf(NoSuchElementException.class)
250+
wrongVolunteerId))
251+
.isInstanceOf(NoSuchElementException.class)
263252
.hasMessage(NOT_EXISTS_VOLUNTEER_APPLY.getMessage());
264253
}
265254

0 commit comments

Comments
 (0)