11package dmu .dasom .api .domain .executive .service ;
22
3+ import dmu .dasom .api .domain .common .exception .CustomException ;
4+ import dmu .dasom .api .domain .common .exception .ErrorCode ;
35import dmu .dasom .api .domain .executive .dto .ExecutiveCreationResponseDto ;
46import dmu .dasom .api .domain .executive .dto .ExecutiveRequestDto ;
57import dmu .dasom .api .domain .executive .dto .ExecutiveResponseDto ;
1214import org .mockito .InjectMocks ;
1315import org .mockito .Mock ;
1416import org .mockito .junit .jupiter .MockitoExtension ;
17+ import org .springframework .security .test .context .support .WithMockUser ;
1518
1619import java .util .Optional ;
1720
1821import static org .assertj .core .api .Assertions .assertThat ;
22+ import static org .junit .jupiter .api .Assertions .assertEquals ;
23+ import static org .junit .jupiter .api .Assertions .assertThrows ;
1924import static org .mockito .ArgumentMatchers .any ;
2025import static org .mockito .Mockito .*;
2126
@@ -56,13 +61,29 @@ void getExecutiveById_success() {
5661 verify (executiveRepository , times (1 )).findById (id ); // 메소드를 정확히 한 번만 호출했는지?
5762 }
5863
64+ @ Test
65+ @ DisplayName ("임원진 멤버 조회 - 실패" )
66+ void getExecutiveById_fail () {
67+ // given
68+ Long id = 1L ;
69+ when (executiveRepository .findById (1L )).thenReturn (Optional .empty ());
70+
71+ // when
72+ CustomException exception = assertThrows (CustomException .class , () -> {
73+ executiveService .getExecutiveById (1L );
74+ });
75+
76+ // then
77+ assertEquals (ErrorCode .EXECUTIVE_NOT_FOUND , exception .getErrorCode ());
78+ }
79+
5980 @ Test
6081 @ DisplayName ("임원진 멤버 생성 - 성공" )
6182 void createExecutive_success () {
6283 // given
6384 Long id = 1L ;
6485 ExecutiveRequestDto dto = new ExecutiveRequestDto (
65- "김다솜" , "회장" , "https://github.com/dasom"
86+ id , "김다솜" , "회장" , "https://github.com/dasom"
6687 );
6788
6889 ExecutiveEntity entity = ExecutiveEntity .builder ()
@@ -81,6 +102,13 @@ void createExecutive_success() {
81102 assertThat (responseDto .getId ()).isEqualTo (id );
82103 }
83104
105+ @ Test
106+ @ DisplayName ("임원진 멤버 생성 - 실패_권한 없음" )
107+ @ WithMockUser (roles = "MEMBER" )
108+ public void createExecutive_fail_authority () {
109+
110+ }
111+
84112 @ Test
85113 @ DisplayName ("임원진 멤버 삭제 - 성공" )
86114 void deleteExecutive_success () {
0 commit comments