Skip to content

Commit

Permalink
fix: 0시 인증 방에서 인증이 안되는 버그 수정 (#213)
Browse files Browse the repository at this point in the history
* fix: 0시 인증타임 예외처리 수정

* test: 테스트 수정
  • Loading branch information
ymkim97 authored Nov 30, 2023
1 parent e1e7477 commit 109e04c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.moabam.api.application.room;

import static com.moabam.global.common.util.GlobalConstant.*;
import static com.moabam.global.error.model.ErrorMessage.*;

import java.time.LocalDate;
Expand Down Expand Up @@ -109,8 +110,13 @@ public Certification findCertification(Long certificationId) {

private void validateCertifyTime(LocalDateTime now, int certifyTime) {
LocalTime targetTime = LocalTime.of(certifyTime, 0);
LocalDateTime minusTenMinutes = LocalDateTime.of(now.toLocalDate(), targetTime).minusMinutes(10);
LocalDateTime plusTenMinutes = LocalDateTime.of(now.toLocalDate(), targetTime).plusMinutes(10);
LocalDateTime targetDateTime = LocalDateTime.of(now.toLocalDate(), targetTime);
if (certifyTime == MIDNIGHT_HOUR) {
targetDateTime = targetDateTime.plusDays(1);
}

LocalDateTime minusTenMinutes = targetDateTime.minusMinutes(10);
LocalDateTime plusTenMinutes = targetDateTime.plusMinutes(10);

if (now.isBefore(minusTenMinutes) || now.isAfter(plusTenMinutes)) {
throw new BadRequestException(INVALID_CERTIFY_TIME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class GlobalConstant {
public static final String DELIMITER = "/";
public static final String CHARSET_UTF_8 = ";charset=UTF-8";
public static final String SPACE = " ";
public static final int MIDNIGHT_HOUR = 0;
public static final int ONE_HOUR = 1;
public static final int HOURS_IN_A_DAY = 24;
public static final int NOT_COMPLETED_RANK = 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ void get_room_details_test() throws Exception {
dailyRoomCertificationRepository.save(dailyRoomCertification);

DailyRoomCertification dailyRoomCertification1 = RoomFixture.dailyRoomCertification(room.getId(),
LocalDate.of(LocalDate.now().getYear(), LocalDate.now().getMonth(), LocalDate.now().getDayOfMonth() - 3));
LocalDate.now().minusDays(3));
dailyRoomCertificationRepository.save(dailyRoomCertification1);

// expected
Expand Down

0 comments on commit 109e04c

Please sign in to comment.