diff --git a/src/main/java/dev/steady/global/config/QueryDslConfig.java b/src/main/java/dev/steady/global/config/QueryDslConfig.java index e911f84..fd5502e 100644 --- a/src/main/java/dev/steady/global/config/QueryDslConfig.java +++ b/src/main/java/dev/steady/global/config/QueryDslConfig.java @@ -2,8 +2,6 @@ import com.querydsl.jpa.JPQLTemplates; import com.querydsl.jpa.impl.JPAQueryFactory; -import com.querydsl.sql.MySQLTemplates; -import com.querydsl.sql.SQLTemplates; import jakarta.persistence.EntityManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/src/test/java/dev/steady/steady/controller/SteadyControllerTest.java b/src/test/java/dev/steady/steady/controller/SteadyControllerTest.java index 42f1a6b..09a3c35 100644 --- a/src/test/java/dev/steady/steady/controller/SteadyControllerTest.java +++ b/src/test/java/dev/steady/steady/controller/SteadyControllerTest.java @@ -35,6 +35,8 @@ import static dev.steady.steady.fixture.SteadyFixtures.createSteadyRequest; import static dev.steady.steady.fixture.SteadyFixtures.createSteadyUpdateRequest; import static dev.steady.user.fixture.UserFixtures.createPosition; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.willDoNothing; import static org.springframework.http.HttpHeaders.AUTHORIZATION; @@ -153,35 +155,38 @@ void findMySteadiesTest() throws Exception { @DisplayName("검색 조건에 따른 전체 조회 결과를 반환한다.") void getSteadiesByConditionTest() throws Exception { // given - var searchRequest = new SteadySearchRequest(null, - 0, - "desc", + var searchRequest = new SteadySearchRequest( + null, + null, + null, + null, + null, + null, + null, + null, null, - "online", - "Java", - "Backend", - "recruiting", "false", - ""); + null); + MultiValueMap params = new LinkedMultiValueMap<>() {{ - add("steadyType", null); - add("page", "0"); - add("direction", "desc"); + add("page", null); + add("direction", null); add("criteria", null); - add("steadyMode", "online"); - add("stack", "Java"); - add("position", "Backend"); - add("status", "recruiting"); + add("cursor", null); + add("steadyType", null); + add("steadyMode", null); + add("stack", null); + add("position", null); + add("status", null); add("like", "false"); - add("keyword", ""); + add("keyword", null); }}; var pageable = searchRequest.toPageable(); - var condition = FilterConditionDto.from(searchRequest); var steady = createSteady(); var response = createSteadyPageResponse(steady, pageable); - given(steadyService.getSteadies(new UserInfo(null), condition, pageable)).willReturn(response); + given(steadyService.getSteadies(eq(new UserInfo(null)), any(FilterConditionDto.class), eq(pageable))).willReturn(response); // when & then mockMvc.perform(get("/api/v1/steadies/search") @@ -190,10 +195,11 @@ void getSteadiesByConditionTest() throws Exception { resourceDetails().tag("스테디").description("스테디 검색 및 필터링 조회") .responseSchema(Schema.schema("PageResponse")), queryParameters( - parameterWithName("steadyType").description("스테디 타입").optional(), parameterWithName("page").description("요청 페이지 번호"), parameterWithName("direction").description("내림/오름차순").optional(), parameterWithName("criteria").description("정렬 조건").optional(), + parameterWithName("cursor").description("페이징 커서").optional(), + parameterWithName("steadyType").description("스테디 타입").optional(), parameterWithName("steadyMode").description("스테디 진행 방식").optional(), parameterWithName("stack").description("스테디 기술 스택").optional(), parameterWithName("position").description("스테디 포지션").optional(), @@ -210,6 +216,7 @@ void getSteadiesByConditionTest() throws Exception { fieldWithPath("content[].status").type(STRING).description("스테디 상태"), fieldWithPath("content[].deadline").type(STRING).description("모집 마감일"), fieldWithPath("content[].createdAt").type(STRING).description("스테디 생성일"), + fieldWithPath("content[].promotedAt").type(STRING).description("스테디 끌어올린 시간"), fieldWithPath("content[].participantLimit").type(NUMBER).description("모집 정원"), fieldWithPath("content[].numberOfParticipants").type(NUMBER).description("스테디 참여 인원"), fieldWithPath("content[].viewCount").type(NUMBER).description("조회수"), diff --git a/src/test/java/dev/steady/steady/fixture/SteadyFixtures.java b/src/test/java/dev/steady/steady/fixture/SteadyFixtures.java index 04d1521..5640c31 100644 --- a/src/test/java/dev/steady/steady/fixture/SteadyFixtures.java +++ b/src/test/java/dev/steady/steady/fixture/SteadyFixtures.java @@ -15,9 +15,9 @@ import dev.steady.steady.dto.response.PageResponse; import dev.steady.steady.dto.response.ParticipantResponse; import dev.steady.steady.dto.response.ParticipantsResponse; +import dev.steady.steady.dto.response.SteadyQueryResponse; import dev.steady.steady.dto.response.SteadyQuestionResponse; import dev.steady.steady.dto.response.SteadyQuestionsResponse; -import dev.steady.steady.dto.response.SteadySearchResponse; import dev.steady.user.domain.Position; import dev.steady.user.domain.Stack; import dev.steady.user.domain.User; @@ -154,9 +154,9 @@ public static Steady createSteady(User user, List stacks, SteadyStatus st return steady; } - public static PageResponse createSteadyPageResponse(Steady steady, Pageable pageable) { + public static PageResponse createSteadyPageResponse(Steady steady, Pageable pageable) { Page steadies = new PageImpl<>(List.of(steady), pageable, 1); - return PageResponse.from(steadies.map(v -> SteadySearchResponse.from(v, 0))); + return PageResponse.from(steadies.map(SteadyQueryResponse::from)); } public static ParticipantsResponse createParticipantsResponse() { diff --git a/src/test/java/dev/steady/steady/infrastructure/SteadySearchRepositoryImplTest.java b/src/test/java/dev/steady/steady/infrastructure/SteadySearchRepositoryImplTest.java index c52632f..5fbd750 100644 --- a/src/test/java/dev/steady/steady/infrastructure/SteadySearchRepositoryImplTest.java +++ b/src/test/java/dev/steady/steady/infrastructure/SteadySearchRepositoryImplTest.java @@ -85,10 +85,12 @@ void findAllByConditionTest() { entityManager.clear(); // when - var request = new SteadySearchRequest("study", - 0, + var request = new SteadySearchRequest( + null, "DESC", null, + null, + "study", "online", "Java", "백엔드", @@ -98,7 +100,7 @@ void findAllByConditionTest() { var pageable = request.toPageable(); var condition = FilterConditionDto.from(request); - var response = queryDslRepository.findAllBySearchCondition(null, condition, pageable); + var response = queryDslRepository.findAllByFilterCondition(null, condition, pageable); var returnedSteady = response.getContent().get(0); // then @@ -126,10 +128,12 @@ void findAllByConditionNotInTest() { entityManager.clear(); // when - var request = new SteadySearchRequest("study", - 0, - "DESC", + var request = new SteadySearchRequest( + null, + null, + null, null, + "study", "both", "Java", "데브옵스", @@ -139,7 +143,7 @@ void findAllByConditionNotInTest() { var pageable = request.toPageable(); var condition = FilterConditionDto.from(request); - var response = queryDslRepository.findAllBySearchCondition(null, condition, pageable); + var response = queryDslRepository.findAllByFilterCondition(null, condition, pageable); // then assertThat(response.getTotalElements()).isZero(); @@ -162,9 +166,11 @@ void findAllByBasicConditionTest() { entityManager.clear(); // when - var request = new SteadySearchRequest("study", - 0, - "DESC", + var request = new SteadySearchRequest( + null, + null, + null, + null, null, null, null, @@ -174,7 +180,7 @@ void findAllByBasicConditionTest() { null); var pageable = request.toPageable(); var condition = FilterConditionDto.from(request); - var response = queryDslRepository.findAllBySearchCondition(null, condition, pageable); + var response = queryDslRepository.findAllByFilterCondition(null, condition, pageable); // then int expectedSize = 1; diff --git a/src/test/java/dev/steady/steady/service/SteadyServiceTest.java b/src/test/java/dev/steady/steady/service/SteadyServiceTest.java index ad9d22f..ff7ce75 100644 --- a/src/test/java/dev/steady/steady/service/SteadyServiceTest.java +++ b/src/test/java/dev/steady/steady/service/SteadyServiceTest.java @@ -25,8 +25,8 @@ import dev.steady.steady.dto.response.PageResponse; import dev.steady.steady.dto.response.ParticipantsResponse; import dev.steady.steady.dto.response.SteadyDetailResponse; +import dev.steady.steady.dto.response.SteadyQueryResponse; import dev.steady.steady.dto.response.SteadyQuestionsResponse; -import dev.steady.steady.dto.response.SteadySearchResponse; import dev.steady.user.domain.User; import dev.steady.user.domain.repository.PositionRepository; import dev.steady.user.domain.repository.StackRepository; @@ -146,7 +146,8 @@ void getSteadiesSearchTest() { // when SteadySearchRequest searchRequest = new SteadySearchRequest(null, - 0, + null, + null, null, null, null, @@ -157,14 +158,14 @@ void getSteadiesSearchTest() { null); FilterConditionDto condition = FilterConditionDto.from(searchRequest); Pageable pageable = searchRequest.toPageable(); - PageResponse response = steadyService.getSteadies(userInfo, condition, pageable); + PageResponse response = steadyService.getSteadies(userInfo, condition, pageable); // then List steadies = steadyRepository.findAll(); - List content = response.content(); + List content = response.content(); assertAll( () -> assertThat(content).hasSameSizeAs(steadies), - () -> assertThat(content.get(0).createdAt()).isAfter(content.get(1).createdAt()) + () -> assertThat(content.get(0).promotedAt()).isAfter(content.get(1).promotedAt()) ); } @@ -185,23 +186,25 @@ void getSteadiesSearchOrderByDeadlineTest() { entityManager.clear(); // when - SteadySearchRequest searchRequest = new SteadySearchRequest(null, - 0, + SteadySearchRequest searchRequest = new SteadySearchRequest( + null, "asc", "deadline", null, null, null, null, + null, + null, "false", null); FilterConditionDto condition = FilterConditionDto.from(searchRequest); Pageable pageable = searchRequest.toPageable(); - PageResponse response = steadyService.getSteadies(userInfo, condition, pageable); + PageResponse response = steadyService.getSteadies(userInfo, condition, pageable); // then List steadies = steadyRepository.findAll(); - List content = response.content(); + List content = response.content(); assertAll( () -> assertThat(content).hasSameSizeAs(steadies), () -> assertThat(content.get(0).deadline()).isBefore(content.get(1).deadline())