Search in sources :

Example 1 with StudylogsSearchRequest

use of wooteco.prolog.studylog.application.dto.search.StudylogsSearchRequest in project prolog by woowacourse.

the class StudylogServiceTest method findWithFilter.

@DisplayName("검색 및 필터")
@ParameterizedTest
@MethodSource("findWithFilter")
void findWithFilter(String keyword, List<Long> sessionIds, List<Long> missionIds, List<Long> tagIds, List<String> usernames, List<String> expectedStudylogTitles) {
    // given
    insertStudylogs(member1, studylog1, studylog2);
    insertStudylogs(member2, studylog3, studylog4);
    // document 초기화 어떻게...
    StudylogsResponse studylogsResponse = studylogService.findStudylogs(new StudylogsSearchRequest(keyword, sessionIds, missionIds, tagIds, usernames, new ArrayList<>(), LocalDate.parse("19990106", DateTimeFormatter.BASIC_ISO_DATE), LocalDate.parse("99991231", DateTimeFormatter.BASIC_ISO_DATE), null, PageRequest.of(0, 10)), null);
    // then
    List<String> titles = studylogsResponse.getData().stream().map(StudylogResponse::getTitle).collect(toList());
    assertThat(titles).containsExactlyInAnyOrderElementsOf(expectedStudylogTitles);
}
Also used : StudylogsResponse(wooteco.prolog.studylog.application.dto.StudylogsResponse) StudylogsSearchRequest(wooteco.prolog.studylog.application.dto.search.StudylogsSearchRequest) ArrayList(java.util.ArrayList) DisplayName(org.junit.jupiter.api.DisplayName) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with StudylogsSearchRequest

use of wooteco.prolog.studylog.application.dto.search.StudylogsSearchRequest in project prolog by woowacourse.

the class StudylogServiceTest method findStudylogsWithScrapData.

@DisplayName("스크랩한 경우 scrap이 true로 응답된다.")
@ParameterizedTest
@MethodSource("findWithFilter")
void findStudylogsWithScrapData(String keyword, List<Long> sessionIds, List<Long> missionIds, List<Long> tagIds, List<String> usernames, List<String> expectedStudylogTitles) {
    // given
    insertStudylogs(member1, studylog1, studylog2);
    List<StudylogResponse> studylogResponses = insertStudylogs(member2, studylog3, studylog4);
    StudylogResponse studylog3Response = studylogResponses.get(0);
    StudylogResponse studylog4Response = studylogResponses.get(1);
    studylogScrapService.registerScrap(member1.getId(), studylog3Response.getId());
    studylogScrapService.registerScrap(member1.getId(), studylog4Response.getId());
    StudylogsResponse studylogsResponse = studylogService.findStudylogs(new StudylogsSearchRequest(keyword, sessionIds, missionIds, tagIds, usernames, new ArrayList<>(), LocalDate.parse("19990106", DateTimeFormatter.BASIC_ISO_DATE), LocalDate.parse("99991231", DateTimeFormatter.BASIC_ISO_DATE), null, PageRequest.of(0, 10)), member1.getId(), member1.isAnonymous());
    // then
    List<Boolean> scraps = studylogsResponse.getData().stream().filter(studylogResponse -> studylogResponse.getId().equals(studylog3Response.getId()) || studylogResponse.getId().equals(studylog4Response.getId())).map(StudylogResponse::isScrap).collect(toList());
    assertThat(scraps).doesNotContain(false);
}
Also used : StudylogsResponse(wooteco.prolog.studylog.application.dto.StudylogsResponse) StudylogsSearchRequest(wooteco.prolog.studylog.application.dto.search.StudylogsSearchRequest) ArrayList(java.util.ArrayList) StudylogResponse(wooteco.prolog.studylog.application.dto.StudylogResponse) CalendarStudylogResponse(wooteco.prolog.studylog.application.dto.CalendarStudylogResponse) DisplayName(org.junit.jupiter.api.DisplayName) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ArrayList (java.util.ArrayList)2 DisplayName (org.junit.jupiter.api.DisplayName)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 StudylogsResponse (wooteco.prolog.studylog.application.dto.StudylogsResponse)2 StudylogsSearchRequest (wooteco.prolog.studylog.application.dto.search.StudylogsSearchRequest)2 CalendarStudylogResponse (wooteco.prolog.studylog.application.dto.CalendarStudylogResponse)1 StudylogResponse (wooteco.prolog.studylog.application.dto.StudylogResponse)1