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);
}
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);
}
Aggregations