Skip to content

Commit

Permalink
refactor: 스터디를 주입받도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook02 committed Aug 2, 2024
1 parent 23603ce commit 151cf82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import static org.assertj.core.api.Assertions.*;

import com.gdschongik.gdsc.domain.member.domain.Member;
import com.gdschongik.gdsc.domain.member.domain.MemberRole;
import com.gdschongik.gdsc.domain.recruitment.domain.vo.Period;
import com.gdschongik.gdsc.domain.study.dao.StudyDetailRepository;
import com.gdschongik.gdsc.domain.study.domain.Study;
import com.gdschongik.gdsc.domain.study.domain.StudyDetail;
import com.gdschongik.gdsc.domain.study.domain.StudyStatus;
import com.gdschongik.gdsc.helper.IntegrationTest;
Expand All @@ -27,7 +30,12 @@ class 스터디_과제_휴강_처리시 {
void 성공한다() {
// given
LocalDateTime now = LocalDateTime.now();
StudyDetail studyDetail = createStudyDetail(now, now.plusDays(7));
Member mentor = createAssociateMember();
Study study = createStudy(
mentor,
Period.createPeriod(now.plusDays(5), now.plusDays(10)),
Period.createPeriod(now.minusDays(5), now));
StudyDetail studyDetail = createStudyDetail(study, now, now.plusDays(7));
logoutAndReloginAs(studyDetail.getStudy().getMentor().getId(), MemberRole.ASSOCIATE);

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,7 @@ protected Study createStudy(Member mentor, Period period, Period applicationPeri
return studyRepository.save(study);
}

protected StudyDetail createStudyDetail(LocalDateTime startDate, LocalDateTime endDate) {
Member mentor = createAssociateMember();
LocalDateTime now = LocalDateTime.now();
Study study = createStudy(
mentor,
Period.createPeriod(now.plusDays(5), now.plusDays(10)),
Period.createPeriod(now.minusDays(5), now));

protected StudyDetail createStudyDetail(Study study, LocalDateTime startDate, LocalDateTime endDate) {
StudyDetail studyDetail =
StudyDetail.createStudyDetail(study, 1L, ATTENDANCE_NUMBER, Period.createPeriod(startDate, endDate));
return studyDetailRepository.save(studyDetail);
Expand Down

0 comments on commit 151cf82

Please sign in to comment.