-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
상세 조회에서 다른 사람의 비공개 템플릿 확인 시 예외 처리 (#852)
* refactor(template): 기본 값 설정 * feat(template): 다른 사람의 비공개 템플릿 단건 조회 시 예외 발생 * feat(domain): 메서드명 변경 * refactor(domain): 주생성자 활용하도록 수정 * refactor(domain): 도메인에서 예외 발생시키지 않도록 수정 * docs: 실패 ErrorCode 문서 수정 * refactor(domain): 필드 사용으로 변경 * refactor(service): 함수형 인터페이스를 이용해 메서드 추출 및 재사용
- Loading branch information
Showing
7 changed files
with
170 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
backend/src/main/java/codezap/template/service/facade/TemplateOwnershipChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package codezap.template.service.facade; | ||
|
||
import codezap.template.domain.Template; | ||
|
||
@FunctionalInterface | ||
public interface TemplateOwnershipChecker { | ||
|
||
boolean isOwner(Template template); | ||
} |
71 changes: 71 additions & 0 deletions
71
backend/src/test/java/codezap/template/domain/TemplateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package codezap.template.domain; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import codezap.category.domain.Category; | ||
import codezap.fixture.MemberFixture; | ||
import codezap.fixture.TemplateFixture; | ||
import codezap.member.domain.Member; | ||
|
||
class TemplateTest { | ||
|
||
@Nested | ||
@DisplayName("멤버 확인") | ||
class MatchMember { | ||
|
||
@Test | ||
@DisplayName("성공: 같은 사용자일 경우 true") | ||
void matchMemberSuccess() { | ||
Member member = MemberFixture.getFirstMember(); | ||
Template template = TemplateFixture.get(member, Category.createDefaultCategory(member)); | ||
|
||
boolean actual = template.matchMember(member); | ||
|
||
assertThat(actual).isTrue(); | ||
} | ||
|
||
@Test | ||
@DisplayName("성공: 다른 사용자일 경우 false") | ||
void matchMemberFail() { | ||
Member member = MemberFixture.getFirstMember(); | ||
Member otherMember = MemberFixture.getSecondMember(); | ||
Template template = TemplateFixture.get(member, Category.createDefaultCategory(member)); | ||
|
||
boolean actual = template.matchMember(otherMember); | ||
|
||
assertThat(actual).isFalse(); | ||
} | ||
} | ||
|
||
@Nested | ||
@DisplayName("공개 범위 확인") | ||
class IsPrivate { | ||
|
||
@Test | ||
@DisplayName("성공: 비공개 템플릿일 경우 true") | ||
void isPrivateTrue() { | ||
Member member = MemberFixture.getFirstMember(); | ||
Template template = TemplateFixture.getPrivate(member, Category.createDefaultCategory(member)); | ||
|
||
boolean actual = template.isPrivate(); | ||
|
||
assertThat(actual).isTrue(); | ||
} | ||
|
||
@Test | ||
@DisplayName("성공: 공개 템플릿일 경우 false") | ||
void isPrivateFalse() { | ||
Member member = MemberFixture.getFirstMember(); | ||
Member otherMember = MemberFixture.getSecondMember(); | ||
Template template = TemplateFixture.get(member, Category.createDefaultCategory(member)); | ||
|
||
boolean actual = template.isPrivate(); | ||
|
||
assertThat(actual).isFalse(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters