-
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
Showing
7 changed files
with
170 additions
and
0 deletions.
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
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
14 changes: 14 additions & 0 deletions
14
layer-api/src/test/java/org/layer/LayerApplicationTests.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,14 @@ | ||
package org.layer; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
@SpringBootTest | ||
@ActiveProfiles("test") | ||
public class LayerApplicationTests { | ||
@Test | ||
void init(){ | ||
|
||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package org.layer.domain.retrospect.service; | ||
|
||
import static org.layer.domain.space.entity.SpaceField.*; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
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; | ||
|
||
@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); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
layer-domain/src/test/java/layer/domain/TestConfiguration.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,12 @@ | ||
package layer.domain; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.autoconfigure.domain.EntityScan; | ||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | ||
|
||
@SpringBootApplication(scanBasePackages = {"org.layer"}) | ||
@EnableJpaRepositories(basePackages = "org.layer.domain") | ||
@EntityScan(basePackages = "org.layer.domain") | ||
public class TestConfiguration { | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
layer-domain/src/test/java/layer/domain/retrospect/entity/RetrospectTest.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,23 @@ | ||
package layer.domain.retrospect.entity; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.layer.domain.retrospect.entity.Retrospect; | ||
import org.layer.domain.retrospect.entity.RetrospectStatus; | ||
|
||
public class RetrospectTest { | ||
|
||
@Test | ||
void 진행중인_회고는_진행여부로직에서_예외를_발생시키지_않는다() { | ||
// given | ||
Retrospect retrospect = new Retrospect(1L, "회고제목입니다", "회고소개입니다", RetrospectStatus.PROCEEDING, | ||
LocalDateTime.of(2024, 8, 4, 3, 5)); | ||
|
||
// when | ||
retrospect.isProceedingRetrospect(); | ||
|
||
Assertions.assertThat(retrospect.getRetrospectStatus()).isEqualTo(RetrospectStatus.PROCEEDING); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
layer-domain/src/test/java/layer/domain/retrospect/repository/RetrospectRepositoryTest.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,35 @@ | ||
package layer.domain.retrospect.repository; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.layer.domain.retrospect.entity.Retrospect; | ||
import org.layer.domain.retrospect.entity.RetrospectStatus; | ||
import org.layer.domain.retrospect.repository.RetrospectRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
@ExtendWith(SpringExtension.class) | ||
@DataJpaTest | ||
public class RetrospectRepositoryTest { | ||
@Autowired | ||
private RetrospectRepository retrospectRepository; | ||
|
||
@Test | ||
void 멀티모듈_레포지토리_테스트() { | ||
// given | ||
Retrospect retrospect = new Retrospect(1L, "회고제목입니다", "회고소개입니다", RetrospectStatus.PROCEEDING, | ||
LocalDateTime.of(2024, 8, 4, 3, 5)); | ||
|
||
// when | ||
Retrospect saved = retrospectRepository.save(retrospect); | ||
|
||
// then | ||
Assertions.assertThat(saved) | ||
.extracting("id", "spaceId", "title", "introduction", "retrospectStatus") | ||
.containsExactly(1L, 1L, "회고제목입니다", "회고소개입니다", RetrospectStatus.PROCEEDING); | ||
} | ||
} |