@@ -79,6 +79,7 @@ void testUploadImage_success() {
7979 @ DisplayName ("이미지 형식이 올바르지 않다면 업로드 할 수 없다." )
8080 @ Test
8181 void testUploadImage_failure () throws IOException {
82+
8283 // given
8384 when (multipartFile .getInputStream ()).thenThrow (new IOException ());
8485
@@ -91,6 +92,7 @@ void testUploadImage_failure() throws IOException {
9192 @ DisplayName ("이미지 파일이 없다면 기본 이미지 링크를 반환한다." )
9293 @ Test
9394 void uploadImageWithEmptyFile () {
95+
9496 // given
9597 MultipartFile emptyFile = new MockMultipartFile ("file" , new byte [0 ]);
9698 given (imageUploadValidator .isEmptyFile (emptyFile )).willReturn (true );
@@ -106,13 +108,12 @@ void uploadImageWithEmptyFile() {
106108 @ DisplayName ("유효한 파일명으로 사전 서명된 URL을 생성할 수 있다." )
107109 @ Test
108110 void getPresignedUrl_success () {
111+
109112 // given
110113 String filename = "testImage.jpg" ;
111114
112- // Mock the validator to return false (file name is valid)
113115 when (imageUploadValidator .isEmptyFileName (filename )).thenReturn (false );
114116
115- // Mock the S3Presigner to return a URL
116117 S3Presigner mockPresigner = mock (S3Presigner .class );
117118 ReflectionTestUtils .setField (imageUploadService , "s3Presigner" , mockPresigner );
118119
@@ -131,7 +132,6 @@ void getPresignedUrl_success() {
131132 assertTrue (presignedUrl .startsWith ("https://test-bucket.s3.amazonaws.com/" ));
132133 assertTrue (presignedUrl .endsWith (".jpg" ));
133134
134- // Verify interactions
135135 verify (imageUploadValidator , times (1 )).isEmptyFileName (filename );
136136 verify (mockPresigner , times (1 )).presignGetObject (any (GetObjectPresignRequest .class ));
137137 }
@@ -151,7 +151,6 @@ void getPresignedUrl_invalidFileName() {
151151 // then
152152 assertNull (presignedUrl );
153153
154- // Verify interactions
155154 verify (imageUploadValidator , times (1 )).isEmptyFileName (filename );
156155 }
157156}
0 commit comments