1
1
package com.yapp.bol.group
2
2
3
- import com.yapp.bol.NoPermissionDeleteGroupException
3
+ import com.yapp.bol.NoPermissionException
4
4
import com.yapp.bol.auth.UserId
5
5
import com.yapp.bol.auth.authorizationHeader
6
6
import com.yapp.bol.base.ARRAY
@@ -22,15 +22,20 @@ import com.yapp.bol.group.member.HostMember
22
22
import com.yapp.bol.group.member.MemberId
23
23
import com.yapp.bol.group.member.MemberList
24
24
import com.yapp.bol.group.member.MemberRole
25
+ import com.yapp.bol.group.member.MemberValidator
25
26
import com.yapp.bol.group.member.OwnerMember
26
27
import com.yapp.bol.pagination.offset.PaginationOffsetResponse
27
28
import io.mockk.every
28
29
import io.mockk.mockk
30
+ import io.mockk.spyk
31
+ import org.springframework.boot.test.context.SpringBootTest
29
32
33
+ @SpringBootTest
30
34
class GroupControllerTest : WebControllerTest () {
31
35
private val groupService: GroupService = mockk()
32
36
private val fileService: FileService = mockk()
33
- override val controller = GroupController (groupService, fileService)
37
+ private val memberValidator: MemberValidator = mockk()
38
+ override val controller = spyk(GroupController (groupService, fileService, memberValidator))
34
39
35
40
init {
36
41
test(" 그룹 기본 이미지 가져오기" ) {
@@ -269,12 +274,12 @@ class GroupControllerTest : WebControllerTest() {
269
274
}
270
275
271
276
context(" 그룹 삭제" ) {
277
+ val groupId = GroupId (123L )
278
+ val userId = UserId (321L )
272
279
273
280
test(" 성공" ) {
274
- val groupId = GroupId (123L )
275
- val userId = UserId (321L )
276
-
277
- every { groupService.deleteGroup(userId, groupId) } returns Unit
281
+ every { memberValidator.requiredGroupOwner(groupId, userId) } returns Unit
282
+ every { groupService.deleteGroup(groupId) } returns Unit
278
283
279
284
delete(" /api/v1/group/{groupId}" , arrayOf(groupId.value)) {
280
285
authorizationHeader(userId)
@@ -293,15 +298,12 @@ class GroupControllerTest : WebControllerTest() {
293
298
}
294
299
295
300
test(" 오너가 아닌 사람" ) {
296
- val groupId = GroupId (123L )
297
- val userId = UserId (321L )
298
-
299
- every { groupService.deleteGroup(userId, groupId) } throws NoPermissionDeleteGroupException
301
+ every { memberValidator.requiredGroupOwner(groupId, userId) } throws NoPermissionException
300
302
301
303
delete(" /api/v1/group/{groupId}" , arrayOf(groupId.value)) {
302
304
authorizationHeader(userId)
303
305
}
304
- .isStatus(400 )
306
+ .isStatus(403 )
305
307
.makeDocument(
306
308
DocumentInfo (
307
309
identifier = " group/{method-name}" ,
0 commit comments