Repository navigation
fix: 교수 미정 강의를 시간표에 추가할 때 NullPointerException이 발생하는 문제 수정 #2476
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
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
94 changes: 94 additions & 0 deletions
94
...tech/koin/unit/domain/timetableV3/dto/response/TimetableLectureProfessorResponseTest.java
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 |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| package in.koreatech.koin.unit.domain.timetableV3.dto.response; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import in.koreatech.koin.domain.timetable.model.Lecture; | ||
| import in.koreatech.koin.domain.timetableV2.model.TimetableLecture; | ||
| import in.koreatech.koin.domain.timetableV3.dto.response.TakeAllTimetableLectureResponse; | ||
| import in.koreatech.koin.domain.timetableV3.dto.response.TimetableLectureResponseV3; | ||
|
|
||
| @SuppressWarnings("NonAsciiCharacters") | ||
| class TimetableLectureProfessorResponseTest { | ||
|
|
||
| @Test | ||
| void 강의와_시간표_강의의_교수가_모두_없어도_교수는_null로_응답한다() { | ||
| TimetableLecture timetableLecture = timetableLecture(lecture(null), null); | ||
|
|
||
| var response = TimetableLectureResponseV3.InnerTimetableLectureResponseV3 | ||
| .from(List.of(timetableLecture)); | ||
|
|
||
| assertThat(response).hasSize(1); | ||
| assertThat(response.get(0).professor()).isNull(); | ||
| } | ||
|
|
||
| @Test | ||
| void 시간표_강의의_교수가_없으면_강의의_교수로_응답한다() { | ||
| TimetableLecture timetableLecture = timetableLecture(lecture("허준기"), null); | ||
|
|
||
| var response = TimetableLectureResponseV3.InnerTimetableLectureResponseV3 | ||
| .from(List.of(timetableLecture)); | ||
|
|
||
| assertThat(response.get(0).professor()).isEqualTo("허준기"); | ||
| } | ||
|
|
||
| @Test | ||
| void 시간표_강의에_교수가_있으면_강의의_교수보다_우선한다() { | ||
| TimetableLecture timetableLecture = timetableLecture(lecture("허준기"), "수정된 교수"); | ||
|
|
||
| var response = TimetableLectureResponseV3.InnerTimetableLectureResponseV3 | ||
| .from(List.of(timetableLecture)); | ||
|
|
||
| assertThat(response.get(0).professor()).isEqualTo("수정된 교수"); | ||
| } | ||
|
|
||
| @Test | ||
| void 이수한_전체_수업_응답도_교수가_모두_없으면_null로_응답한다() { | ||
| TimetableLecture timetableLecture = timetableLecture(lecture(null), null); | ||
|
|
||
| var response = TakeAllTimetableLectureResponse.InnerTimetableLectureResponseV3 | ||
| .from(List.of(timetableLecture)); | ||
|
|
||
| assertThat(response).hasSize(1); | ||
| assertThat(response.get(0).professor()).isNull(); | ||
| } | ||
|
|
||
| @Test | ||
| void 이수한_전체_수업_응답은_시간표_강의의_교수가_없으면_강의의_교수로_응답한다() { | ||
| TimetableLecture timetableLecture = timetableLecture(lecture("허준기"), null); | ||
|
|
||
| var response = TakeAllTimetableLectureResponse.InnerTimetableLectureResponseV3 | ||
| .from(List.of(timetableLecture)); | ||
|
|
||
| assertThat(response.get(0).professor()).isEqualTo("허준기"); | ||
| } | ||
|
|
||
| private Lecture lecture(String professor) { | ||
| return Lecture.builder() | ||
| .code("MEB311") | ||
| .semester("20192") | ||
| .name("재료역학") | ||
| .grades("3") | ||
| .lectureClass("01") | ||
| .regularNumber("35") | ||
| .department("기계공학부") | ||
| .target("기공전체") | ||
| .professor(professor) | ||
| .isEnglish("") | ||
| .designScore("0") | ||
| .isElearning("") | ||
| .classTime("[100, 101, 102, 103, 308, 309]") | ||
| .build(); | ||
| } | ||
|
|
||
| private TimetableLecture timetableLecture(Lecture lecture, String professor) { | ||
| return TimetableLecture.builder() | ||
| .lecture(lecture) | ||
| .grades("0") | ||
| .professor(professor) | ||
| .build(); | ||
| } | ||
| } |
Oops, something went wrong.
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n '교수_미정_강의|TakeAllTimetableLectureResponse|timetables/lecture|completed|이수' src/test/java/in/koreatech/koin/acceptance/domain/TimetableLectureV3ApiTest.java src/test/java/in/koreatech/koin/unit/domain/timetableV3/dto/response/TimetableLectureProfessorResponseTest.java src/test/java/in/koreatech/koin/acceptance/domainRepository: BCSDLab/KOIN_API_V2
Length of output: 4636
🏁 Script executed:
Repository: BCSDLab/KOIN_API_V2
Length of output: 43113
🏁 Script executed:
Repository: BCSDLab/KOIN_API_V2
Length of output: 38361
🏁 Script executed:
Repository: BCSDLab/KOIN_API_V2
Length of output: 3258
Add acceptance coverage for both retrieval routes.
The direct tests cover both DTO mappers, and this test checks the POST response. No acceptance test exercises
GET /v3/timetables/lectureorGET /v3/timetables/main/lectureswith a professor-unspecified lecture. Add a GET assertion for each route that the response contains"professor": null; otherwise regressions in retrieval, service wiring, or JSON serialization can pass the stated retrieval criteria.🤖 Prompt for AI Agents