-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98241bc
commit 27409b0
Showing
10 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/com/gdschongik/gdsc/domain/study/application/StudyMentorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.gdschongik.gdsc.domain.study.application; | ||
|
||
import static com.gdschongik.gdsc.global.exception.ErrorCode.*; | ||
|
||
import com.gdschongik.gdsc.domain.study.dao.StudyDetailRepository; | ||
import com.gdschongik.gdsc.domain.study.domain.StudyDetail; | ||
import com.gdschongik.gdsc.global.exception.CustomException; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class StudyMentorService { | ||
|
||
private final StudyDetailRepository studyDetailRepository; | ||
|
||
@Transactional | ||
public void cancelStudyAssignment(Long studyDetailId) { | ||
StudyDetail studyDetail = studyDetailRepository | ||
.findById(studyDetailId) | ||
.orElseThrow(() -> new CustomException(ASSIGNMENT_NOT_FOUND)); | ||
|
||
studyDetail.cancelAssignment(); | ||
|
||
log.info("[StudyMentorService] 과제 휴강 처리: studyDetailId={}", studyDetail.getId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/test/java/com/gdschongik/gdsc/domain/study/application/StudyMentorServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.gdschongik.gdsc.domain.study.application; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import com.gdschongik.gdsc.domain.study.dao.StudyDetailRepository; | ||
import com.gdschongik.gdsc.domain.study.domain.StudyDetail; | ||
import com.gdschongik.gdsc.domain.study.domain.StudyStatus; | ||
import com.gdschongik.gdsc.helper.IntegrationTest; | ||
import java.time.LocalDateTime; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
public class StudyMentorServiceTest extends IntegrationTest { | ||
|
||
@Autowired | ||
private StudyMentorService studyMentorService; | ||
|
||
@Autowired | ||
private StudyDetailRepository studyDetailRepository; | ||
|
||
@Nested | ||
class 스터디_과제_휴강_처리시 { | ||
|
||
@Test | ||
void 성공한다() { | ||
// given | ||
LocalDateTime now = LocalDateTime.now(); | ||
StudyDetail studyDetail = createStudyDetail(now, now.plusDays(7)); | ||
|
||
// when | ||
studyMentorService.cancelStudyAssignment(studyDetail.getId()); | ||
|
||
// then | ||
StudyDetail cancelledStudyDetail = | ||
studyDetailRepository.findById(studyDetail.getId()).get(); | ||
assertThat(cancelledStudyDetail.getAssignment().getStatus()).isEqualTo(StudyStatus.CANCELLED); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyDetailTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.gdschongik.gdsc.domain.study.domain; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import com.gdschongik.gdsc.domain.member.domain.Member; | ||
import com.gdschongik.gdsc.domain.recruitment.domain.vo.Period; | ||
import com.gdschongik.gdsc.helper.FixtureHelper; | ||
import java.time.LocalDateTime; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class StudyDetailTest { | ||
|
||
@Nested | ||
class 과제_휴강_처리시 { | ||
|
||
FixtureHelper fixtureHelper = new FixtureHelper(); | ||
|
||
@Test | ||
void 과제_상태가_휴강이_된다() { | ||
// given | ||
Member mentor = fixtureHelper.createAssociateMember(1L); | ||
LocalDateTime now = LocalDateTime.now(); | ||
StudyDetail studyDetail = fixtureHelper.createStudyDetail( | ||
mentor, | ||
Period.createPeriod(now.plusDays(5), now.plusDays(10)), | ||
Period.createPeriod(now.minusDays(5), now), | ||
now, | ||
now.plusDays(7)); | ||
|
||
// when | ||
studyDetail.cancelAssignment(); | ||
|
||
// then | ||
assertThat(studyDetail.getAssignment().getStatus()).isEqualTo(StudyStatus.CANCELLED); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters