Skip to content

Commit

Permalink
Merge pull request #94 from study-hub-inu/refactor/SH-332-apply
Browse files Browse the repository at this point in the history
Refactor/sh 332 apply
  • Loading branch information
elyudwo authored Feb 18, 2024
2 parents edc3e93 + 7a75310 commit 8046cbf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public List<RequestApplyData> findApplyByUserId(Long userId, Pageable pageable)
.from(applyEntity)
.innerJoin(studyEntity).on(applyEntity.studyId.eq(studyEntity.id))
.innerJoin(studyPostEntity).on(studyPostEntity.studyId.eq(studyEntity.id))
.where(applyEntity.userId.eq(userId))
.where(applyEntity.userId.eq(userId), applyEntity.inspection.in(Inspection.STANDBY, Inspection.REJECT))
.orderBy(applyEntity.createdDate.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize() + 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import kr.co.studyhubinu.studyhubserver.apply.domain.ApplyEntity;
import kr.co.studyhubinu.studyhubserver.apply.dto.data.ApplyUserData;
import kr.co.studyhubinu.studyhubserver.apply.dto.data.RequestApplyData;
import kr.co.studyhubinu.studyhubserver.apply.dto.request.UpdateApplyRequest;
import kr.co.studyhubinu.studyhubserver.apply.enums.Inspection;
import kr.co.studyhubinu.studyhubserver.exception.apply.ApplyNotFoundException;
import kr.co.studyhubinu.studyhubserver.study.repository.StudyRepository;
import kr.co.studyhubinu.studyhubserver.study.domain.StudyEntity;
import kr.co.studyhubinu.studyhubserver.studypost.domain.StudyPostEntity;
import kr.co.studyhubinu.studyhubserver.studypost.repository.StudyPostRepository;
import kr.co.studyhubinu.studyhubserver.support.fixture.StudyEntityFixture;
import kr.co.studyhubinu.studyhubserver.support.fixture.UserEntityFixture;
import kr.co.studyhubinu.studyhubserver.support.repository.RepositoryTest;
Expand All @@ -26,6 +29,7 @@
import java.util.Optional;

import static kr.co.studyhubinu.studyhubserver.apply.enums.Inspection.ACCEPT;
import static kr.co.studyhubinu.studyhubserver.apply.enums.Inspection.REJECT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -43,6 +47,9 @@ class ApplyRepositoryTest {
@Autowired
UserRepository userRepository;

@Autowired
StudyPostRepository studyPostRepository;

@PersistenceContext
private EntityManager entityManager;

Expand Down Expand Up @@ -168,4 +175,25 @@ class ApplyRepositoryTest {
// then
assertThat(apply).isEmpty();
}

@Test
void 내가_신청한_스터디_조회_시_Apply된_스터디를_제외하고_조회() {
UserEntity userEntity = userRepository.save(UserEntityFixture.DONGWOO.UserEntity_생성());
StudyEntity studyEntity = studyRepository.save(StudyEntityFixture.INU.studyEntity_생성());
StudyPostEntity studyPostEntity = StudyPostEntity.builder()
.studyId(studyEntity.getId())
.postedUserId(userEntity.getId())
.build();
studyPostRepository.save(studyPostEntity);

ApplyEntity apply = ApplyEntity.builder()
.userId(userEntity.getId())
.studyId(studyEntity.getId())
.inspection(ACCEPT)
.build();
applyRepository.save(apply);

List<RequestApplyData> applyData = applyRepository.findApplyByUserId(userEntity.getId(), PageRequest.of(0,3));
assertThat(applyData.size()).isEqualTo(0);
}
}

0 comments on commit 8046cbf

Please sign in to comment.