From d499e8f832889f48c250e815fc74a7dff0579ebe Mon Sep 17 00:00:00 2001 From: pricelees Date: Thu, 18 Jul 2024 16:59:59 +0900 Subject: [PATCH 01/16] =?UTF-8?q?style:=20=ED=81=B4=EB=9E=98=EC=8A=A4=20?= =?UTF-8?q?=EC=84=A0=EC=96=B8=EB=B6=80=20=EC=95=84=EB=9E=98=20=EA=B0=9C?= =?UTF-8?q?=ED=96=89=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/mouda/backend/common/RestResponse.java | 1 + backend/src/main/java/mouda/backend/config/CorsConfig.java | 1 + backend/src/main/java/mouda/backend/moim/domain/Moim.java | 1 + .../java/mouda/backend/moim/dto/request/MoimCreateRequest.java | 1 + .../mouda/backend/moim/dto/response/MoimDetailsFindResponse.java | 1 + .../mouda/backend/moim/dto/response/MoimFindAllResponse.java | 1 + 6 files changed, 6 insertions(+) diff --git a/backend/src/main/java/mouda/backend/common/RestResponse.java b/backend/src/main/java/mouda/backend/common/RestResponse.java index 2b646d0af..ccc36be6f 100644 --- a/backend/src/main/java/mouda/backend/common/RestResponse.java +++ b/backend/src/main/java/mouda/backend/common/RestResponse.java @@ -6,5 +6,6 @@ @Getter @AllArgsConstructor public class RestResponse { + private T data; } diff --git a/backend/src/main/java/mouda/backend/config/CorsConfig.java b/backend/src/main/java/mouda/backend/config/CorsConfig.java index 887ac79f7..80e2cb37e 100644 --- a/backend/src/main/java/mouda/backend/config/CorsConfig.java +++ b/backend/src/main/java/mouda/backend/config/CorsConfig.java @@ -6,6 +6,7 @@ @Configuration public class CorsConfig implements WebMvcConfigurer { + @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") diff --git a/backend/src/main/java/mouda/backend/moim/domain/Moim.java b/backend/src/main/java/mouda/backend/moim/domain/Moim.java index e1ec28e0f..200054f66 100644 --- a/backend/src/main/java/mouda/backend/moim/domain/Moim.java +++ b/backend/src/main/java/mouda/backend/moim/domain/Moim.java @@ -18,6 +18,7 @@ @NoArgsConstructor @AllArgsConstructor public class Moim { + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; diff --git a/backend/src/main/java/mouda/backend/moim/dto/request/MoimCreateRequest.java b/backend/src/main/java/mouda/backend/moim/dto/request/MoimCreateRequest.java index 4465b84ee..492c2f1f6 100644 --- a/backend/src/main/java/mouda/backend/moim/dto/request/MoimCreateRequest.java +++ b/backend/src/main/java/mouda/backend/moim/dto/request/MoimCreateRequest.java @@ -14,6 +14,7 @@ public record MoimCreateRequest( String authorNickname, String description ) { + public Moim toEntity() { return Moim.builder() .title(title) diff --git a/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java b/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java index e62ba6132..e11fd0541 100644 --- a/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java +++ b/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java @@ -17,6 +17,7 @@ public record MoimDetailsFindResponse( String authorNickname, String description ) { + public static MoimDetailsFindResponse toResponse(Moim moim) { return MoimDetailsFindResponse.builder() .title(moim.getTitle()) diff --git a/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java b/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java index 04978b651..015ba5dce 100644 --- a/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java +++ b/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java @@ -18,6 +18,7 @@ public record MoimFindAllResponse( String authorNickname, String description ) { + public static MoimFindAllResponse toResponse(Moim moim) { return MoimFindAllResponse.builder() .moimId(moim.getId()) From ee337028d820c2b538091134922221d769270300 Mon Sep 17 00:00:00 2001 From: pricelees Date: Thu, 18 Jul 2024 17:03:01 +0900 Subject: [PATCH 02/16] =?UTF-8?q?refactor:=20=EB=B0=98=ED=99=98=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20void=EB=A5=BC=20ResponseEntity=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/mouda/backend/moim/controller/MoimController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/mouda/backend/moim/controller/MoimController.java b/backend/src/main/java/mouda/backend/moim/controller/MoimController.java index 6ff48247f..dd17e8ebd 100644 --- a/backend/src/main/java/mouda/backend/moim/controller/MoimController.java +++ b/backend/src/main/java/mouda/backend/moim/controller/MoimController.java @@ -71,7 +71,9 @@ public ResponseEntity> joinMoim(@RequestBody MoimJoinRequest @ApiResponse(responseCode = "200", description = "모임 삭제 성공!"), }) @DeleteMapping("/{moimId}") - public void deleteMoim(@PathVariable long moimId) { + public ResponseEntity deleteMoim(@PathVariable long moimId) { moimService.deleteMoim(moimId); + + return ResponseEntity.ok().build(); } } From 6f9192e81730f17be73aadee08f133df7307bab0 Mon Sep 17 00:00:00 2001 From: pricelees Date: Thu, 18 Jul 2024 17:04:28 +0900 Subject: [PATCH 03/16] =?UTF-8?q?style:=20return=EB=AC=B8=20=EC=9C=84=20?= =?UTF-8?q?=EA=B0=9C=ED=96=89=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/mouda/backend/moim/controller/MoimController.java | 2 ++ .../src/main/java/mouda/backend/moim/service/MoimService.java | 1 + 2 files changed, 3 insertions(+) diff --git a/backend/src/main/java/mouda/backend/moim/controller/MoimController.java b/backend/src/main/java/mouda/backend/moim/controller/MoimController.java index dd17e8ebd..9b76c7ffa 100644 --- a/backend/src/main/java/mouda/backend/moim/controller/MoimController.java +++ b/backend/src/main/java/mouda/backend/moim/controller/MoimController.java @@ -35,6 +35,7 @@ public class MoimController { @PostMapping public ResponseEntity> createMoim(@RequestBody MoimCreateRequest moimCreateRequest) { Moim moim = moimService.createMoim(moimCreateRequest); + return ResponseEntity.ok().body(new RestResponse<>(moim.getId())); } @@ -63,6 +64,7 @@ public ResponseEntity> findMoimDetails(@Pa @PostMapping("/join") public ResponseEntity> joinMoim(@RequestBody MoimJoinRequest moimJoinRequest) { moimService.joinMoim(moimJoinRequest); + return ResponseEntity.ok().build(); } diff --git a/backend/src/main/java/mouda/backend/moim/service/MoimService.java b/backend/src/main/java/mouda/backend/moim/service/MoimService.java index 9f54fdc8b..72f408a42 100644 --- a/backend/src/main/java/mouda/backend/moim/service/MoimService.java +++ b/backend/src/main/java/mouda/backend/moim/service/MoimService.java @@ -28,6 +28,7 @@ public Moim createMoim(MoimCreateRequest moimCreateRequest) { @Transactional(readOnly = true) public MoimFindAllResponses findAllMoim() { List moims = moimRepository.findAll(); + return new MoimFindAllResponses( moims.stream() .map(MoimFindAllResponse::toResponse) From 31b0447558192155d9f87ac7b01404c22548a8fc Mon Sep 17 00:00:00 2001 From: pricelees Date: Thu, 18 Jul 2024 17:07:11 +0900 Subject: [PATCH 04/16] =?UTF-8?q?style:=20=EB=AA=A8=EB=93=A0=20id=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=EB=AA=85=EC=9D=84=20moimId=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/mouda/backend/moim/service/MoimService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/mouda/backend/moim/service/MoimService.java b/backend/src/main/java/mouda/backend/moim/service/MoimService.java index 72f408a42..d7a18e59e 100644 --- a/backend/src/main/java/mouda/backend/moim/service/MoimService.java +++ b/backend/src/main/java/mouda/backend/moim/service/MoimService.java @@ -37,8 +37,8 @@ public MoimFindAllResponses findAllMoim() { } @Transactional(readOnly = true) - public MoimDetailsFindResponse findMoimDetails(long id) { - Moim moim = moimRepository.findById(id) + public MoimDetailsFindResponse findMoimDetails(long moimId) { + Moim moim = moimRepository.findById(moimId) .orElseThrow(IllegalArgumentException::new); return MoimDetailsFindResponse.toResponse(moim); @@ -50,8 +50,8 @@ public void joinMoim(MoimJoinRequest moimJoinRequest) { moim.join(); } - public void deleteMoim(long id) { - Moim moim = moimRepository.findById(id) + public void deleteMoim(long moimId) { + Moim moim = moimRepository.findById(moimId) .orElseThrow(IllegalArgumentException::new); moimRepository.delete(moim); From 2a5587a0a0e228a1f6e084d7a27f346d04dd61d8 Mon Sep 17 00:00:00 2001 From: pricelees Date: Thu, 18 Jul 2024 17:31:27 +0900 Subject: [PATCH 05/16] =?UTF-8?q?refactor:=20=EB=AA=A8=EB=93=A0=20?= =?UTF-8?q?=EC=9B=90=EC=8B=9C=ED=83=80=EC=9E=85=20=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=ED=8F=AC=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/mouda/backend/moim/controller/MoimController.java | 4 ++-- backend/src/main/java/mouda/backend/moim/domain/Moim.java | 4 ++-- .../mouda/backend/moim/dto/request/MoimCreateRequest.java | 2 +- .../backend/moim/dto/response/MoimDetailsFindResponse.java | 4 ++-- .../backend/moim/dto/response/MoimFindAllResponse.java | 6 +++--- .../main/java/mouda/backend/moim/service/MoimService.java | 4 ++-- .../java/mouda/backend/moim/service/MoimServiceTest.java | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/backend/src/main/java/mouda/backend/moim/controller/MoimController.java b/backend/src/main/java/mouda/backend/moim/controller/MoimController.java index 9b76c7ffa..7349b3f1b 100644 --- a/backend/src/main/java/mouda/backend/moim/controller/MoimController.java +++ b/backend/src/main/java/mouda/backend/moim/controller/MoimController.java @@ -53,7 +53,7 @@ public ResponseEntity> findAllMoim() { @ApiResponse(responseCode = "200", description = "모임 상세 조회 성공!"), }) @GetMapping("/{moimId}") - public ResponseEntity> findMoimDetails(@PathVariable long moimId) { + public ResponseEntity> findMoimDetails(@PathVariable Long moimId) { return ResponseEntity.ok().body(new RestResponse<>(moimService.findMoimDetails(moimId))); } @@ -73,7 +73,7 @@ public ResponseEntity> joinMoim(@RequestBody MoimJoinRequest @ApiResponse(responseCode = "200", description = "모임 삭제 성공!"), }) @DeleteMapping("/{moimId}") - public ResponseEntity deleteMoim(@PathVariable long moimId) { + public ResponseEntity deleteMoim(@PathVariable Long moimId) { moimService.deleteMoim(moimId); return ResponseEntity.ok().build(); diff --git a/backend/src/main/java/mouda/backend/moim/domain/Moim.java b/backend/src/main/java/mouda/backend/moim/domain/Moim.java index 200054f66..0852b337e 100644 --- a/backend/src/main/java/mouda/backend/moim/domain/Moim.java +++ b/backend/src/main/java/mouda/backend/moim/domain/Moim.java @@ -31,9 +31,9 @@ public class Moim { private String place; - private int currentPeople; + private Integer currentPeople; - private int maxPeople; + private Integer maxPeople; private String authorNickname; diff --git a/backend/src/main/java/mouda/backend/moim/dto/request/MoimCreateRequest.java b/backend/src/main/java/mouda/backend/moim/dto/request/MoimCreateRequest.java index 492c2f1f6..b36992caa 100644 --- a/backend/src/main/java/mouda/backend/moim/dto/request/MoimCreateRequest.java +++ b/backend/src/main/java/mouda/backend/moim/dto/request/MoimCreateRequest.java @@ -10,7 +10,7 @@ public record MoimCreateRequest( LocalDate date, LocalTime time, String place, - int maxPeople, + Integer maxPeople, String authorNickname, String description ) { diff --git a/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java b/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java index e11fd0541..0c74e186f 100644 --- a/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java +++ b/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java @@ -12,8 +12,8 @@ public record MoimDetailsFindResponse( LocalDate date, LocalTime time, String place, - int currentPeople, - int maxPeople, + Integer currentPeople, + Integer maxPeople, String authorNickname, String description ) { diff --git a/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java b/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java index 015ba5dce..becfb8769 100644 --- a/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java +++ b/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java @@ -8,13 +8,13 @@ @Builder public record MoimFindAllResponse( - long moimId, + Long moimId, String title, LocalDate date, LocalTime time, String place, - int currentPeople, - int maxPeople, + Integer currentPeople, + Integer maxPeople, String authorNickname, String description ) { diff --git a/backend/src/main/java/mouda/backend/moim/service/MoimService.java b/backend/src/main/java/mouda/backend/moim/service/MoimService.java index d7a18e59e..e97b9b581 100644 --- a/backend/src/main/java/mouda/backend/moim/service/MoimService.java +++ b/backend/src/main/java/mouda/backend/moim/service/MoimService.java @@ -37,7 +37,7 @@ public MoimFindAllResponses findAllMoim() { } @Transactional(readOnly = true) - public MoimDetailsFindResponse findMoimDetails(long moimId) { + public MoimDetailsFindResponse findMoimDetails(Long moimId) { Moim moim = moimRepository.findById(moimId) .orElseThrow(IllegalArgumentException::new); @@ -50,7 +50,7 @@ public void joinMoim(MoimJoinRequest moimJoinRequest) { moim.join(); } - public void deleteMoim(long moimId) { + public void deleteMoim(Long moimId) { Moim moim = moimRepository.findById(moimId) .orElseThrow(IllegalArgumentException::new); diff --git a/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java b/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java index 66ca9ca59..8447c7f73 100644 --- a/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java +++ b/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java @@ -91,7 +91,7 @@ void joinMoim() { moimService.joinMoim(moimJoinRequest); MoimDetailsFindResponse moimDetails = moimService.findMoimDetails(1L); - assertThat(moimDetails.currentPeople()).isEqualTo(1); + assertThat(moimDetails.currentPeople()).isEqualTo(2); } @DisplayName("모임을 삭제한다.") From 70073932f74ad23aeba99b9a5d133c1935bc57a3 Mon Sep 17 00:00:00 2001 From: pricelees Date: Thu, 18 Jul 2024 17:59:15 +0900 Subject: [PATCH 06/16] =?UTF-8?q?refactor:=20=EC=9B=90=EC=8B=9C=EA=B0=92?= =?UTF-8?q?=20=ED=8F=AC=EC=9E=A5=EC=97=90=EC=84=9C=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=98=EB=8A=94=20NPE=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Moim.currentPeople이 null로 초기화되는 문제 해결 --- backend/src/main/java/mouda/backend/moim/domain/Moim.java | 4 ++++ .../main/java/mouda/backend/moim/service/MoimService.java | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/mouda/backend/moim/domain/Moim.java b/backend/src/main/java/mouda/backend/moim/domain/Moim.java index 0852b337e..2617310bc 100644 --- a/backend/src/main/java/mouda/backend/moim/domain/Moim.java +++ b/backend/src/main/java/mouda/backend/moim/domain/Moim.java @@ -39,6 +39,10 @@ public class Moim { private String description; + public void initCurrentPeople() { + this.currentPeople = 1; + } + public void join() { if (currentPeople + 1 > maxPeople) { throw new IllegalArgumentException(); diff --git a/backend/src/main/java/mouda/backend/moim/service/MoimService.java b/backend/src/main/java/mouda/backend/moim/service/MoimService.java index e97b9b581..bc23a71af 100644 --- a/backend/src/main/java/mouda/backend/moim/service/MoimService.java +++ b/backend/src/main/java/mouda/backend/moim/service/MoimService.java @@ -22,7 +22,10 @@ public class MoimService { private final MoimRepository moimRepository; public Moim createMoim(MoimCreateRequest moimCreateRequest) { - return moimRepository.save(moimCreateRequest.toEntity()); + Moim moim = moimCreateRequest.toEntity(); + moim.initCurrentPeople(); + + return moimRepository.save(moim); } @Transactional(readOnly = true) From 910274679ec4bf3582e83e27b406b5f62ba744f9 Mon Sep 17 00:00:00 2001 From: pricelees Date: Thu, 18 Jul 2024 18:03:28 +0900 Subject: [PATCH 07/16] =?UTF-8?q?refactor:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20Assertion=EC=97=90=EC=84=9C=20Service=EA=B0=80=20=EC=95=84?= =?UTF-8?q?=EB=8B=8C=20Repository=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - service에서 반환된 dto를 이용하는게 아닌, repository에서 반환된 domain을 이용하여 테스트 --- .../backend/moim/service/MoimServiceTest.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java b/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java index 8447c7f73..fba29afec 100644 --- a/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java +++ b/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java @@ -16,8 +16,6 @@ import mouda.backend.moim.domain.Moim; import mouda.backend.moim.dto.request.MoimCreateRequest; import mouda.backend.moim.dto.request.MoimJoinRequest; -import mouda.backend.moim.dto.response.MoimDetailsFindResponse; -import mouda.backend.moim.dto.response.MoimFindAllResponses; import mouda.backend.moim.repository.MoimRepository; @SpringBootTest @@ -44,7 +42,9 @@ void createMoim() { "title", LocalDate.now(), LocalTime.now(), "place", 10, "안나", "설명" ); + Moim moim = moimService.createMoim(moimCreateRequest); + assertThat(moim.getId()).isEqualTo(1L); } @@ -58,10 +58,8 @@ void findAllMoim() { moimService.createMoim(moimCreateRequest); moimService.createMoim(moimCreateRequest); - MoimFindAllResponses moimResponses = moimService.findAllMoim(); - - assertThat(moimResponses).isNotNull(); - assertThat(moimResponses.moims()).hasSize(2); + List moims = moimRepository.findAll(); + assertThat(moims).isNotNull().hasSize(2); } @DisplayName("모임 상세를 조회한다.") @@ -73,9 +71,8 @@ void findMoimDetails() { ); moimService.createMoim(moimCreateRequest); - MoimDetailsFindResponse moimDetails = moimService.findMoimDetails(1L); - - assertThat(moimDetails.authorNickname()).isEqualTo("안나"); + Moim moim = moimRepository.findById(1L).orElseThrow(); + assertThat(moim.getAuthorNickname()).isEqualTo("안나"); } @DisplayName("모임에 참여한다.") @@ -90,8 +87,8 @@ void joinMoim() { MoimJoinRequest moimJoinRequest = new MoimJoinRequest(1L); moimService.joinMoim(moimJoinRequest); - MoimDetailsFindResponse moimDetails = moimService.findMoimDetails(1L); - assertThat(moimDetails.currentPeople()).isEqualTo(2); + Moim moim = moimRepository.findById(1L).orElseThrow(); + assertThat(moim.getCurrentPeople()).isEqualTo(2); } @DisplayName("모임을 삭제한다.") @@ -104,8 +101,8 @@ void deleteMoim() { moimService.createMoim(moimCreateRequest); moimService.deleteMoim(1L); - List moims = moimRepository.findAll(); + List moims = moimRepository.findAll(); assertThat(moims).hasSize(0); } } From a50b08ff701b7d81488dc6e11ded4d0b0a57870f Mon Sep 17 00:00:00 2001 From: pricelees Date: Thu, 18 Jul 2024 18:05:12 +0900 Subject: [PATCH 08/16] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=EB=A1=9C=20=EC=93=B0?= =?UTF-8?q?=EC=9D=B4=EB=8A=94=20service=20=EC=BD=94=EB=93=9C=EB=A5=BC=20?= =?UTF-8?q?=EB=B3=84=EB=8F=84=EC=9D=98=20=EB=B3=80=EC=88=98=EB=A1=9C=20?= =?UTF-8?q?=EC=B6=94=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mouda/backend/moim/controller/MoimController.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/mouda/backend/moim/controller/MoimController.java b/backend/src/main/java/mouda/backend/moim/controller/MoimController.java index 7349b3f1b..5fc7efb1c 100644 --- a/backend/src/main/java/mouda/backend/moim/controller/MoimController.java +++ b/backend/src/main/java/mouda/backend/moim/controller/MoimController.java @@ -45,7 +45,9 @@ public ResponseEntity> createMoim(@RequestBody MoimCreateRequ }) @GetMapping public ResponseEntity> findAllMoim() { - return ResponseEntity.ok().body(new RestResponse<>(moimService.findAllMoim())); + MoimFindAllResponses moimFindAllResponses = moimService.findAllMoim(); + + return ResponseEntity.ok().body(new RestResponse<>(moimFindAllResponses)); } @Operation(summary = "모임 상세 조회", description = "모임 상세 조회한다.") @@ -54,7 +56,9 @@ public ResponseEntity> findAllMoim() { }) @GetMapping("/{moimId}") public ResponseEntity> findMoimDetails(@PathVariable Long moimId) { - return ResponseEntity.ok().body(new RestResponse<>(moimService.findMoimDetails(moimId))); + MoimDetailsFindResponse moimDetailsFindResponse = moimService.findMoimDetails(moimId); + + return ResponseEntity.ok().body(new RestResponse<>(moimDetailsFindResponse)); } @Operation(summary = "모임 참여", description = "모임에 참여한다.") From 898a78070721671723d58f2c602bb5ce18268848 Mon Sep 17 00:00:00 2001 From: pricelees Date: Fri, 19 Jul 2024 14:49:53 +0900 Subject: [PATCH 09/16] =?UTF-8?q?refactor:=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=EB=B0=8F=20=EC=9D=91=EB=8B=B5=EC=97=90=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EB=8A=94=20=EB=82=A0=EC=A7=9C=20=EB=B0=8F=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=ED=98=95=EC=8B=9D=20=ED=86=B5=EC=9D=BC=20=EB=B0=8F?= =?UTF-8?q?=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mouda/backend/config/DateTimeFormat.java | 16 ++ .../mouda/backend/config/JacksonConfig.java | 43 +++++ backend/src/main/resources/application.yml | 6 + .../backend/config/JacksonConfigTest.java | 176 ++++++++++++++++++ backend/src/test/resources/application.yml | 6 + 5 files changed, 247 insertions(+) create mode 100644 backend/src/main/java/mouda/backend/config/DateTimeFormat.java create mode 100644 backend/src/main/java/mouda/backend/config/JacksonConfig.java create mode 100644 backend/src/test/java/mouda/backend/config/JacksonConfigTest.java diff --git a/backend/src/main/java/mouda/backend/config/DateTimeFormat.java b/backend/src/main/java/mouda/backend/config/DateTimeFormat.java new file mode 100644 index 000000000..cb5f3ea54 --- /dev/null +++ b/backend/src/main/java/mouda/backend/config/DateTimeFormat.java @@ -0,0 +1,16 @@ +package mouda.backend.config; + + +import org.springframework.boot.context.properties.ConfigurationProperties; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@ConfigurationProperties("datetime.format") +@RequiredArgsConstructor +@Getter +public class DateTimeFormat { + + private final String date; + private final String time; +} diff --git a/backend/src/main/java/mouda/backend/config/JacksonConfig.java b/backend/src/main/java/mouda/backend/config/JacksonConfig.java new file mode 100644 index 000000000..44a81ae6a --- /dev/null +++ b/backend/src/main/java/mouda/backend/config/JacksonConfig.java @@ -0,0 +1,43 @@ +package mouda.backend.config; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; + +@Configuration +@EnableConfigurationProperties(DateTimeFormat.class) +public class JacksonConfig { + + @Bean + public ObjectMapper objectMapper(DateTimeFormat dateTimeFormat) { + return new ObjectMapper() + .registerModule(javaTimeModule(dateTimeFormat)); + } + + @Bean + public JavaTimeModule javaTimeModule(DateTimeFormat dateTimeFormat) { + JavaTimeModule javaTimeModule = new JavaTimeModule(); + + javaTimeModule.addSerializer(LocalDate.class, + new LocalDateSerializer(DateTimeFormatter.ofPattern(dateTimeFormat.getDate()))) + .addSerializer(LocalTime.class, + new LocalTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat.getTime()))) + .addDeserializer(LocalDate.class, + new LocalDateDeserializer(DateTimeFormatter.ofPattern(dateTimeFormat.getDate()))) + .addDeserializer(LocalTime.class, + new LocalTimeDeserializer(DateTimeFormatter.ofPattern(dateTimeFormat.getTime()))); + + return javaTimeModule; + } +} diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 11ecad4c8..4930ac114 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -19,3 +19,9 @@ spring: console: enabled: true path: /h2-console + + +datetime: + format: + date: yyyy-MM-dd + time: HH:mm diff --git a/backend/src/test/java/mouda/backend/config/JacksonConfigTest.java b/backend/src/test/java/mouda/backend/config/JacksonConfigTest.java new file mode 100644 index 000000000..1b5367086 --- /dev/null +++ b/backend/src/test/java/mouda/backend/config/JacksonConfigTest.java @@ -0,0 +1,176 @@ +package mouda.backend.config; + +import static org.hamcrest.Matchers.*; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.util.Map; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; + +import io.restassured.RestAssured; +import mouda.backend.moim.domain.Moim; +import mouda.backend.moim.repository.MoimRepository; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +class JacksonConfigTest { + + @Autowired + private MoimRepository moimRepository; + + @Autowired + private DatabaseCleaner databaseCleaner; + + @LocalServerPort + private int port; + + @BeforeEach + void setUp() { + RestAssured.port = port; + } + + @AfterEach + void tearDown() { + databaseCleaner.cleanUp(); + } + + @DisplayName("날짜 형식에 따른 직렬화 및 역직렬화 테스트") + @Nested + class DateDeserialize { + + @DisplayName("yyyy-MM-dd 형식의 날짜를 역직렬화한다.") + @Test + void deserialize() { + Map params = Map.of( + "title", "title", + "date", "2024-07-19", + "time", "12:30", + "place", "place", + "maxPeople", 10, + "authorNickname", "안나", + "description", "설명" + ); + + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(params) + .when().post("/v1/moim") + .then().statusCode(is(HttpStatus.OK.value())); + } + + @DisplayName("yyyy-MM-dd 형식이 아닌 날짜가 입력되면 예외가 발생한다.") + @Test + void deserialize_when_invalidDateFormat() { + Map params = Map.of( + "title", "title", + "date", "2024/07/19", + "time", "12:30", + "place", "place", + "maxPeople", 10, + "authorNickname", "안나", + "description", "설명" + ); + + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(params) + .when().post("/v1/moim") + .then().statusCode(is(HttpStatus.BAD_REQUEST.value())); + } + + @DisplayName("날짜는 yyyy-MM-dd 형식으로 직렬화된다.") + @Test + void dateSerialize() { + Moim moim = Moim.builder() + .title("title") + .date(LocalDate.parse("2024-07-19")) + .time(LocalTime.parse("12:30")) + .place("place") + .maxPeople(10) + .authorNickname("안나") + .description("설명") + .build(); + + Moim saved = moimRepository.save(moim); + + RestAssured.given() + .when().get("/v1/moim/" + saved.getId()) + .then().statusCode(is(HttpStatus.OK.value())) + .body("data.date", is("2024-07-19")); + } + } + + @DisplayName("시간 형식에 따른 직렬화 및 역직렬화 테스트") + @Nested + class TimeSerialize { + + @DisplayName("HH:mm 형식의 시간을 역직렬화한다.") + @Test + void deserialize() { + Map params = Map.of( + "title", "title", + "date", "2024-07-19", + "time", "12:30", + "place", "place", + "maxPeople", 10, + "authorNickname", "안나", + "description", "설명" + ); + + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(params) + .when().post("/v1/moim") + .then().statusCode(is(HttpStatus.OK.value())); + } + + @DisplayName("HH:mm 형식이 아닌 시간이 입력되면 예외가 발생한다.") + @Test + void deserialize_when_invalidTimeFormat() { + Map params = Map.of( + "title", "title", + "date", "2024-07-19", + "time", "12-30", + "place", "place", + "maxPeople", 10, + "authorNickname", "안나", + "description", "설명" + ); + + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(params) + .when().post("/v1/moim") + .then().statusCode(is(HttpStatus.BAD_REQUEST.value())); + } + + @DisplayName("시간은 HH:mm 형식으로 직렬화된다.") + @Test + void serialize() { + Moim moim = Moim.builder() + .title("title") + .date(LocalDate.now().plusDays(1)) + .time(LocalTime.parse("12:30")) + .place("place") + .maxPeople(10) + .authorNickname("안나") + .description("설명") + .build(); + Moim saved = moimRepository.save(moim); + + RestAssured.given() + .when().get("/v1/moim/" + saved.getId()) + .then().statusCode(is(HttpStatus.OK.value())) + .body("data.time", is("12:30")); + } + } +} diff --git a/backend/src/test/resources/application.yml b/backend/src/test/resources/application.yml index 026ce36af..cf1a8f302 100644 --- a/backend/src/test/resources/application.yml +++ b/backend/src/test/resources/application.yml @@ -9,3 +9,9 @@ spring: sql: init: data-locations: classpath:test-data.sql + + +datetime: + format: + date: yyyy-MM-dd + time: HH:mm From c52c39b0b1166be85ca59a24b0fdb8c403a669f3 Mon Sep 17 00:00:00 2001 From: pricelees Date: Fri, 19 Jul 2024 14:57:26 +0900 Subject: [PATCH 10/16] =?UTF-8?q?refactor:=20=EB=B0=98=ED=99=98=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EC=9B=90?= =?UTF-8?q?=EC=8B=9C=ED=83=80=EC=9E=85=20=EB=B3=80=EC=88=98=20=ED=8F=AC?= =?UTF-8?q?=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/mouda/backend/moim/controller/MoimSwagger.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/mouda/backend/moim/controller/MoimSwagger.java b/backend/src/main/java/mouda/backend/moim/controller/MoimSwagger.java index 48994dab9..41ce1e561 100644 --- a/backend/src/main/java/mouda/backend/moim/controller/MoimSwagger.java +++ b/backend/src/main/java/mouda/backend/moim/controller/MoimSwagger.java @@ -31,7 +31,7 @@ public interface MoimSwagger { @ApiResponses({ @ApiResponse(responseCode = "200", description = "모임 상세 조회 성공!"), }) - ResponseEntity> findMoimDetails(@PathVariable long moimId); + ResponseEntity> findMoimDetails(@PathVariable Long moimId); @Operation(summary = "모임 참여", description = "모임에 참여한다.") @ApiResponses({ @@ -43,5 +43,5 @@ public interface MoimSwagger { @ApiResponses({ @ApiResponse(responseCode = "200", description = "모임 삭제 성공!"), }) - void deleteMoim(@PathVariable long moimId); + ResponseEntity deleteMoim(@PathVariable Long moimId); } From 10b4f6ec72baeee34925cda375ea2e3803fe05e8 Mon Sep 17 00:00:00 2001 From: pricelees Date: Sat, 20 Jul 2024 14:53:54 +0900 Subject: [PATCH 11/16] =?UTF-8?q?refactor:=20=EB=B0=98=ED=99=98=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/mouda/backend/moim/controller/MoimController.java | 2 +- .../main/java/mouda/backend/moim/controller/MoimSwagger.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/mouda/backend/moim/controller/MoimController.java b/backend/src/main/java/mouda/backend/moim/controller/MoimController.java index e26a4c9f5..c56a535c0 100644 --- a/backend/src/main/java/mouda/backend/moim/controller/MoimController.java +++ b/backend/src/main/java/mouda/backend/moim/controller/MoimController.java @@ -51,7 +51,7 @@ public ResponseEntity> findMoimDetails(@Pa @Override @PostMapping("/join") - public ResponseEntity> joinMoim(@RequestBody MoimJoinRequest moimJoinRequest) { + public ResponseEntity joinMoim(@RequestBody MoimJoinRequest moimJoinRequest) { moimService.joinMoim(moimJoinRequest); return ResponseEntity.ok().build(); diff --git a/backend/src/main/java/mouda/backend/moim/controller/MoimSwagger.java b/backend/src/main/java/mouda/backend/moim/controller/MoimSwagger.java index 41ce1e561..90bf816ea 100644 --- a/backend/src/main/java/mouda/backend/moim/controller/MoimSwagger.java +++ b/backend/src/main/java/mouda/backend/moim/controller/MoimSwagger.java @@ -37,7 +37,7 @@ public interface MoimSwagger { @ApiResponses({ @ApiResponse(responseCode = "200", description = "모임 참여 성공!") }) - ResponseEntity> joinMoim(@RequestBody MoimJoinRequest moimJoinRequest); + ResponseEntity joinMoim(@RequestBody MoimJoinRequest moimJoinRequest); @Operation(summary = "모임 삭제", description = "해당하는 id의 모임을 삭제한다.") @ApiResponses({ From 237f9d69f886da10aaa7564cbdb5e6bd0386b14e Mon Sep 17 00:00:00 2001 From: pricelees Date: Mon, 22 Jul 2024 16:53:56 +0900 Subject: [PATCH 12/16] =?UTF-8?q?refactor:=20property=EC=97=90=20=EC=A7=80?= =?UTF-8?q?=EC=A0=95=ED=95=9C=20=EB=82=A0=EC=A7=9C,=20=EC=8B=9C=EA=B0=84?= =?UTF-8?q?=20=ED=8F=AC=EB=A7=B7=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mouda/backend/config/DateTimeFormat.java | 16 ------------- .../mouda/backend/config/JacksonConfig.java | 24 ++++++------------- backend/src/main/resources/application.yml | 6 ----- .../backend/config/JacksonConfigTest.java | 6 ++--- backend/src/test/resources/application.yml | 6 ----- 5 files changed, 10 insertions(+), 48 deletions(-) delete mode 100644 backend/src/main/java/mouda/backend/config/DateTimeFormat.java diff --git a/backend/src/main/java/mouda/backend/config/DateTimeFormat.java b/backend/src/main/java/mouda/backend/config/DateTimeFormat.java deleted file mode 100644 index cb5f3ea54..000000000 --- a/backend/src/main/java/mouda/backend/config/DateTimeFormat.java +++ /dev/null @@ -1,16 +0,0 @@ -package mouda.backend.config; - - -import org.springframework.boot.context.properties.ConfigurationProperties; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@ConfigurationProperties("datetime.format") -@RequiredArgsConstructor -@Getter -public class DateTimeFormat { - - private final String date; - private final String time; -} diff --git a/backend/src/main/java/mouda/backend/config/JacksonConfig.java b/backend/src/main/java/mouda/backend/config/JacksonConfig.java index 44a81ae6a..d2ff7d583 100644 --- a/backend/src/main/java/mouda/backend/config/JacksonConfig.java +++ b/backend/src/main/java/mouda/backend/config/JacksonConfig.java @@ -4,7 +4,6 @@ import java.time.LocalTime; import java.time.format.DateTimeFormatter; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -16,27 +15,18 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; @Configuration -@EnableConfigurationProperties(DateTimeFormat.class) public class JacksonConfig { @Bean - public ObjectMapper objectMapper(DateTimeFormat dateTimeFormat) { - return new ObjectMapper() - .registerModule(javaTimeModule(dateTimeFormat)); - } - - @Bean - public JavaTimeModule javaTimeModule(DateTimeFormat dateTimeFormat) { + public JavaTimeModule javaTimeModule() { JavaTimeModule javaTimeModule = new JavaTimeModule(); + DateTimeFormatter dateFormat = DateTimeFormatter.ISO_LOCAL_DATE; + DateTimeFormatter timeFormat = DateTimeFormatter.ofPattern("HH:mm"); - javaTimeModule.addSerializer(LocalDate.class, - new LocalDateSerializer(DateTimeFormatter.ofPattern(dateTimeFormat.getDate()))) - .addSerializer(LocalTime.class, - new LocalTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat.getTime()))) - .addDeserializer(LocalDate.class, - new LocalDateDeserializer(DateTimeFormatter.ofPattern(dateTimeFormat.getDate()))) - .addDeserializer(LocalTime.class, - new LocalTimeDeserializer(DateTimeFormatter.ofPattern(dateTimeFormat.getTime()))); + javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(dateFormat)) + .addSerializer(LocalTime.class, new LocalTimeSerializer(timeFormat)) + .addDeserializer(LocalDate.class, new LocalDateDeserializer(dateFormat)) + .addDeserializer(LocalTime.class, new LocalTimeDeserializer(timeFormat)); return javaTimeModule; } diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 4930ac114..11ecad4c8 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -19,9 +19,3 @@ spring: console: enabled: true path: /h2-console - - -datetime: - format: - date: yyyy-MM-dd - time: HH:mm diff --git a/backend/src/test/java/mouda/backend/config/JacksonConfigTest.java b/backend/src/test/java/mouda/backend/config/JacksonConfigTest.java index 1b5367086..4440a39cd 100644 --- a/backend/src/test/java/mouda/backend/config/JacksonConfigTest.java +++ b/backend/src/test/java/mouda/backend/config/JacksonConfigTest.java @@ -45,7 +45,7 @@ void tearDown() { @DisplayName("날짜 형식에 따른 직렬화 및 역직렬화 테스트") @Nested - class DateDeserialize { + class DateFormatTest { @DisplayName("yyyy-MM-dd 형식의 날짜를 역직렬화한다.") @Test @@ -89,7 +89,7 @@ void deserialize_when_invalidDateFormat() { @DisplayName("날짜는 yyyy-MM-dd 형식으로 직렬화된다.") @Test - void dateSerialize() { + void serialize() { Moim moim = Moim.builder() .title("title") .date(LocalDate.parse("2024-07-19")) @@ -111,7 +111,7 @@ void dateSerialize() { @DisplayName("시간 형식에 따른 직렬화 및 역직렬화 테스트") @Nested - class TimeSerialize { + class TimeFormatTest { @DisplayName("HH:mm 형식의 시간을 역직렬화한다.") @Test diff --git a/backend/src/test/resources/application.yml b/backend/src/test/resources/application.yml index cf1a8f302..026ce36af 100644 --- a/backend/src/test/resources/application.yml +++ b/backend/src/test/resources/application.yml @@ -9,9 +9,3 @@ spring: sql: init: data-locations: classpath:test-data.sql - - -datetime: - format: - date: yyyy-MM-dd - time: HH:mm From aa54ad684077b2e7eaaca780085873e503030466 Mon Sep 17 00:00:00 2001 From: pricelees Date: Mon, 22 Jul 2024 17:05:03 +0900 Subject: [PATCH 13/16] =?UTF-8?q?refactor:=20=EB=8F=84=EB=A9=94=EC=9D=B8?= =?UTF-8?q?=EC=97=90=EC=84=9C=EC=9D=98=20wrapper=20type=20=EC=96=B8?= =?UTF-8?q?=EB=B0=95=EC=8B=B1=20=EB=B0=8F=20=EB=B9=8C=EB=8D=94=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EC=83=9D=EC=84=B1=EC=9E=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/mouda/backend/moim/domain/Moim.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/mouda/backend/moim/domain/Moim.java b/backend/src/main/java/mouda/backend/moim/domain/Moim.java index 4655b54eb..29dee9155 100644 --- a/backend/src/main/java/mouda/backend/moim/domain/Moim.java +++ b/backend/src/main/java/mouda/backend/moim/domain/Moim.java @@ -9,7 +9,6 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; -import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -18,9 +17,7 @@ @Entity @Getter -@Builder @NoArgsConstructor -@AllArgsConstructor public class Moim { @Id @@ -35,16 +32,32 @@ public class Moim { private String place; - private Integer currentPeople; + private int currentPeople; - private Integer maxPeople; + private int maxPeople; private String authorNickname; private String description; - public void initCurrentPeople() { + @Builder + public Moim( + String title, + LocalDate date, + LocalTime time, + String place, + int maxPeople, + String authorNickname, + String description + ) { + this.title = title; + this.date = date; + this.time = time; + this.place = place; this.currentPeople = 1; + this.maxPeople = maxPeople; + this.authorNickname = authorNickname; + this.description = description; } public void join() { From 3d6a9d6ff71477fe25324c49cc21cfe2c05518af Mon Sep 17 00:00:00 2001 From: pricelees Date: Mon, 22 Jul 2024 17:06:04 +0900 Subject: [PATCH 14/16] =?UTF-8?q?refactor:=20=EC=9D=91=EB=8B=B5=EC=97=90?= =?UTF-8?q?=EC=84=9C=EC=9D=98=20wrapper=20type=20=EC=96=B8=EB=B0=95?= =?UTF-8?q?=EC=8B=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/moim/dto/response/MoimDetailsFindResponse.java | 4 ++-- .../mouda/backend/moim/dto/response/MoimFindAllResponse.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java b/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java index 0c74e186f..e11fd0541 100644 --- a/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java +++ b/backend/src/main/java/mouda/backend/moim/dto/response/MoimDetailsFindResponse.java @@ -12,8 +12,8 @@ public record MoimDetailsFindResponse( LocalDate date, LocalTime time, String place, - Integer currentPeople, - Integer maxPeople, + int currentPeople, + int maxPeople, String authorNickname, String description ) { diff --git a/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java b/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java index becfb8769..e18b1aa11 100644 --- a/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java +++ b/backend/src/main/java/mouda/backend/moim/dto/response/MoimFindAllResponse.java @@ -13,8 +13,8 @@ public record MoimFindAllResponse( LocalDate date, LocalTime time, String place, - Integer currentPeople, - Integer maxPeople, + int currentPeople, + int maxPeople, String authorNickname, String description ) { From db1237211d7bb8ef823f7c3be74443a8be4943b3 Mon Sep 17 00:00:00 2001 From: pricelees Date: Mon, 22 Jul 2024 17:14:11 +0900 Subject: [PATCH 15/16] =?UTF-8?q?style:=20=EC=BD=94=EB=93=9C=20=EC=BB=A8?= =?UTF-8?q?=EB=B2=A4=EC=85=98=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/mouda/backend/config/JacksonConfig.java | 1 - backend/src/test/resources/application.yml | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/mouda/backend/config/JacksonConfig.java b/backend/src/main/java/mouda/backend/config/JacksonConfig.java index d2ff7d583..d9a4fc542 100644 --- a/backend/src/main/java/mouda/backend/config/JacksonConfig.java +++ b/backend/src/main/java/mouda/backend/config/JacksonConfig.java @@ -7,7 +7,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; diff --git a/backend/src/test/resources/application.yml b/backend/src/test/resources/application.yml index 026ce36af..3ba0d1773 100644 --- a/backend/src/test/resources/application.yml +++ b/backend/src/test/resources/application.yml @@ -4,7 +4,8 @@ spring: properties: hibernate: format_sql: true - ddl-auto: create-drop + hibernate: + ddl-auto: create-drop defer-datasource-initialization: true sql: init: From 31a432c27d284b8339c6c4ce9a5d65eff9f65a78 Mon Sep 17 00:00:00 2001 From: pricelees Date: Mon, 22 Jul 2024 18:08:22 +0900 Subject: [PATCH 16/16] =?UTF-8?q?refactor:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=97=90=EC=84=9C=EC=9D=98=20Optional=20=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mouda/backend/moim/service/MoimServiceTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java b/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java index fba29afec..341b85007 100644 --- a/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java +++ b/backend/src/test/java/mouda/backend/moim/service/MoimServiceTest.java @@ -5,7 +5,9 @@ import java.time.LocalDate; import java.time.LocalTime; import java.util.List; +import java.util.Optional; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -71,8 +73,9 @@ void findMoimDetails() { ); moimService.createMoim(moimCreateRequest); - Moim moim = moimRepository.findById(1L).orElseThrow(); - assertThat(moim.getAuthorNickname()).isEqualTo("안나"); + Optional moimOptional = moimRepository.findById(1L); + assertThat(moimOptional).isNotEmpty(); + assertThat(moimOptional.get().getAuthorNickname()).isEqualTo("안나"); } @DisplayName("모임에 참여한다.") @@ -87,8 +90,9 @@ void joinMoim() { MoimJoinRequest moimJoinRequest = new MoimJoinRequest(1L); moimService.joinMoim(moimJoinRequest); - Moim moim = moimRepository.findById(1L).orElseThrow(); - assertThat(moim.getCurrentPeople()).isEqualTo(2); + Optional moimOptional = moimRepository.findById(1L); + assertThat(moimOptional).isNotEmpty(); + assertThat(moimOptional.get().getCurrentPeople()).isEqualTo(2); } @DisplayName("모임을 삭제한다.")