Skip to content

Commit b8fd14d

Browse files
committed
refactor: 구조 변경에 따른 테스트 코드 변경 (DASOMBE-21)
1 parent c402091 commit b8fd14d

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

src/test/java/dmu/dasom/api/domain/executive/service/ExecutiveServiceTest.java

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import dmu.dasom.api.domain.executive.dto.ExecutiveResponseDto;
88
import dmu.dasom.api.domain.executive.dto.ExecutiveUpdateRequestDto;
99
import dmu.dasom.api.domain.executive.entity.ExecutiveEntity;
10+
import dmu.dasom.api.domain.executive.enums.Team;
1011
import dmu.dasom.api.domain.executive.repository.ExecutiveRepository;
1112
import org.junit.jupiter.api.DisplayName;
1213
import org.junit.jupiter.api.Test;
@@ -43,7 +44,9 @@ void getExecutiveById_success() {
4344
.id(1L)
4445
.name("김다솜")
4546
.position("회장")
46-
.githubUrl("https://github.com/dasom")
47+
.role("동아리 운영 총괄")
48+
.githubUsername("DASOM")
49+
.team(Team.PRESIDENT)
4750
.build();
4851

4952
when(executiveRepository.findById(id)).thenReturn(Optional.of(entity));
@@ -55,7 +58,9 @@ void getExecutiveById_success() {
5558
assertThat(responseDto.getId()).isEqualTo(id);
5659
assertThat(responseDto.getName()).isEqualTo("김다솜");
5760
assertThat(responseDto.getPosition()).isEqualTo("회장");
58-
assertThat(responseDto.getGithubUrl()).isEqualTo("https://github.com/dasom");
61+
assertThat(responseDto.getRole()).isEqualTo("동아리 운영 총괄");
62+
assertThat(responseDto.getGithub_username()).isEqualTo("DASOM");
63+
assertThat(responseDto.getTeam()).isEqualTo(Team.PRESIDENT);
5964

6065
// verify ( 호출 검증 )
6166
verify(executiveRepository, times(1)).findById(id); // 메소드를 정확히 한 번만 호출했는지?
@@ -83,14 +88,22 @@ void createExecutive_success() {
8388
// given
8489
Long id = 1L;
8590
ExecutiveRequestDto dto = new ExecutiveRequestDto(
86-
id, "김다솜", "회장", "https://github.com/dasom"
91+
id,
92+
"김다솜",
93+
"회장",
94+
"동아리 운영 총괄",
95+
"DASOM",
96+
Team.PRESIDENT,
97+
1
8798
);
8899

89100
ExecutiveEntity entity = ExecutiveEntity.builder()
90101
.id(1L)
91102
.name("김다솜")
92103
.position("회장")
93-
.githubUrl("https://github.com/dasom")
104+
.role("동아리 운영 총괄")
105+
.githubUsername("DASOM")
106+
.team(Team.PRESIDENT)
94107
.build();
95108

96109
when(executiveRepository.save(any(ExecutiveEntity.class))).thenReturn(entity);
@@ -119,7 +132,9 @@ void deleteExecutive_success() {
119132
.id(1L)
120133
.name("김다솜")
121134
.position("회장")
122-
.githubUrl("https://github.com/dasom")
135+
.role("동아리 운영 총괄")
136+
.githubUsername("DASOM")
137+
.team(Team.PRESIDENT)
123138
.build();
124139

125140
when(executiveRepository.findById(id)).thenReturn(Optional.of(entity));
@@ -158,10 +173,19 @@ void updateExecutive_success() {
158173
.id(1L)
159174
.name("김다솜")
160175
.position("회장")
161-
.githubUrl("https://github.com/dasom")
176+
.role("동아리 운영 총괄")
177+
.githubUsername("DASOM")
178+
.team(Team.PRESIDENT)
162179
.build();
163180

164-
ExecutiveUpdateRequestDto updateEntity = new ExecutiveUpdateRequestDto("김솜다", "부회장", "https://github.com/dasom");
181+
ExecutiveUpdateRequestDto updateEntity = new ExecutiveUpdateRequestDto(
182+
"김솜다",
183+
"부회장",
184+
"동아리 운영 총괄",
185+
"MOSAD",
186+
Team.ACADEMIC,
187+
1
188+
);
165189

166190
when(executiveRepository.findById(id)).thenReturn(Optional.of(entity));
167191

@@ -171,7 +195,9 @@ void updateExecutive_success() {
171195
//then
172196
assertThat(updateExecutive.getName()).isEqualTo("김솜다");
173197
assertThat(updateExecutive.getPosition()).isEqualTo("부회장");
174-
assertThat(updateExecutive.getGithubUrl()).isEqualTo("https://github.com/dasom");
198+
assertThat(updateExecutive.getRole()).isEqualTo("동아리 운영 총괄");
199+
assertThat(updateExecutive.getGithub_username()).isEqualTo("MOSAD");
200+
assertThat(updateExecutive.getTeam()).isEqualTo(Team.ACADEMIC);
175201

176202
// verify ( 호출 검증 )
177203
verify(executiveRepository, times(1)).findById(id); // 메소드를 정확히 한 번만 호출했는지?

0 commit comments

Comments
 (0)