Skip to content

Commit

Permalink
[#140] test: conflict resolved 에서 삭제된 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
JuHyun419 committed Jun 29, 2022
1 parent 685b180 commit 1ddcd0e
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import com.yapp.web2.config.S3Uploader
import com.yapp.web2.domain.account.entity.Account
import com.yapp.web2.domain.account.entity.AccountRequestDto
import com.yapp.web2.domain.account.repository.AccountRepository
import com.yapp.web2.domain.folder.entity.AccountFolder
import com.yapp.web2.domain.folder.entity.Folder
import com.yapp.web2.domain.folder.service.FolderService
import com.yapp.web2.exception.BusinessException
import com.yapp.web2.exception.custom.AlreadyInvitedException
import com.yapp.web2.exception.custom.FolderNotRootException
import com.yapp.web2.exception.custom.PasswordMismatchException
import com.yapp.web2.security.jwt.JwtProvider
import com.yapp.web2.security.jwt.TokenDto
Expand All @@ -27,6 +31,7 @@ import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertAll
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.extension.ExtendWith
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
Expand Down Expand Up @@ -300,6 +305,53 @@ internal open class AccountServiceTest {
// when
// then
}

@Test
fun `보관함에 유저가 추가된다`() {
// given
val testFolder = Folder("test", 0, 0, null)
val testFolderToken = "testFolderToken"

every { jwtProvider.getAccountFromToken(any()) } returns testAccount
every { aeS256Util.decrypt(testFolderToken) } returns "3"
every { folderService.findByFolderId(any()) } returns testFolder

// when
accountService.acceptInvitation(testToken, testFolderToken)

// then
assertThat(testFolder.folders?.size).isEqualTo(1)
}

@Test
fun `초대받은 링크가 보관함이 아닐 경우에 예외를 던진다`() {
// given
val testFolder = Folder("test", 0, 0, null)
testFolder.rootFolderId = 1L
val testFolderToken = "testFolderToken"

every { jwtProvider.getAccountFromToken(any()) } returns testAccount
every { aeS256Util.decrypt(testFolderToken) } returns "3"
every { folderService.findByFolderId(any()) } returns testFolder

// when + then
assertThrows<FolderNotRootException> { accountService.acceptInvitation(testToken, testFolderToken) }
}

@Test
fun `초대받은 링크를 이미 사용한 경우에는 예외를 던진다`() {
// given
val testFolder = Folder("test", 0, 0, null)
val testFolderToken = "testFolderToken"
testAccount.accountFolderList.add(AccountFolder(testAccount, testFolder))

every { jwtProvider.getAccountFromToken(any()) } returns testAccount
every { aeS256Util.decrypt(testFolderToken) } returns "3"
every { folderService.findByFolderId(any()) } returns testFolder

// when + then
assertThrows<AlreadyInvitedException> { accountService.acceptInvitation(testToken, testFolderToken) }
}
}

@Nested
Expand Down

0 comments on commit 1ddcd0e

Please sign in to comment.