-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wonie
committed
Dec 31, 2024
1 parent
6746df0
commit f05c901
Showing
5 changed files
with
236 additions
and
0 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
64 changes: 64 additions & 0 deletions
64
.../user/schedule/publicschedule/controller/response/PublicScheduleDetailRetrieveResDto.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,64 @@ | ||
package gg.calendar.api.user.schedule.publicschedule.controller.response; | ||
|
||
import gg.data.calendar.PublicSchedule; | ||
import gg.data.calendar.type.DetailClassification; | ||
import gg.data.calendar.type.EventTag; | ||
import gg.data.calendar.type.JobTag; | ||
import gg.data.calendar.type.TechTag; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class PublicScheduleDetailRetrieveResDto { | ||
private Long id; | ||
private DetailClassification classification; | ||
private EventTag eventTag; | ||
private JobTag jobTag; | ||
private TechTag techTag; | ||
private String author; | ||
private String title; | ||
private String content; | ||
private String link; | ||
private String startTime; | ||
private String endTime; | ||
private Integer sharedCount; | ||
|
||
@Builder | ||
private PublicScheduleDetailRetrieveResDto(Long id, DetailClassification classification, EventTag eventTag, | ||
JobTag jobTag, | ||
TechTag techTag, String author, String title, String content, String link, String startTime, String endTime, | ||
Integer sharedCount) { | ||
this.id = id; | ||
this.classification = classification; | ||
this.eventTag = eventTag; | ||
this.jobTag = jobTag; | ||
this.techTag = techTag; | ||
this.author = author; | ||
this.title = title; | ||
this.content = content; | ||
this.link = link; | ||
this.startTime = startTime; | ||
this.endTime = endTime; | ||
this.sharedCount = sharedCount; | ||
} | ||
|
||
public static PublicScheduleDetailRetrieveResDto toDto(PublicSchedule publicSchedule) { | ||
return PublicScheduleDetailRetrieveResDto.builder() | ||
.id(publicSchedule.getId()) | ||
.classification(publicSchedule.getClassification()) | ||
.eventTag(publicSchedule.getEventTag()) | ||
.jobTag(publicSchedule.getJobTag()) | ||
.techTag(publicSchedule.getTechTag()) | ||
.author(publicSchedule.getAuthor()) | ||
.title(publicSchedule.getTitle()) | ||
.content(publicSchedule.getContent()) | ||
.link(publicSchedule.getLink()) | ||
.startTime(publicSchedule.getStartTime().toString()) | ||
.endTime(publicSchedule.getEndTime().toString()) | ||
.sharedCount(publicSchedule.getSharedCount()) | ||
.build(); | ||
} | ||
} |
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
54 changes: 54 additions & 0 deletions
54
...r/schedule/publicschedule/controller/response/PublicScheduleDetailRetrieveResDtoTest.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,54 @@ | ||
package gg.calendar.api.user.schedule.publicschedule.controller.response; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import gg.data.calendar.PublicSchedule; | ||
import gg.data.calendar.type.DetailClassification; | ||
import gg.data.calendar.type.EventTag; | ||
import gg.utils.annotation.UnitTest; | ||
|
||
@UnitTest | ||
public class PublicScheduleDetailRetrieveResDtoTest { | ||
|
||
@Test | ||
@DisplayName("PublicSchedule Entity를 ResponseDto로 변환 성공") | ||
void toDto_Success() { | ||
//given | ||
LocalDateTime startTime = LocalDateTime.now().plusDays(1); | ||
LocalDateTime endTime = LocalDateTime.now().plusDays(2); | ||
|
||
PublicSchedule schedule = PublicSchedule.builder() | ||
.classification(DetailClassification.JOB_NOTICE) | ||
.eventTag(EventTag.INSTRUCTION) | ||
.author("testUser") | ||
.title("Test Title") | ||
.content("Test Content") | ||
.link("http://test.com") | ||
.startTime(startTime) | ||
.endTime(endTime) | ||
.build(); | ||
|
||
//when | ||
PublicScheduleDetailRetrieveResDto responseDto = PublicScheduleDetailRetrieveResDto.toDto(schedule); | ||
|
||
//then | ||
assertAll( | ||
() -> assertEquals(null, responseDto.getId()), | ||
() -> assertEquals(DetailClassification.JOB_NOTICE, responseDto.getClassification()), | ||
() -> assertEquals(EventTag.INSTRUCTION, responseDto.getEventTag()), | ||
() -> assertEquals("testUser", responseDto.getAuthor()), | ||
() -> assertEquals("Test Title", responseDto.getTitle()), | ||
() -> assertEquals("Test Content", responseDto.getContent()), | ||
() -> assertEquals("http://test.com", responseDto.getLink()), | ||
() -> assertEquals(startTime.toString(), responseDto.getStartTime()), | ||
() -> assertEquals(endTime.toString(), responseDto.getEndTime()), | ||
() -> assertEquals(schedule.getSharedCount(), responseDto.getSharedCount()) | ||
); | ||
} | ||
|
||
} |