Skip to content

Commit c57f4dd

Browse files
committed
fix(community): sonarqube 이슈 사항 반영
1 parent d625dae commit c57f4dd

File tree

4 files changed

+15
-31
lines changed

4 files changed

+15
-31
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public List<CommunityBoardGetResponseDto> getCommunityBoards() {
3939
String writerNickname = getWriterNickname(board.getWriterId());
4040
return CommunityBoardGetResponseDto.fromEntity(board, writerNickname);
4141
})
42-
.collect(Collectors.toList());
42+
.toList();
4343
}
4444

4545
@Override
@@ -49,7 +49,7 @@ public List<CommunityBoardGetResponseDto> getCommunityBoardsByWriterId(UUID writ
4949

5050
return boards.stream()
5151
.map(board -> CommunityBoardGetResponseDto.fromEntity(board, writerNickname))
52-
.collect(Collectors.toList());
52+
.toList();
5353
}
5454

5555
@Override

src/test/java/com/somemore/community/repository/CommunityRepositoryTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
import java.util.Optional;
1212
import java.util.UUID;
1313

14-
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
15-
14+
import static org.assertj.core.api.Assertions.assertThat;
1615

1716
@Transactional
18-
public class CommunityRepositoryTest extends IntegrationTestSupport {
17+
class CommunityRepositoryTest extends IntegrationTestSupport {
1918

2019
@Autowired
2120
private CommunityBoardRepository communityBoardRepository;
@@ -69,7 +68,7 @@ void getCommunityBoards() {
6968
List<CommunityBoard> communityBoards = communityBoardRepository.getCommunityBoards();
7069

7170
//then
72-
assertThat(communityBoards.size()).isEqualTo(2);
71+
assertThat(communityBoards).hasSize(2);
7372
assertThat(communityBoards.get(0)).isEqualTo(communityBoard2);
7473
assertThat(communityBoards.get(1)).isEqualTo(communityBoard1);
7574
}
@@ -107,7 +106,7 @@ void getCommunityBoardsByWriterId() {
107106
List<CommunityBoard> communityBoards = communityBoardRepository.getCommunityBoardsByWriterId(communityBoard1.getWriterId());
108107

109108
//then
110-
assertThat(communityBoards.size()).isEqualTo(2);
109+
assertThat(communityBoards).hasSize(2);
111110
assertThat(communityBoards.get(0)).isEqualTo(communityBoard2);
112111
assertThat(communityBoards.get(1)).isEqualTo(communityBoard1);
113112
}

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

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ void getAllCommunityBoards() {
8888
Optional<CommunityBoard> communityBoard1 = communityBoardRepository.findById(communityId1);
8989
Optional<CommunityBoard> communityBoard2 = communityBoardRepository.findById(communityId2);
9090

91-
assertThat(dtos).isNotNull();
92-
assertThat(dtos).hasSize(2);
91+
92+
assertThat(dtos)
93+
.isNotNull()
94+
.hasSize(2);
9395

9496
CommunityBoardGetResponseDto board1 = dtos.getLast();
9597
assertThat(board1.id()).isEqualTo(communityId1);
@@ -114,17 +116,6 @@ void getCommunityBoardsByWriter() {
114116

115117
Volunteer savedVolunteer = volunteerRepository.save(volunteer);
116118

117-
Center center = Center.create(
118-
"기본 기관 이름",
119-
"010-1234-5678",
120-
"http://example.com/image.jpg",
121-
"기관 소개 내용",
122-
"http://example.com",
123-
"account123",
124-
"password123"
125-
);
126-
Center savedCenter = centerRepository.save(center);
127-
128119
CommunityBoardCreateRequestDto dto1 = CommunityBoardCreateRequestDto.builder()
129120
.title("커뮤니티 테스트 제목1")
130121
.content("커뮤니티 테스트 내용1")
@@ -135,16 +126,10 @@ void getCommunityBoardsByWriter() {
135126
.content("커뮤니티 테스트 내용2")
136127
.build();
137128

138-
CommunityBoardCreateRequestDto dto3 = CommunityBoardCreateRequestDto.builder()
139-
.title("커뮤니티 테스트 제목3")
140-
.content("커뮤니티 테스트 내용23")
141-
.build();
142-
143129
String imgUrl1 = "https://image.test.url/123";
144130

145131
Long communityId1 = createCommunityBoardService.createCommunityBoard(dto1, savedVolunteer.getId(), null);
146132
Long communityId2 = createCommunityBoardService.createCommunityBoard(dto2, savedVolunteer.getId(), imgUrl1);
147-
Long communityId3 = createCommunityBoardService.createCommunityBoard(dto3, savedCenter.getId(), imgUrl1);
148133

149134
//when
150135
List<CommunityBoardGetResponseDto> dtos = communityBoardQueryService.getCommunityBoardsByWriterId(volunteer.getId());
@@ -153,8 +138,9 @@ void getCommunityBoardsByWriter() {
153138
Optional<CommunityBoard> communityBoard1 = communityBoardRepository.findById(communityId1);
154139
Optional<CommunityBoard> communityBoard2 = communityBoardRepository.findById(communityId2);
155140

156-
assertThat(dtos).isNotNull();
157-
assertThat(dtos).hasSize(2);
141+
assertThat(dtos)
142+
.isNotNull()
143+
.hasSize(2);
158144

159145
CommunityBoardGetResponseDto board1 = dtos.getLast();
160146
assertThat(board1.id()).isEqualTo(communityId1);

src/test/java/com/somemore/volunteer/repository/VolunteerRepositoryTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
import com.somemore.IntegrationTestSupport;
44
import com.somemore.auth.oauth.OAuthProvider;
5-
import com.somemore.center.domain.Center;
65
import com.somemore.volunteer.domain.Volunteer;
76
import org.junit.jupiter.api.DisplayName;
87
import org.junit.jupiter.api.Test;
98
import org.springframework.beans.factory.annotation.Autowired;
109
import org.springframework.transaction.annotation.Transactional;
1110

12-
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
11+
import static org.assertj.core.api.Assertions.assertThat;
1312

1413
@Transactional
15-
public class VolunteerRepositoryTest extends IntegrationTestSupport {
14+
class VolunteerRepositoryTest extends IntegrationTestSupport {
1615
@Autowired
1716
private VolunteerRepository volunteerRepository;
1817

0 commit comments

Comments
 (0)