diff --git a/src/main/java/com/asap/server/controller/dto/request/MeetingConfirmRequestDto.java b/src/main/java/com/asap/server/controller/dto/request/MeetingConfirmRequestDto.java index b082cd56..b5ad3c61 100644 --- a/src/main/java/com/asap/server/controller/dto/request/MeetingConfirmRequestDto.java +++ b/src/main/java/com/asap/server/controller/dto/request/MeetingConfirmRequestDto.java @@ -4,11 +4,15 @@ import java.util.List; import javax.validation.constraints.NotNull; import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @Getter +@Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) public class MeetingConfirmRequestDto { @NotNull(message = "회의 진행 월이 입력되지 않았습니다.") private String month; diff --git a/src/main/java/com/asap/server/controller/dto/request/UserRequestDto.java b/src/main/java/com/asap/server/controller/dto/request/UserRequestDto.java index d9b5c4cd..c439d096 100644 --- a/src/main/java/com/asap/server/controller/dto/request/UserRequestDto.java +++ b/src/main/java/com/asap/server/controller/dto/request/UserRequestDto.java @@ -1,11 +1,15 @@ package com.asap.server.controller.dto.request; import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @Getter +@Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) public class UserRequestDto { private Long id; private String name; diff --git a/src/main/java/com/asap/server/domain/Meeting.java b/src/main/java/com/asap/server/domain/Meeting.java index cc03ab9c..1d4221be 100644 --- a/src/main/java/com/asap/server/domain/Meeting.java +++ b/src/main/java/com/asap/server/domain/Meeting.java @@ -22,7 +22,7 @@ @Entity @Getter @Builder -@AllArgsConstructor +@AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Meeting extends AuditingTimeEntity { @Id diff --git a/src/main/java/com/asap/server/domain/User.java b/src/main/java/com/asap/server/domain/User.java index d7a674db..aa15491b 100644 --- a/src/main/java/com/asap/server/domain/User.java +++ b/src/main/java/com/asap/server/domain/User.java @@ -23,7 +23,7 @@ @Getter @Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor +@AllArgsConstructor(access = AccessLevel.PRIVATE) public class User extends AuditingTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/asap/server/service/MeetingService.java b/src/main/java/com/asap/server/service/MeetingService.java index 037f280f..a1a6444e 100644 --- a/src/main/java/com/asap/server/service/MeetingService.java +++ b/src/main/java/com/asap/server/service/MeetingService.java @@ -98,17 +98,17 @@ public void confirmMeeting( userService.setFixedUsers(meeting, meetingConfirmRequestDto.getUsers()); - LocalDate fixedDate = DateUtil.transformLocalDate(meetingConfirmRequestDto.getMonth(), meetingConfirmRequestDto.getDay()); + deleteMeetingTimes(meeting); + LocalDate fixedDate = DateUtil.transformLocalDate(meetingConfirmRequestDto.getMonth(), meetingConfirmRequestDto.getDay()); LocalTime startTime = DateUtil.parseLocalTime(meetingConfirmRequestDto.getStartTime().getTime()); LocalTime endTime = DateUtil.parseLocalTime(meetingConfirmRequestDto.getEndTime().getTime()); LocalDateTime fixedStartDateTime = LocalDateTime.of(fixedDate, startTime); LocalDateTime fixedEndDateTime = LocalDateTime.of(fixedDate, endTime); - meeting.setConfirmedDateTime(fixedStartDateTime, fixedEndDateTime); - deleteMeetingTimes(meeting); + meetingRepository.save(meeting); } private void deleteMeetingTimes(final Meeting meeting) { diff --git a/src/test/java/com/asap/server/service/meeting/ConfirmMeetingMethodTest.java b/src/test/java/com/asap/server/service/meeting/ConfirmMeetingMethodTest.java new file mode 100644 index 00000000..c81d1b6d --- /dev/null +++ b/src/test/java/com/asap/server/service/meeting/ConfirmMeetingMethodTest.java @@ -0,0 +1,80 @@ +package com.asap.server.service.meeting; + +import com.asap.server.controller.dto.request.MeetingConfirmRequestDto; +import com.asap.server.controller.dto.request.UserRequestDto; +import com.asap.server.domain.Meeting; +import com.asap.server.domain.Place; +import com.asap.server.domain.User; +import com.asap.server.domain.enums.Duration; +import com.asap.server.domain.enums.PlaceType; +import com.asap.server.domain.enums.Role; +import com.asap.server.domain.enums.TimeSlot; +import com.asap.server.service.MeetingService; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +import javax.persistence.EntityManager; +import javax.transaction.Transactional; +import java.util.List; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +@SpringBootTest +@Transactional +public class ConfirmMeetingMethodTest { + @Autowired + private MeetingService meetingService; + @Autowired + private EntityManager em; + + @Test + @DisplayName("회의 확정시 ConfirmedDateTime 은 Update 된다.") + void setConfirmDateTimeTest() { + // given + final Place place = Place.builder() + .placeType(PlaceType.OFFLINE) + .build(); + final Meeting meeting = Meeting.builder() + .title("회의 테스트") + .password("0000") + .additionalInfo("") + .duration(Duration.HALF) + .place(place) + .build(); + final User user = User.builder() + .meeting(meeting) + .name("강원용") + .role(Role.HOST) + .isFixed(false) + .build(); + meeting.setHost(user); + + em.persist(meeting); + em.persist(user); + em.flush(); + em.clear(); + + final UserRequestDto userDto = UserRequestDto.builder() + .id(user.getId()) + .name(user.getName()) + .build(); + final MeetingConfirmRequestDto body = MeetingConfirmRequestDto.builder() + .month("09") + .day("07") + .dayOfWeek("월") + .startTime(TimeSlot.SLOT_6_00) + .endTime(TimeSlot.SLOT_6_30) + .users(List.of(userDto)) + .build(); + + // when + meetingService.confirmMeeting(body, meeting.getId(), user.getId()); + + // then + final Meeting result = em.find(Meeting.class, meeting.getId()); + assertThat(result.isConfirmedMeeting()).isTrue(); + } + +}