@@ -2,15 +2,16 @@ package com.depromeet.whatnow.domains.picture.adapter
2
2
3
3
import com.depromeet.whatnow.domains.picture.domain.Picture
4
4
import com.depromeet.whatnow.domains.picture.domain.PictureCommentType
5
+ import com.depromeet.whatnow.domains.picture.domain.PictureType
5
6
import com.depromeet.whatnow.domains.picture.repository.PictureRepository
6
7
import org.junit.jupiter.api.Test
7
8
import org.junit.jupiter.api.extension.ExtendWith
8
- import org.mockito.ArgumentCaptor
9
9
import org.mockito.InjectMocks
10
10
import org.mockito.Mock
11
11
import org.mockito.Mockito
12
12
import org.mockito.junit.jupiter.MockitoExtension
13
- import org.mockito.kotlin.then
13
+ import org.mockito.kotlin.given
14
+ import kotlin.test.assertEquals
14
15
15
16
@ExtendWith(MockitoExtension ::class )
16
17
class PictureAdapterTest {
@@ -21,13 +22,36 @@ class PictureAdapterTest {
21
22
lateinit var pictureAdapter: PictureAdapter
22
23
23
24
@Test
24
- fun `Picture 저장 시 정상적으로 저장된다` () {
25
- val captor: ArgumentCaptor <Picture > = ArgumentCaptor .forClass(Picture ::class .java)
25
+ fun `약속 이미지 Picture 저장 시 정상적으로 저장된다` () {
26
+ given(pictureRepository.save(Mockito .any(Picture ::class .java)))
27
+ .willReturn(Picture .createForPromise(1 , 1 , " imageUrl" , " imageKey" , PictureCommentType .RUNNING ))
26
28
27
29
// when
28
- pictureAdapter.save (1 , 1 , " imageUrl" , " imageKey" , PictureCommentType .RUNNING )
30
+ val picture = pictureAdapter.saveForPromise (1 , 1 , " imageUrl" , " imageKey" , PictureCommentType .RUNNING )
29
31
30
32
// then
31
- then(pictureRepository).should(Mockito .times(1 )).save(captor.capture())
33
+ assertEquals(picture.userId, 1 )
34
+ assertEquals(picture.promiseId, 1 )
35
+ assertEquals(picture.url, " imageUrl" )
36
+ assertEquals(picture.uuid, " imageKey" )
37
+ assertEquals(picture.pictureType, PictureType .PROMISE )
38
+ assertEquals(picture.pictureCommentType, PictureCommentType .RUNNING )
39
+ }
40
+
41
+ @Test
42
+ fun `유저 프로필 Picture 저장 시 정상적으로 저장된다` () {
43
+ given(pictureRepository.save(Mockito .any(Picture ::class .java)))
44
+ .willReturn(Picture .createForUser(1 , " imageUrl" , " imageKey" ))
45
+
46
+ // when
47
+ val picture = pictureAdapter.saveForUser(1 , " imageUrl" , " imageKey" )
48
+
49
+ // then
50
+ assertEquals(picture.userId, 1 )
51
+ assertEquals(picture.promiseId, 0 )
52
+ assertEquals(picture.url, " imageUrl" )
53
+ assertEquals(picture.uuid, " imageKey" )
54
+ assertEquals(picture.pictureType, PictureType .USER )
55
+ assertEquals(picture.pictureCommentType, PictureCommentType .NONE )
32
56
}
33
57
}
0 commit comments