-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: 식단 품절, 변경 여부 (Boolean -> 시간)으로 변경 #310
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
songsunkook
merged 6 commits into
develop
from
refactor/299-soldout-is_changed-bool-to-date
Apr 6, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bc8490d
refactor: flyway 추가
ImTotem 78f592a
refactor: Boolean에서 LocalDateTime으로 변경
ImTotem 76d244a
test: Boolean에서 LocalDateTime으로 수정
ImTotem 73f9f4b
test: DisplayName 수정
ImTotem 3997c93
refactor: 품절 취소로직 추가
ImTotem e57fb5e
refactor: DTO NotNull Valid 추가
ImTotem 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
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
11 changes: 11 additions & 0 deletions
11
src/main/resources/db/migration/V7__alter_diningmenus_change_field_type.sql
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,11 @@ | ||
| ALTER TABLE `dining_menus` | ||
| MODIFY COLUMN sold_out BOOLEAN NULL, | ||
| MODIFY COLUMN is_changed BOOLEAN NULL; | ||
|
|
||
| UPDATE `dining_menus` | ||
| SET sold_out = NULL, | ||
| is_changed = NULL; | ||
|
|
||
| ALTER TABLE `dining_menus` | ||
| MODIFY COLUMN sold_out DATETIME NULL, | ||
| MODIFY COLUMN is_changed DATETIME NULL; |
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 |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| import static org.mockito.Mockito.when; | ||
|
|
||
| import java.time.Clock; | ||
| import java.time.LocalDateTime; | ||
| import java.time.ZonedDateTime; | ||
| import java.time.format.DateTimeFormatter; | ||
| import java.util.List; | ||
|
|
@@ -54,8 +55,6 @@ void findDinings() { | |
| .kcal(881) | ||
| .menu(""" | ||
| ["병아리콩밥", "(탕)소고기육개장", "땡초부추전", "누룽지탕"]""") | ||
| .soldOut(false) | ||
| .isChanged(false) | ||
| .build(); | ||
|
|
||
| Dining request2 = Dining.builder() | ||
|
|
@@ -68,8 +67,6 @@ void findDinings() { | |
| .kcal(881) | ||
| .menu(""" | ||
| ["혼합잡곡밥", "가쓰오장국", "땡초부추전", "누룽지탕"]""") | ||
| .soldOut(false) | ||
| .isChanged(false) | ||
| .build(); | ||
|
|
||
| Dining request3 = Dining.builder() | ||
|
|
@@ -82,8 +79,6 @@ void findDinings() { | |
| .kcal(300) | ||
| .menu(""" | ||
| ["참치김치볶음밥", "유부된장국", "땡초부추전", "누룽지탕"]""") | ||
| .soldOut(false) | ||
| .isChanged(true) | ||
| .build(); | ||
|
|
||
| Dining dining1 = diningRepository.save(request1); | ||
|
|
@@ -119,7 +114,7 @@ void findDinings() { | |
| .isEqualTo(dining1.getUpdatedAt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); | ||
| softly.assertThat(response.body().jsonPath().getList("[0].menu", String.class)) | ||
| .containsExactlyInAnyOrderElementsOf(menus1); | ||
| softly.assertThat(response.body().jsonPath().getBoolean("[0].is_changed")) | ||
| softly.assertThat((LocalDateTime)response.body().jsonPath().get("[0].is_changed")) | ||
| .isEqualTo(dining1.getIsChanged()); | ||
|
|
||
| softly.assertThat(response.body().jsonPath().getLong("[1].id")).isEqualTo(dining3.getId()); | ||
|
|
@@ -137,7 +132,7 @@ void findDinings() { | |
| .isEqualTo(dining3.getUpdatedAt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); | ||
| softly.assertThat(response.body().jsonPath().getList("[1].menu", String.class)) | ||
| .containsExactlyInAnyOrderElementsOf(menus2); | ||
| softly.assertThat(response.body().jsonPath().getBoolean("[1].is_changed")) | ||
| softly.assertThat((LocalDateTime)response.body().jsonPath().get("[1].is_changed")) | ||
| .isEqualTo(dining3.getIsChanged()); | ||
|
|
||
| } | ||
|
|
@@ -157,8 +152,6 @@ void invalidFormatDate() { | |
| .kcal(881) | ||
| .menu(""" | ||
| ["병아리콩밥", "(탕)소고기육개장", "땡초부추전", "누룽지탕"]""") | ||
| .soldOut(false) | ||
| .isChanged(false) | ||
| .build(); | ||
|
|
||
| Dining dining = diningRepository.save(request); | ||
|
|
@@ -188,8 +181,6 @@ void nullDate() { | |
| .kcal(881) | ||
| .menu(""" | ||
| ["병아리콩밥", "(탕)소고기육개장", "땡초부추전", "고구마순들깨볶음", "총각김치"]""") | ||
| .soldOut(false) | ||
| .isChanged(false) | ||
| .build(); | ||
|
|
||
| Dining request2 = Dining.builder() | ||
|
|
@@ -202,8 +193,6 @@ void nullDate() { | |
| .kcal(881) | ||
| .menu(""" | ||
| ["혼합잡곡밥", "가쓰오장국", "땡초부추전", "누룽지탕"]""") | ||
| .soldOut(false) | ||
| .isChanged(false) | ||
| .build(); | ||
|
|
||
| Dining dining1 = diningRepository.save(request1); | ||
|
|
@@ -242,7 +231,7 @@ void nullDate() { | |
| } | ||
|
|
||
| @Test | ||
| @DisplayName("영양사 권한으로 품절 요청을 보낸다") | ||
| @DisplayName("영양사 권한으로 품절 요청을 보내고 메뉴를 변경한다.") | ||
| void requestSoldOut() { | ||
| User user = User.builder() | ||
| .password("1234") | ||
|
|
@@ -259,6 +248,13 @@ void requestSoldOut() { | |
|
|
||
| String token = jwtProvider.createToken(user); | ||
|
|
||
| when(clock.instant()).thenReturn(ZonedDateTime.parse( | ||
| "2024-04-04 18:00:00 KST", | ||
| ofPattern("yyyy-MM-dd " + "HH:mm:ss z") | ||
| ) | ||
| .toInstant()); | ||
| when(clock.getZone()).thenReturn(Clock.systemDefaultZone().getZone()); | ||
|
|
||
| Dining dining1 = Dining.builder() | ||
| .date("2024-03-11") | ||
| .type("LUNCH") | ||
|
|
@@ -268,8 +264,7 @@ void requestSoldOut() { | |
| .kcal(881) | ||
| .menu(""" | ||
| ["병아리콩밥", "(탕)소고기육개장", "땡초부추전", "누룽지탕"]""") | ||
| .soldOut(false) | ||
| .isChanged(false) | ||
| .isChanged(LocalDateTime.now(clock)) | ||
|
Contributor
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. C 테스트 이름에 식단 변경 여부에 대한 내용도 포함되면 좋을 것 같아요!
Collaborator
Author
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. 수정했습니다 |
||
| .build(); | ||
|
|
||
| Dining dining2 = Dining.builder() | ||
|
|
@@ -281,8 +276,6 @@ void requestSoldOut() { | |
| .kcal(881) | ||
| .menu(""" | ||
| ["병아리", "소고기", "땡초", "탕"]""") | ||
| .soldOut(false) | ||
| .isChanged(false) | ||
| .build(); | ||
|
|
||
| diningRepository.save(dining1); | ||
|
|
@@ -301,7 +294,12 @@ void requestSoldOut() { | |
| .extract(); | ||
|
|
||
| SoftAssertions.assertSoftly( | ||
| softly -> softly.assertThat(diningRepository.getById(2L).getSoldOut()).isEqualTo(true) | ||
| softly -> { | ||
| softly.assertThat(diningRepository.getById(1L).getIsChanged()).isEqualTo(LocalDateTime.now(clock)); | ||
|
|
||
| softly.assertThat(diningRepository.getById(2L).getSoldOut()).isEqualTo(LocalDateTime.now(clock)); | ||
| softly.assertThat(diningRepository.getById(2L).getIsChanged()).isNull(); | ||
| } | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -332,8 +330,6 @@ void requestSoldOutNoAuth() { | |
| .kcal(881) | ||
| .menu(""" | ||
| ["병아리콩밥", "(탕)소고기육개장", "땡초부추전", "누룽지탕"]""") | ||
| .soldOut(false) | ||
| .isChanged(false) | ||
| .build(); | ||
|
|
||
| diningRepository.save(dining1); | ||
|
|
@@ -379,8 +375,6 @@ void ImageUpload() { | |
| .kcal(881) | ||
| .menu(""" | ||
| ["병아리콩밥", "(탕)소고기육개장", "땡초부추전", "누룽지탕"]""") | ||
| .soldOut(false) | ||
| .isChanged(false) | ||
| .build(); | ||
|
|
||
| Dining dining = diningRepository.save(request); | ||
|
|
@@ -433,8 +427,6 @@ void ImageUploadWithNoAuth() { | |
| .kcal(881) | ||
| .menu(""" | ||
| ["병아리콩밥", "(탕)소고기육개장", "땡초부추전", "누룽지탕"]""") | ||
| .soldOut(false) | ||
| .isChanged(false) | ||
| .build(); | ||
|
|
||
| Dining dining = diningRepository.save(request); | ||
|
|
||
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.
R
품절 취소를 하고 싶으면 요청을 어떻게 받아야 하는지, 로직을 어떻게 짜야 하는지 고민해봐야 할 것 같아요
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.
품절 취소는 생각도 못했네요
수정했습니다