Skip to content

Commit 1e5e21b

Browse files
committed
refactor: 임시 저장편지 matchingId 추가 (WR9-112)
1 parent 56e1b77 commit 1e5e21b

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

src/main/java/io/crops/warmletter/domain/letter/dto/request/TemporarySaveLetterRequest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class TemporarySaveLetterRequest {
1414

1515
private Long receiverId;
1616

17+
private Long matchingId;
18+
1719
private Long parentLetterId;
1820

1921
@NotBlank(message = "제목을 입력해주세요.")

src/main/java/io/crops/warmletter/domain/letter/entity/Letter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ public void updateLetterType(LetterType letterType) {
9292
}
9393

9494

95-
public void updateTemporarySave(Long receiverId, Long parentLetterId, Category category, String title, String content) {
95+
public void updateTemporarySave(Long receiverId, Long matchingId, Long parentLetterId, Category category, String title, String content) {
9696
this.receiverId = receiverId;
97+
this.matchingId = matchingId;
9798
this.parentLetterId = parentLetterId;
9899
this.category = category;
99100
this.title = title;

src/main/java/io/crops/warmletter/domain/letter/service/LetterService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ public LetterResponse temporarySaveLetter(Long letterId, TemporarySaveLetterRequ
192192

193193
letter.updateTemporarySave(
194194
request.getReceiverId(),
195+
request.getMatchingId(),
195196
request.getParentLetterId(),
196197
request.getCategory(),
197198
request.getTitle(),

src/test/java/io/crops/warmletter/domain/letter/service/LetterServiceTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,13 +967,15 @@ void temporarySaveExistingLetter_success() throws Exception {
967967
// given
968968
Long letterId = 1L;
969969
Long writerId = 1L;
970+
Long matchingId = 1L;
970971

971972
// Letter를 mock으로 생성
972973
Letter existingLetter = mock(Letter.class);
973974
// mock 객체에 필요한 getter 메서드 동작 정의
974975
when(existingLetter.getId()).thenReturn(letterId);
975976
when(existingLetter.getTitle()).thenReturn("임시 저장 제목");
976977
when(existingLetter.getContent()).thenReturn("임시 저장 내용");
978+
when(existingLetter.getMatchingId()).thenReturn(matchingId);
977979
when(existingLetter.getCategory()).thenReturn(Category.ETC);
978980
when(existingLetter.getFontType()).thenReturn(FontType.HIMCHAN);
979981
when(existingLetter.getPaperType()).thenReturn(PaperType.COMFORT);
@@ -987,6 +989,7 @@ void temporarySaveExistingLetter_success() throws Exception {
987989
Field fontField = TemporarySaveLetterRequest.class.getDeclaredField("fontType");
988990
Field paperTypeField = TemporarySaveLetterRequest.class.getDeclaredField("paperType");
989991
Field receiverIdField = TemporarySaveLetterRequest.class.getDeclaredField("receiverId");
992+
Field matchingIdField = TemporarySaveLetterRequest.class.getDeclaredField("matchingId");
990993
Field parentLetterIdField = TemporarySaveLetterRequest.class.getDeclaredField("parentLetterId");
991994

992995
titleField.setAccessible(true);
@@ -995,6 +998,7 @@ void temporarySaveExistingLetter_success() throws Exception {
995998
fontField.setAccessible(true);
996999
paperTypeField.setAccessible(true);
9971000
receiverIdField.setAccessible(true);
1001+
matchingIdField.setAccessible(true);
9981002
parentLetterIdField.setAccessible(true);
9991003

10001004
titleField.set(request, "임시 저장 제목");
@@ -1003,6 +1007,7 @@ void temporarySaveExistingLetter_success() throws Exception {
10031007
fontField.set(request, FontType.HIMCHAN);
10041008
paperTypeField.set(request, PaperType.COMFORT);
10051009
receiverIdField.set(request, null);
1010+
matchingIdField.set(request, matchingId);
10061011
parentLetterIdField.set(request, null);
10071012

10081013
// 서비스 메서드 모킹
@@ -1013,6 +1018,7 @@ void temporarySaveExistingLetter_success() throws Exception {
10131018
// void 메서드 모킹 (doNothing 사용)
10141019
doNothing().when(existingLetter).updateTemporarySave(
10151020
request.getReceiverId(),
1021+
request.getMatchingId(),
10161022
request.getParentLetterId(),
10171023
request.getCategory(),
10181024
request.getTitle(),
@@ -1028,6 +1034,7 @@ void temporarySaveExistingLetter_success() throws Exception {
10281034
() -> assertEquals(letterId, response.getLetterId()),
10291035
() -> assertEquals("임시 저장 제목", response.getTitle()),
10301036
() -> assertEquals("임시 저장 내용", response.getContent()),
1037+
() -> assertEquals(matchingId, response.getMatchingId()),
10311038
() -> assertEquals(Category.ETC, response.getCategory()),
10321039
() -> assertEquals(FontType.HIMCHAN, response.getFontType()),
10331040
() -> assertEquals(PaperType.COMFORT, response.getPaperType()),
@@ -1038,6 +1045,7 @@ void temporarySaveExistingLetter_success() throws Exception {
10381045
verify(letterRepository).findByIdAndWriterId(letterId, writerId);
10391046
verify(existingLetter).updateTemporarySave(
10401047
request.getReceiverId(),
1048+
request.getMatchingId(),
10411049
request.getParentLetterId(),
10421050
request.getCategory(),
10431051
request.getTitle(),

0 commit comments

Comments
 (0)