Q&A 댓글 기능 추가 및 첨부파일 제거
- djb 패키지 분리 - 댓글 CRUD/권한/알림 일체 - 같은 법인 공유 - 상세/댓글 조회 정책 일원화 - 작성자명 매핑 - PortalUser/TSEAIRM02 양쪽 조회 - 목록 - 댓글 수 표시 및 첨부 UI/로직 제거 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+117
@@ -0,0 +1,117 @@
|
||||
package com.eactive.apim.portal.djb.community.qna.support;
|
||||
|
||||
import com.eactive.apim.portal.common.user.PortalAuthenticatedUser;
|
||||
import com.eactive.apim.portal.djb.community.qna.exception.InquiryClosedException;
|
||||
import com.eactive.apim.portal.djb.community.qna.exception.InquiryCommentNotOwnedException;
|
||||
import com.eactive.apim.portal.qna.entity.Inquiry;
|
||||
import com.eactive.apim.portal.qna.entity.InquiryComment;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class InquiryCommentPermissionCheckerTest {
|
||||
|
||||
private InquiryCommentPermissionChecker checker;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
checker = new InquiryCommentPermissionChecker();
|
||||
}
|
||||
|
||||
private Inquiry inquiry(String status) {
|
||||
Inquiry i = new Inquiry();
|
||||
i.setId("inq-1");
|
||||
i.setInquiryStatus(status);
|
||||
return i;
|
||||
}
|
||||
|
||||
private InquiryComment comment(String createdBy, Inquiry inquiry) {
|
||||
InquiryComment c = new InquiryComment();
|
||||
c.setId("cmt-1");
|
||||
c.setInquiry(inquiry);
|
||||
c.setCommentDetail("test");
|
||||
c.setAdminYn("N");
|
||||
c.setDelYn("N");
|
||||
c.setCreatedBy(createdBy);
|
||||
return c;
|
||||
}
|
||||
|
||||
private PortalAuthenticatedUser user(String id) {
|
||||
PortalAuthenticatedUser u = new PortalAuthenticatedUser();
|
||||
u.setId(id);
|
||||
u.setLoginId(id);
|
||||
return u;
|
||||
}
|
||||
|
||||
@Test
|
||||
void canWrite_pendingTrue() {
|
||||
assertTrue(checker.canWrite(inquiry("PENDING")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void canWrite_inProgressTrue() {
|
||||
assertTrue(checker.canWrite(inquiry("IN_PROGRESS")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void canWrite_closedFalse() {
|
||||
assertFalse(checker.canWrite(inquiry("CLOSED")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void canDelete_ownerInOpenTrue() {
|
||||
Inquiry i = inquiry("IN_PROGRESS");
|
||||
InquiryComment c = comment("alice", i);
|
||||
assertTrue(checker.canDelete(c, user("alice")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void canDelete_otherUserFalse() {
|
||||
Inquiry i = inquiry("IN_PROGRESS");
|
||||
InquiryComment c = comment("alice", i);
|
||||
assertFalse(checker.canDelete(c, user("bob")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void canDelete_closedFalse() {
|
||||
Inquiry i = inquiry("CLOSED");
|
||||
InquiryComment c = comment("alice", i);
|
||||
assertFalse(checker.canDelete(c, user("alice")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void assertWritable_closedThrows() {
|
||||
assertThrows(InquiryClosedException.class, () -> checker.assertWritable(inquiry("CLOSED")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void assertWritable_pendingOk() {
|
||||
assertDoesNotThrow(() -> checker.assertWritable(inquiry("PENDING")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void assertDeletable_closedThrowsClosed() {
|
||||
Inquiry i = inquiry("CLOSED");
|
||||
InquiryComment c = comment("alice", i);
|
||||
assertThrows(InquiryClosedException.class, () -> checker.assertDeletable(c, user("alice")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void assertDeletable_notOwnerThrowsNotOwned() {
|
||||
Inquiry i = inquiry("IN_PROGRESS");
|
||||
InquiryComment c = comment("alice", i);
|
||||
assertThrows(InquiryCommentNotOwnedException.class,
|
||||
() -> checker.assertDeletable(c, user("bob")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void assertDeletable_ownerInOpenOk() {
|
||||
Inquiry i = inquiry("IN_PROGRESS");
|
||||
InquiryComment c = comment("alice", i);
|
||||
assertDoesNotThrow(() -> checker.assertDeletable(c, user("alice")));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user