Skip to content

Commit 98ab4ca

Browse files
committed
feat: 임원진 멤버 수정 테스트 추가
1 parent 98b6b64 commit 98ab4ca

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dmu.dasom.api.domain.executive.dto.ExecutiveCreationResponseDto;
44
import dmu.dasom.api.domain.executive.dto.ExecutiveRequestDto;
55
import dmu.dasom.api.domain.executive.dto.ExecutiveResponseDto;
6+
import dmu.dasom.api.domain.executive.dto.ExecutiveUpdateRequestDto;
67
import dmu.dasom.api.domain.executive.entity.ExecutiveEntity;
78
import dmu.dasom.api.domain.executive.repository.ExecutiveRepository;
89
import org.junit.jupiter.api.DisplayName;
@@ -79,4 +80,34 @@ void createExecutive_success() {
7980
// then
8081
assertThat(responseDto.getId()).isEqualTo(id);
8182
}
83+
84+
@Test
85+
@DisplayName("임원진 멤버 수정 - 성공")
86+
void updateExecutive_success() {
87+
88+
//given
89+
Long id = 1L;
90+
91+
ExecutiveEntity entity = ExecutiveEntity.builder()
92+
.id(1L)
93+
.name("김다솜")
94+
.position("회장")
95+
.githubUrl("https://github.com/dasom")
96+
.build();
97+
98+
ExecutiveUpdateRequestDto updateEntity = new ExecutiveUpdateRequestDto("김솜다", "부회장", "https://github.com/dasom");
99+
100+
when(executiveRepository.findById(id)).thenReturn(Optional.of(entity));
101+
102+
//when
103+
ExecutiveResponseDto updateExecutive = executiveService.updateExecutive(id, updateEntity);
104+
105+
//then
106+
assertThat(updateExecutive.getName()).isEqualTo("김솜다");
107+
assertThat(updateExecutive.getPosition()).isEqualTo("부회장");
108+
assertThat(updateExecutive.getGithubUrl()).isEqualTo("https://github.com/dasom");
109+
110+
// verify ( 호출 검증 )
111+
verify(executiveRepository, times(1)).findById(id); // 메소드를 정확히 한 번만 호출했는지?
112+
}
82113
}

0 commit comments

Comments
 (0)