From f35efc177898f1939e3969c219475a3d6e87697e Mon Sep 17 00:00:00 2001 From: Jae Min Yu Date: Tue, 31 Oct 2023 23:50:49 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[BE]=20Round=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95=20(#591)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Round 업데이트 로직 수정 * refactor: 매개변수명 수정 --- .../backend/application/StudyService.java | 2 +- .../yigongil/backend/domain/study/Study.java | 4 +- .../acceptance/steps/StudyProgressStep.java | 54 ++++++++++++++++--- .../backend/acceptance/steps/StudySteps.java | 20 ++++++- .../resources/features/study-progress.feature | 32 ++++++++++- 5 files changed, 101 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/com/yigongil/backend/application/StudyService.java b/backend/src/main/java/com/yigongil/backend/application/StudyService.java index 94186030b..0abb26941 100644 --- a/backend/src/main/java/com/yigongil/backend/application/StudyService.java +++ b/backend/src/main/java/com/yigongil/backend/application/StudyService.java @@ -223,7 +223,7 @@ public void proceedRound(LocalDate today) { List studies = studyRepository.findAllByProcessingStatus(ProcessingStatus.PROCESSING); studies.stream() - .filter(study -> study.isCurrentRoundEndAt(today)) + .filter(study -> study.isCurrentRoundEndAt(today.minusDays(1))) .forEach(Study::updateToNextRound); } diff --git a/backend/src/main/java/com/yigongil/backend/domain/study/Study.java b/backend/src/main/java/com/yigongil/backend/domain/study/Study.java index 8ab6bf037..4082e0aa1 100644 --- a/backend/src/main/java/com/yigongil/backend/domain/study/Study.java +++ b/backend/src/main/java/com/yigongil/backend/domain/study/Study.java @@ -207,8 +207,8 @@ public int sizeOfCurrentMembers() { .count(); } - public boolean isCurrentRoundEndAt(LocalDate today) { - return getCurrentRound().isEndAt(today); + public boolean isCurrentRoundEndAt(LocalDate date) { + return getCurrentRound().isEndAt(date); } public void start(Member member, List daysOfTheWeek, LocalDateTime startAt) { diff --git a/backend/src/test/java/com/yigongil/backend/acceptance/steps/StudyProgressStep.java b/backend/src/test/java/com/yigongil/backend/acceptance/steps/StudyProgressStep.java index e86568fb4..ebee4956d 100644 --- a/backend/src/test/java/com/yigongil/backend/acceptance/steps/StudyProgressStep.java +++ b/backend/src/test/java/com/yigongil/backend/acceptance/steps/StudyProgressStep.java @@ -2,15 +2,20 @@ import static io.restassured.RestAssured.given; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertAll; import com.yigongil.backend.domain.study.ProcessingStatus; +import com.yigongil.backend.response.MembersCertificationResponse; import com.yigongil.backend.response.StudyDetailResponse; +import com.yigongil.backend.response.UpcomingRoundResponse; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import io.restassured.response.ExtractableResponse; import io.restassured.response.Response; +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjusters; import org.junit.Ignore; import org.springframework.http.HttpHeaders; @@ -32,6 +37,34 @@ public StudyProgressStep(SharedContext sharedContext) { .extract(); } + @Given("이번주 일요일이 됐다.") + public void 이번주_일요일() { + LocalDate today = LocalDate.now(); + LocalDate sunday = today.with(DayOfWeek.SUNDAY); + long daysUntilSunday = ChronoUnit.DAYS.between(today, sunday); + + given().when() + .put("/fake/proceed?days=" + daysUntilSunday) + .then() + .log() + .all() + .extract(); + } + + @Given("다음주 월요일이 됐다.") + public void 다음주_월요일() { + LocalDate today = LocalDate.now(); + LocalDate nextMonday = today.with(TemporalAdjusters.next(DayOfWeek.MONDAY)); + long daysUntilNextMonday = ChronoUnit.DAYS.between(today, nextMonday); + + given().when() + .put("/fake/proceed?days=" + daysUntilNextMonday) + .then() + .log() + .all() + .extract(); + } + @When("{string}가 {string} 스터디를 조회한다.") public void 스터디_조회(String memberGithubId, String studyName) { String token = sharedContext.getToken(memberGithubId); @@ -52,12 +85,21 @@ public StudyProgressStep(SharedContext sharedContext) { @Ignore("스터디라운드 -> 주차반영까지 무시") // TODO: 스터디라운드 -> 주차반영 @Then("스터디의 현재 주차가 {int}로 변경되어 있다.") public void 스터디_현재_회차_조회(int expectedWeekNumber) { - StudyDetailResponse studyDetailResponse = sharedContext.getResponse().as(StudyDetailResponse.class); + UpcomingRoundResponse response = sharedContext.getResponse() + .as(MembersCertificationResponse.class) + .upcomingRound(); + + assertThat(response.weekNumber()).isEqualTo(expectedWeekNumber); + + } + + @Then("스터디의 현재 주차가 1에서 변경되지 않았다.") + public void 스터디_주차_변경되지_않았다() { + UpcomingRoundResponse response = sharedContext.getResponse() + .as(MembersCertificationResponse.class) + .upcomingRound(); - assertAll( -// () -> assertThat(studyDetailResponse.currentRound()).isEqualTo(expectedWeekNumber), - () -> assertThat(studyDetailResponse.processingStatus()).isEqualTo(ProcessingStatus.PROCESSING.getCode()) - ); + assertThat(response.weekNumber()).isEqualTo(1); } @Then("스터디가 종료되어 있다.") diff --git a/backend/src/test/java/com/yigongil/backend/acceptance/steps/StudySteps.java b/backend/src/test/java/com/yigongil/backend/acceptance/steps/StudySteps.java index 711899569..7a234ffcf 100644 --- a/backend/src/test/java/com/yigongil/backend/acceptance/steps/StudySteps.java +++ b/backend/src/test/java/com/yigongil/backend/acceptance/steps/StudySteps.java @@ -22,6 +22,8 @@ import io.cucumber.java.en.When; import io.restassured.response.ExtractableResponse; import io.restassured.response.Response; +import java.time.DayOfWeek; +import java.time.LocalDate; import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -221,8 +223,24 @@ public StudySteps(ObjectMapper objectMapper, SharedContext sharedContext) { .when() .patch("/studies/" + studyId + "/start") .then().log().all(); + } + + @Given("{string}가 이름이 {string}인 스터디를 내일에 해당하는 요일에 진행되도록 하여 시작한다.") + public void 스터디_시작_내일에_해당하는_요일(String memberGithubId, String studyName) { + String token = sharedContext.getToken(memberGithubId); + String studyId = (String) sharedContext.getParameter(studyName); + + LocalDate tomorrow = LocalDate.now().plusDays(1); + DayOfWeek dayOfWeek = tomorrow.getDayOfWeek(); + StudyStartRequest request = new StudyStartRequest(List.of(dayOfWeek.name())); - sharedContext.setParameter("currentRoundNumber", 1); + given().log().all() + .header(HttpHeaders.AUTHORIZATION, token) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(request) + .when() + .patch("/studies/" + studyId + "/start") + .then().log().all(); } @When("{string}가 홈화면을 조회한다.") diff --git a/backend/src/test/resources/features/study-progress.feature b/backend/src/test/resources/features/study-progress.feature index 060ecbb9e..292d8f24a 100644 --- a/backend/src/test/resources/features/study-progress.feature +++ b/backend/src/test/resources/features/study-progress.feature @@ -21,7 +21,37 @@ Feature: 스터디를 진행한다 Given "jinwoo"가 "noiman"의 "자바1" 스터디 신청을 수락한다. Given "jinwoo"가 이름이 "자바1"인 스터디를 "MONDAY"에 진행되도록 하여 시작한다. Given 7일이 지난다. - When "jinwoo"가 "자바1" 스터디를 조회한다. + When "jinwoo"가 "자바1" 스터디의 인증 목록을 조회한다. + Then 스터디의 현재 주차가 2로 변경되어 있다. + + Scenario: N요일에 진행되는 라운드는 N+1일에 라운드가 업데이트된다. + Given "jinwoo"의 깃허브 아이디로 회원가입을 한다. + Given "jinwoo"가 제목-"자바1", 정원-"6"명, 최소 주차-"7"주, 주당 진행 횟수-"3"회, 소개-"스터디소개1"로 스터디를 개설한다. + + Given "noiman"의 깃허브 아이디로 회원가입을 한다. + Given 깃허브 아이디가 "noiman"인 멤버가 이름이 "자바1"스터디에 신청한다. + Given "jinwoo"가 "noiman"의 "자바1" 스터디 신청을 수락한다. + + Given "jinwoo"가 이름이 "자바1"인 스터디를 내일에 해당하는 요일에 진행되도록 하여 시작한다. + When 1일이 지난다. + When "jinwoo"가 "자바1" 스터디의 인증 목록을 조회한다. + Then 스터디의 현재 주차가 1에서 변경되지 않았다. + + Scenario: 일요일에 진행되는 라운드는 다음주 월요일에 라운드가 업데이트된다. + Given "jinwoo"의 깃허브 아이디로 회원가입을 한다. + Given "jinwoo"가 제목-"자바1", 정원-"6"명, 최소 주차-"7"주, 주당 진행 횟수-"3"회, 소개-"스터디소개1"로 스터디를 개설한다. + + Given "noiman"의 깃허브 아이디로 회원가입을 한다. + Given 깃허브 아이디가 "noiman"인 멤버가 이름이 "자바1"스터디에 신청한다. + Given "jinwoo"가 "noiman"의 "자바1" 스터디 신청을 수락한다. + + Given "jinwoo"가 이름이 "자바1"인 스터디를 "SUNDAY"에 진행되도록 하여 시작한다. + When 이번주 일요일이 됐다. + When "jinwoo"가 "자바1" 스터디의 인증 목록을 조회한다. + Then 스터디의 현재 주차가 1에서 변경되지 않았다. + + When 다음주 월요일이 됐다. + When "jinwoo"가 "자바1" 스터디의 인증 목록을 조회한다. Then 스터디의 현재 주차가 2로 변경되어 있다. Scenario: 스터디가 최소 주차를 만족하지 못하면 스터디를 종료할 수 없다. From 1983174ccab6171d27ffaa2c56ad304095c0112a Mon Sep 17 00:00:00 2001 From: kevstevie <109793396+kevstevie@users.noreply.github.com> Date: Thu, 2 Nov 2023 10:29:40 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[BE]=20refactor:=20=EC=9D=B8=EC=A6=9D,=20?= =?UTF-8?q?=ED=94=BC=EB=93=9C=20=EC=B5=9C=EB=8C=80=20=EA=B8=80=EC=9E=90?= =?UTF-8?q?=EC=88=98=20=EC=A6=9D=EA=B0=80=20(#599)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 인증, 피드 최대 글자수 증가 * refactor: 피드 내용 nullable false 적용 --- .../yigongil/backend/domain/certification/Certification.java | 2 ++ .../java/com/yigongil/backend/domain/feedpost/FeedPost.java | 2 ++ .../db/migration/V13__increase_feed_certification_length.sql | 5 +++++ 3 files changed, 9 insertions(+) create mode 100644 backend/src/main/resources/db/migration/V13__increase_feed_certification_length.sql diff --git a/backend/src/main/java/com/yigongil/backend/domain/certification/Certification.java b/backend/src/main/java/com/yigongil/backend/domain/certification/Certification.java index 265097560..32824b93f 100644 --- a/backend/src/main/java/com/yigongil/backend/domain/certification/Certification.java +++ b/backend/src/main/java/com/yigongil/backend/domain/certification/Certification.java @@ -5,6 +5,7 @@ import com.yigongil.backend.domain.round.Round; import com.yigongil.backend.domain.study.Study; import java.time.LocalDateTime; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; @@ -30,6 +31,7 @@ public class Certification extends BaseEntity { @JoinColumn(name = "study_id") private Study study; + @Column(length = 1000) private String content; private String imageUrl; diff --git a/backend/src/main/java/com/yigongil/backend/domain/feedpost/FeedPost.java b/backend/src/main/java/com/yigongil/backend/domain/feedpost/FeedPost.java index 7278718c3..1c2b96324 100644 --- a/backend/src/main/java/com/yigongil/backend/domain/feedpost/FeedPost.java +++ b/backend/src/main/java/com/yigongil/backend/domain/feedpost/FeedPost.java @@ -5,6 +5,7 @@ import com.yigongil.backend.domain.study.Study; import java.time.LocalDateTime; import java.util.Objects; +import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; @@ -30,6 +31,7 @@ public class FeedPost extends BaseEntity { @JoinColumn(name = "study_id") private Study study; + @Column(length = 1000, nullable = false) private String content; private String imageUrl; diff --git a/backend/src/main/resources/db/migration/V13__increase_feed_certification_length.sql b/backend/src/main/resources/db/migration/V13__increase_feed_certification_length.sql new file mode 100644 index 000000000..54caaa09c --- /dev/null +++ b/backend/src/main/resources/db/migration/V13__increase_feed_certification_length.sql @@ -0,0 +1,5 @@ +alter table certification + modify column content varchar(1000) not null; + +alter table feed_post + modify column content varchar(1000) not null;