-
Notifications
You must be signed in to change notification settings - Fork 1
[WTH-68] 출석 dto에 출석코드 추가 #229
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
Merged
The head ref may contain hidden characters: "WTH-68-Weeth-\uCD9C\uC11D-dto\uC5D0-\uCD9C\uC11D\uCF54\uB4DC-\uCD94\uAC00"
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,23 +1,28 @@ | ||
| package leets.weeth.domain.attendance.application.mapper; | ||
|
|
||
| import static leets.weeth.domain.attendance.test.fixture.AttendanceTestFixture.*; | ||
| import static org.assertj.core.api.Assertions.*; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import leets.weeth.domain.attendance.application.dto.AttendanceDTO; | ||
| import leets.weeth.domain.attendance.domain.entity.Attendance; | ||
| import leets.weeth.domain.schedule.domain.entity.Meeting; | ||
| import leets.weeth.domain.user.domain.entity.User; | ||
| import leets.weeth.domain.user.domain.entity.enums.Position; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.extension.ExtendWith; | ||
| import org.mapstruct.factory.Mappers; | ||
| import org.mockito.InjectMocks; | ||
| import org.mockito.junit.jupiter.MockitoExtension; | ||
|
|
||
| import java.time.LocalDate; | ||
| import java.util.List; | ||
|
|
||
| import static leets.weeth.domain.attendance.test.fixture.AttendanceTestFixture.*; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| @ExtendWith(MockitoExtension.class) | ||
| class AttendanceMapperTest { | ||
|
|
||
| private final AttendanceMapper attendanceMapper = new AttendanceMapperImpl(); | ||
| @InjectMocks | ||
| private final AttendanceMapper attendanceMapper = Mappers.getMapper(AttendanceMapper.class); | ||
|
|
||
| @Test | ||
| @DisplayName("toMainDto: 사용자 + 당일 출석 객체를 Main DTO로 매핑한다") | ||
|
|
@@ -121,4 +126,45 @@ void nullSafety_whenTodayAttendanceNull() { | |
| assertThat(main.end()).isNull(); | ||
| assertThat(main.location()).isNull(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("toMainDto: 일반 유저는 출석 코드가 null로 매핑된다") | ||
| void toMainDto_normalUser_codeIsNull() { | ||
| // given | ||
| LocalDate today = LocalDate.now(); | ||
| Meeting meeting = createOneDayMeeting(today, 1, 1234, "Today"); | ||
| User user = createActiveUserWithAttendances("일반유저", List.of(meeting)); | ||
| Attendance attendance = user.getAttendances().get(0); | ||
|
|
||
| // when | ||
| AttendanceDTO.Main main = attendanceMapper.toMainDto(user, attendance); | ||
|
|
||
| // then | ||
| assertThat(main).isNotNull(); | ||
| assertThat(main.code()).isNull(); | ||
| assertThat(main.title()).isEqualTo("Today"); | ||
| assertThat(main.status()).isEqualTo(attendance.getStatus()); | ||
| } | ||
|
|
||
| @Test | ||
| @DisplayName("toAdminResponse: ADMIN 유저는 출석 코드가 포함된다") | ||
| void toAdminResponse_adminUser_includesCode() { | ||
| // given | ||
| LocalDate today = LocalDate.now(); | ||
| Integer expectedCode = 1234; | ||
| Meeting meeting = createOneDayMeeting(today, 1, expectedCode, "Today"); | ||
| User adminUser = createAdminUserWithAttendances("관리자", List.of(meeting)); | ||
| Attendance attendance = adminUser.getAttendances().get(0); | ||
|
|
||
| // when | ||
| AttendanceDTO.Main main = attendanceMapper.toAdminResponse(adminUser, attendance); | ||
|
|
||
| // then | ||
| assertThat(main).isNotNull(); | ||
| assertThat(main.code()).isEqualTo(expectedCode); | ||
| assertThat(main.title()).isEqualTo("Today"); | ||
| assertThat(main.start()).isEqualTo(meeting.getStart()); | ||
| assertThat(main.end()).isEqualTo(meeting.getEnd()); | ||
| assertThat(main.location()).isEqualTo(meeting.getLocation()); | ||
| } | ||
| } | ||
|
Collaborator
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. 테스트도 케이스별로 보기좋게 잘 작성해주신 것 같아요 !! 굳굳 |
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ignore 옵션으로 , ROLE별로 매핑되는 필드를 조절할 수 있군요! 좋은 설계같습니다