-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] 카테고리 ADMIN 역할을 포기하더라도 자신이 생성한 카테고리라면 구독 해제가 안되는 문제를 해결한다. #713
Changes from all commits
e1ed0fc
e937947
7a0c0e0
907a3e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.allog.dallog.domain.categoryrole.exception; | ||
|
||
public class NotAbleToChangeRoleException extends RuntimeException { | ||
|
||
public NotAbleToChangeRoleException(final String message) { | ||
super(message); | ||
} | ||
|
||
public NotAbleToChangeRoleException() { | ||
super("역할을 변경할 수 없습니다."); | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
import com.allog.dallog.domain.category.exception.NoSuchCategoryException; | ||
import com.allog.dallog.domain.categoryrole.exception.NoCategoryAuthorityException; | ||
import com.allog.dallog.domain.categoryrole.exception.NoSuchCategoryRoleException; | ||
import com.allog.dallog.domain.categoryrole.exception.NotAbleToMangeRoleException; | ||
import com.allog.dallog.domain.categoryrole.exception.NotAbleToChangeRoleException; | ||
import com.allog.dallog.domain.member.exception.InvalidMemberException; | ||
import com.allog.dallog.domain.member.exception.NoSuchMemberException; | ||
import com.allog.dallog.domain.schedule.exception.InvalidScheduleException; | ||
|
@@ -45,7 +45,7 @@ public class ControllerAdvice { | |
InvalidSubscriptionException.class, | ||
ExistSubscriptionException.class, | ||
ExistExternalCategoryException.class, | ||
NotAbleToMangeRoleException.class | ||
NotAbleToChangeRoleException.class | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 더욱 명확한 네이밍이군요!👍👍 |
||
}) | ||
public ResponseEntity<ErrorResponse> handleInvalidData(final RuntimeException e) { | ||
ErrorResponse errorResponse = new ErrorResponse(e.getMessage()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package com.allog.dallog.domain.categoryrole.application; | ||
|
||
import static com.allog.dallog.common.fixtures.CategoryFixtures.BE_일정_생성_요청; | ||
import static com.allog.dallog.common.fixtures.CategoryFixtures.내_일정_생성_요청; | ||
import static com.allog.dallog.common.fixtures.CategoryFixtures.외부_BE_일정_생성_요청; | ||
import static com.allog.dallog.common.fixtures.MemberFixtures.관리자; | ||
import static com.allog.dallog.common.fixtures.MemberFixtures.매트; | ||
import static com.allog.dallog.common.fixtures.MemberFixtures.후디; | ||
|
@@ -16,7 +18,7 @@ | |
import com.allog.dallog.domain.categoryrole.domain.CategoryRoleRepository; | ||
import com.allog.dallog.domain.categoryrole.dto.request.CategoryRoleUpdateRequest; | ||
import com.allog.dallog.domain.categoryrole.exception.NoCategoryAuthorityException; | ||
import com.allog.dallog.domain.categoryrole.exception.NotAbleToMangeRoleException; | ||
import com.allog.dallog.domain.categoryrole.exception.NotAbleToChangeRoleException; | ||
import com.allog.dallog.domain.member.domain.Member; | ||
import com.allog.dallog.domain.member.domain.MemberRepository; | ||
import com.allog.dallog.domain.subscription.application.SubscriptionService; | ||
|
@@ -139,6 +141,32 @@ class CategoryRoleServiceTest extends ServiceTest { | |
// when & then | ||
CategoryRoleUpdateRequest request = new CategoryRoleUpdateRequest(NONE); | ||
assertThatThrownBy(() -> categoryRoleService.updateRole(관리자.getId(), 관리자.getId(), BE_일정.getId(), request)) | ||
.isInstanceOf(NotAbleToMangeRoleException.class); | ||
.isInstanceOf(NotAbleToChangeRoleException.class); | ||
} | ||
|
||
@DisplayName("개인 카테고리에 대한 회원의 역할을 변경할 경우 예외가 발생한다.") | ||
@Test | ||
void 개인_카테고리에_대한_회원의_역할을_변경할_경우_예외가_발생한다() { | ||
// given | ||
Member 후디 = memberRepository.save(후디()); | ||
CategoryResponse 개인_카테고리 = categoryService.save(후디.getId(), 내_일정_생성_요청); | ||
|
||
// when & then | ||
CategoryRoleUpdateRequest request = new CategoryRoleUpdateRequest(NONE); | ||
assertThatThrownBy(() -> categoryRoleService.updateRole(후디.getId(), 후디.getId(), 개인_카테고리.getId(), request)) | ||
.isInstanceOf(NotAbleToChangeRoleException.class); | ||
} | ||
|
||
@DisplayName("외부 카테고리에 대한 회원의 역할을 변경할 경우 예외가 발생한다.") | ||
@Test | ||
void 외부_카테고리에_대한_회원의_역할을_변경할_경우_예외가_발생한다() { | ||
Comment on lines
+146
to
+162
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 꼼꼼한 테스트 코드군요!! |
||
// given | ||
Member 후디 = memberRepository.save(후디()); | ||
CategoryResponse 외부_카테고리 = categoryService.save(후디.getId(), 외부_BE_일정_생성_요청); | ||
|
||
// when & then | ||
CategoryRoleUpdateRequest request = new CategoryRoleUpdateRequest(NONE); | ||
assertThatThrownBy(() -> categoryRoleService.updateRole(후디.getId(), 후디.getId(), 외부_카테고리.getId(), request)) | ||
.isInstanceOf(NotAbleToChangeRoleException.class); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
import static com.allog.dallog.common.fixtures.CategoryFixtures.내_일정_생성_요청; | ||
import static com.allog.dallog.common.fixtures.MemberFixtures.관리자; | ||
import static com.allog.dallog.common.fixtures.MemberFixtures.후디; | ||
import static com.allog.dallog.common.fixtures.SubscriptionFixtures.색상1_구독; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
import static org.junit.jupiter.api.Assertions.assertAll; | ||
|
@@ -30,7 +29,6 @@ | |
import com.allog.dallog.domain.member.domain.Member; | ||
import com.allog.dallog.domain.member.domain.MemberRepository; | ||
import com.allog.dallog.domain.subscription.domain.Color; | ||
import com.allog.dallog.domain.subscription.domain.Subscription; | ||
import com.allog.dallog.domain.subscription.domain.SubscriptionRepository; | ||
import com.allog.dallog.domain.subscription.dto.request.SubscriptionUpdateRequest; | ||
import com.allog.dallog.domain.subscription.dto.response.SubscriptionResponse; | ||
|
@@ -260,19 +258,6 @@ class SubscriptionServiceTest extends ServiceTest { | |
.isInstanceOf(NoPermissionException.class); | ||
} | ||
|
||
@DisplayName("자신이 만든 카테고리에 대한 구독을 삭제할 경우 예외를 던진다") | ||
@Test | ||
void 자신이_만든_카테고리에_대한_구독을_삭제할_경우_예외를_던진다() { | ||
// given | ||
Member 관리자 = memberRepository.save(관리자()); | ||
Category 공통_일정 = categoryRepository.save(공통_일정(관리자)); | ||
Subscription 공통_일정_구독 = subscriptionRepository.save(색상1_구독(관리자, 공통_일정)); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> subscriptionService.delete(공통_일정_구독.getId(), 관리자.getId())) | ||
.isInstanceOf(NoPermissionException.class); | ||
} | ||
|
||
Comment on lines
-263
to
-275
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 불필요한 테스트코드가 삭제되었군요! |
||
@DisplayName("카테고리를 구독하면 카테고리에 대한 NONE 역할이 생성된다") | ||
@Test | ||
void 카테고리를_구독하면_카테고리에_대한_NONE_역할이_생성된다() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
불필요한 로직이 제거되었군요!👍👍