Skip to content

Commit ce7ec93

Browse files
committed
refactor(community): 코드 리뷰 사항 반영
- repository 테스트 usecase 주입 - getWriterDetail 메서드 else문 삭제
1 parent c57f4dd commit ce7ec93

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/main/java/com/somemore/community/service/query/CommunityBoardQueryService.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import java.util.List;
1818
import java.util.UUID;
19-
import java.util.stream.Collectors;
2019

2120
import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_COMMUNITY_BOARD;
2221

@@ -66,7 +65,6 @@ private String getWriterNickname(UUID writerId) {
6665
if (nickname == null) {
6766
nickname = centerQueryUseCase.getNameById(writerId);
6867
}
69-
7068
return nickname;
7169
}
7270

@@ -75,8 +73,7 @@ private WriterDetailDto getWriterDetail(UUID writerId) {
7573

7674
if (volunteer == null) {
7775
return centerQueryUseCase.getCenterDetailForCommunity(writerId);
78-
} else {
79-
return volunteer;
8076
}
77+
return volunteer;
8178
}
8279
}

src/test/java/com/somemore/community/service/query/CommunityBoardQueryServiceTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import com.somemore.community.dto.response.CommunityBoardGetDetailResponseDto;
1010
import com.somemore.community.dto.response.CommunityBoardGetResponseDto;
1111
import com.somemore.community.repository.CommunityBoardRepository;
12-
import com.somemore.community.service.command.CreateCommunityBoardService;
12+
import com.somemore.community.usecase.command.CreateCommunityBoardUseCase;
1313
import com.somemore.global.exception.BadRequestException;
1414
import com.somemore.global.exception.ExceptionMessage;
1515
import com.somemore.volunteer.domain.Volunteer;
@@ -35,7 +35,7 @@ class CommunityBoardQueryServiceTest extends IntegrationTestSupport {
3535
@Autowired
3636
CenterRepository centerRepository;
3737
@Autowired
38-
CreateCommunityBoardService createCommunityBoardService;
38+
CreateCommunityBoardUseCase createCommunityBoardUseCase;
3939
@Autowired
4040
CommunityBoardQueryService communityBoardQueryService;
4141

@@ -52,7 +52,7 @@ void getAllCommunityBoards() {
5252
String oAuthId = "example-oauth-id";
5353
Volunteer volunteer = Volunteer.createDefault(OAuthProvider.NAVER, oAuthId);
5454

55-
Volunteer savedVolunteer = volunteerRepository.save(volunteer);
55+
Volunteer savedVolunteer = volunteerRepository.save(volunteer);
5656

5757
Center center = Center.create(
5858
"기본 기관 이름",
@@ -78,8 +78,8 @@ void getAllCommunityBoards() {
7878

7979
String imgUrl1 = "https://image.test.url/123";
8080

81-
Long communityId1 = createCommunityBoardService.createCommunityBoard(dto1, savedCenter.getId(), null);
82-
Long communityId2 = createCommunityBoardService.createCommunityBoard(dto2, savedVolunteer.getId(), imgUrl1);
81+
Long communityId1 = createCommunityBoardUseCase.createCommunityBoard(dto1, savedCenter.getId(), null);
82+
Long communityId2 = createCommunityBoardUseCase.createCommunityBoard(dto2, savedVolunteer.getId(), imgUrl1);
8383

8484
// when
8585
List<CommunityBoardGetResponseDto> dtos = communityBoardQueryService.getCommunityBoards();
@@ -128,8 +128,8 @@ void getCommunityBoardsByWriter() {
128128

129129
String imgUrl1 = "https://image.test.url/123";
130130

131-
Long communityId1 = createCommunityBoardService.createCommunityBoard(dto1, savedVolunteer.getId(), null);
132-
Long communityId2 = createCommunityBoardService.createCommunityBoard(dto2, savedVolunteer.getId(), imgUrl1);
131+
Long communityId1 = createCommunityBoardUseCase.createCommunityBoard(dto1, savedVolunteer.getId(), null);
132+
Long communityId2 = createCommunityBoardUseCase.createCommunityBoard(dto2, savedVolunteer.getId(), imgUrl1);
133133

134134
//when
135135
List<CommunityBoardGetResponseDto> dtos = communityBoardQueryService.getCommunityBoardsByWriterId(volunteer.getId());
@@ -172,7 +172,7 @@ void getCommunityBoardDetail() {
172172

173173
String imgUrl = "https://image.test.url/123";
174174

175-
Long communityId1 = createCommunityBoardService.createCommunityBoard(dto1, savedVolunteer.getId(), imgUrl);
175+
Long communityId1 = createCommunityBoardUseCase.createCommunityBoard(dto1, savedVolunteer.getId(), imgUrl);
176176

177177
//when
178178
CommunityBoardGetDetailResponseDto communityBoard = communityBoardQueryService.getCommunityBoardDetail(communityId1);
@@ -207,7 +207,7 @@ void getCommunityBoardDetailWithDeletedId() {
207207

208208
String imgUrl = "https://image.test.url/123";
209209

210-
Long communityId = createCommunityBoardService.createCommunityBoard(dto1, savedVolunteer.getId(), imgUrl);
210+
Long communityId = createCommunityBoardUseCase.createCommunityBoard(dto1, savedVolunteer.getId(), imgUrl);
211211

212212
communityBoardRepository.deleteAllInBatch();
213213

0 commit comments

Comments
 (0)