Skip to content

Commit

Permalink
[Test] : 내가 신청한 스터디 목록 조회 기능 통합 테스트 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
elyudwo committed Feb 12, 2024
1 parent 3efe514 commit c1da7f0
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package kr.co.studyhubinu.studyhubserver.apply.dto.data;

import kr.co.studyhubinu.studyhubserver.apply.enums.Inspection;
import lombok.Getter;

@Getter
public class RequestApplyData {

private final Long studyId;
private final String studyTitle;
private final Inspection inspection;
private final String introduce;

public RequestApplyData(Long studyId, String studyTitle, Inspection inspection, String introduce) {
this.studyId = studyId;
this.studyTitle = studyTitle;
this.inspection = inspection;
this.introduce = introduce;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package kr.co.studyhubinu.studyhubserver.apply.dto.response;

import kr.co.studyhubinu.studyhubserver.apply.dto.data.ParticipateApplyData;
import kr.co.studyhubinu.studyhubserver.apply.dto.data.RequestApplyData;
import lombok.Getter;
import org.springframework.data.domain.Slice;

@Getter
public class FindMyRequestApplyResponse {

private Long totalCount;
Slice<RequestApplyData> requestStudyData;

public FindMyRequestApplyResponse(Long totalCount, Slice<RequestApplyData> requestStudyData) {
this.totalCount = totalCount;
this.requestStudyData = requestStudyData;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package kr.co.studyhubinu.studyhubserver.apply.service;

import kr.co.studyhubinu.studyhubserver.apply.domain.ApplyEntity;
import kr.co.studyhubinu.studyhubserver.apply.dto.data.RequestApplyData;
import kr.co.studyhubinu.studyhubserver.apply.dto.response.FindMyRequestApplyResponse;
import kr.co.studyhubinu.studyhubserver.apply.enums.Inspection;
import kr.co.studyhubinu.studyhubserver.apply.repository.ApplyRepository;
import kr.co.studyhubinu.studyhubserver.study.domain.StudyEntity;
import kr.co.studyhubinu.studyhubserver.study.repository.StudyRepository;
import kr.co.studyhubinu.studyhubserver.support.fixture.StudyEntityFixture;
import kr.co.studyhubinu.studyhubserver.support.fixture.UserEntityFixture;
import kr.co.studyhubinu.studyhubserver.user.domain.UserEntity;
import kr.co.studyhubinu.studyhubserver.user.dto.data.UserId;
import kr.co.studyhubinu.studyhubserver.user.repository.UserRepository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;


import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest
public class ApplyServiceIntegrationTest {

@Autowired
ApplyService applyService;

@Autowired
UserRepository userRepository;

@Autowired
ApplyRepository applyRepository;

@Autowired
StudyRepository studyRepository;

@Test
void 내가_신청한_스터디목록_조회() {
UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성();
StudyEntity study = studyRepository.save(StudyEntityFixture.INU.studyEntity_생성());
userRepository.save(user);
applyRepository.save(ApplyEntity.builder()
.userId(user.getId()).introduce("안녕")
.studyId(study.getId())
.inspection(Inspection.ACCEPT)
.build());


FindMyRequestApplyResponse applyResponse = applyService.getMyRequestApply(new UserId(user.getId()), 0, 3);
RequestApplyData applyData = applyResponse.getRequestStudyData().getContent().get(0);

assertThat(applyData.getInspection()).isEqualTo(Inspection.ACCEPT);
assertThat(applyData.getIntroduce()).isEqualTo("안녕");

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public enum StudyEntityFixture {

INU("인천대학교 스터디", "반가워요 잘해봐요", LocalDate.of(2024, 1, 3), LocalDate.of(2024, 1, 5), "asdadsa", 1L, MajorType.COMPUTER_SCIENCE_ENGINEERING);
INU("인천대학교 스터디", "반가워요 잘해봐요", LocalDate.of(2025, 1, 3), LocalDate.of(2025, 1, 5), "asdadsa", 1L, MajorType.COMPUTER_SCIENCE_ENGINEERING);

private String title;
private String content;
Expand Down

0 comments on commit c1da7f0

Please sign in to comment.