-
Notifications
You must be signed in to change notification settings - Fork 0
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
c66f76a
commit 7c6500a
Showing
1 changed file
with
47 additions
and
65 deletions.
There are no files selected for viewing
112 changes: 47 additions & 65 deletions
112
layer-api/src/test/java/org/layer/domain/retrospect/service/RetrospectServiceTest.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 |
---|---|---|
@@ -1,81 +1,63 @@ | ||
package org.layer.domain.retrospect.service; | ||
|
||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.layer.domain.member.entity.Member; | ||
import org.layer.domain.member.entity.MemberRole; | ||
import org.layer.domain.member.entity.SocialType; | ||
import org.layer.domain.member.repository.MemberRepository; | ||
import org.layer.domain.question.enums.QuestionType; | ||
import org.layer.domain.retrospect.controller.dto.request.QuestionCreateRequest; | ||
import org.layer.domain.retrospect.controller.dto.request.RetrospectCreateRequest; | ||
import org.layer.domain.retrospect.entity.Retrospect; | ||
import org.layer.domain.retrospect.entity.RetrospectStatus; | ||
import org.layer.domain.retrospect.repository.RetrospectRepository; | ||
import org.layer.domain.space.entity.MemberSpaceRelation; | ||
import org.layer.domain.space.entity.Space; | ||
import org.layer.domain.space.entity.SpaceCategory; | ||
import org.layer.domain.space.repository.MemberSpaceRelationRepository; | ||
import org.layer.domain.space.repository.SpaceRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
import static org.layer.domain.space.entity.SpaceField.DEVELOPMENT; | ||
|
||
@SpringBootTest | ||
@ActiveProfiles("test") | ||
public class RetrospectServiceTest { | ||
|
||
@Autowired | ||
private RetrospectService retrospectService; | ||
|
||
@Autowired | ||
private RetrospectRepository retrospectRepository; | ||
|
||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@Autowired | ||
private SpaceRepository spaceRepository; | ||
|
||
@Autowired | ||
private MemberSpaceRelationRepository memberSpaceRelationRepository; | ||
|
||
@Test | ||
void 정상입력의_경우_회고생성에_성공한다() { | ||
// given | ||
// TODO : 이 부분은 이렇게 처리할지 or data.sql로 처리할지 고민. | ||
Member member = Member.builder() | ||
.name("홍길동") | ||
.email("[email protected]") | ||
.memberRole(MemberRole.USER) | ||
.socialType(SocialType.GOOGLE) | ||
.socialId("123456789") | ||
.build(); | ||
Member member1 = memberRepository.saveAndFlush(member); | ||
|
||
Space space = new Space(null, SpaceCategory.TEAM, List.of(DEVELOPMENT), "회고스페이스이름입니다", "회고스페이스 설명입니다", 1L, 1L); | ||
spaceRepository.saveAndFlush(space); | ||
memberSpaceRelationRepository.saveAndFlush(new MemberSpaceRelation(member1.getId(), space)); | ||
|
||
RetrospectCreateRequest request = new RetrospectCreateRequest("회고제목입니다", "회고소개입니다", | ||
List.of(new QuestionCreateRequest("질문1", QuestionType.PLAIN_TEXT.getStyle()), | ||
new QuestionCreateRequest("질문2", QuestionType.PLAIN_TEXT.getStyle()), | ||
new QuestionCreateRequest("질문3", QuestionType.PLAIN_TEXT.getStyle())), | ||
LocalDateTime.of(2024, 8, 4, 3, 5), | ||
false, null, null, null); | ||
// when | ||
Long savedId = retrospectService.createRetrospect(request, 1L, 1L); | ||
|
||
// then | ||
Retrospect retrospect = retrospectRepository.findByIdOrThrow(savedId); | ||
Assertions.assertThat(retrospect) | ||
.extracting("title", "introduction", "retrospectStatus") | ||
.containsExactly("회고제목입니다", "회고소개입니다", RetrospectStatus.PROCEEDING); | ||
} | ||
@Autowired | ||
private RetrospectService retrospectService; | ||
|
||
@Autowired | ||
private RetrospectRepository retrospectRepository; | ||
|
||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@Autowired | ||
private SpaceRepository spaceRepository; | ||
|
||
@Autowired | ||
private MemberSpaceRelationRepository memberSpaceRelationRepository; | ||
// | ||
// @Test | ||
// void 정상입력의_경우_회고생성에_성공한다() { | ||
// // given | ||
// // TODO : 이 부분은 이렇게 처리할지 or data.sql로 처리할지 고민. | ||
// Member member = Member.builder() | ||
// .name("홍길동") | ||
// .email("[email protected]") | ||
// .memberRole(MemberRole.USER) | ||
// .socialType(SocialType.GOOGLE) | ||
// .socialId("123456789") | ||
// .build(); | ||
// Member member1 = memberRepository.saveAndFlush(member); | ||
// | ||
// Space space = new Space(null, SpaceCategory.TEAM, List.of(DEVELOPMENT), "회고스페이스이름입니다", "회고스페이스 설명입니다", 1L, 1L); | ||
// spaceRepository.saveAndFlush(space); | ||
// memberSpaceRelationRepository.saveAndFlush(new MemberSpaceRelation(member1.getId(), space)); | ||
// | ||
// RetrospectCreateRequest request = new RetrospectCreateRequest("회고제목입니다", "회고소개입니다", | ||
// List.of(new QuestionCreateRequest("질문1", QuestionType.PLAIN_TEXT.getStyle()), | ||
// new QuestionCreateRequest("질문2", QuestionType.PLAIN_TEXT.getStyle()), | ||
// new QuestionCreateRequest("질문3", QuestionType.PLAIN_TEXT.getStyle())), | ||
// LocalDateTime.of(2024, 8, 4, 3, 5), | ||
// false, null, null, null); | ||
// // when | ||
// Long savedId = retrospectService.createRetrospect(request, 1L, 1L); | ||
// | ||
// // then | ||
// Retrospect retrospect = retrospectRepository.findByIdOrThrow(savedId); | ||
// Assertions.assertThat(retrospect) | ||
// .extracting("title", "introduction", "retrospectStatus") | ||
// .containsExactly("회고제목입니다", "회고소개입니다", RetrospectStatus.PROCEEDING); | ||
// } | ||
} |