Skip to content

Commit

Permalink
Merge branch 'BE/develop' into BE/fix/547
Browse files Browse the repository at this point in the history
  • Loading branch information
CFalws authored Nov 2, 2023
2 parents a12b4a0 + 1983174 commit 6fc5fe1
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public void proceedRound(LocalDate today) {
List<Study> studies = studyRepository.findAllByProcessingStatus(ProcessingStatus.PROCESSING);

studies.stream()
.filter(study -> study.isCurrentRoundEndAt(today))
.filter(study -> study.isCurrentRoundEndAt(today.minusDays(1)))
.forEach(Study::updateToNextRound);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DayOfWeek> daysOfTheWeek, LocalDateTime startAt) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.as;
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.MyProfileResponse;
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;

Expand All @@ -34,6 +39,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);
Expand All @@ -54,12 +87,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("μŠ€ν„°λ””κ°€ μ’…λ£Œλ˜μ–΄ μžˆλ‹€.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}κ°€ ν™ˆν™”λ©΄μ„ μ‘°νšŒν•œλ‹€.")
Expand Down
32 changes: 31 additions & 1 deletion backend/src/test/resources/features/study-progress.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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: μŠ€ν„°λ””κ°€ μ΅œμ†Œ μ£Όμ°¨λ₯Ό λ§Œμ‘±ν•˜μ§€ λͺ»ν•˜λ©΄ μŠ€ν„°λ””λ₯Ό μ’…λ£Œν•  수 μ—†λ‹€.
Expand Down

0 comments on commit 6fc5fe1

Please sign in to comment.