use of wooteco.prolog.studylog.domain.Studylog in project prolog by woowacourse.
the class ReportStudylogResponse method of.
public static ReportStudylogResponse of(Studylog studylog, List<ReportStudylog> reportStudylogs) {
StudylogResponse studylogResponse = StudylogResponse.of(studylog);
List<ReportAbilityResponse> abilityResponses = reportStudylogs.stream().map(it -> ReportAbilityResponse.of(it.getReportAbility())).collect(Collectors.toList());
List<ReportStudylogAbilityResponse> studylogAbilityResponses = reportStudylogs.stream().map(it -> ReportStudylogAbilityResponse.of(it.getStudylogAbility())).collect(Collectors.toList());
return new ReportStudylogResponse(studylogResponse, abilityResponses, studylogAbilityResponses);
}
use of wooteco.prolog.studylog.domain.Studylog in project prolog by woowacourse.
the class StudylogServiceTest method findStudylogsOfPagingTest.
@DisplayName("유저 이름으로 스터디로그를 조회한다 - 페이징")
@ParameterizedTest
@MethodSource("findStudylogsOfPagingTest")
void findStudylogsOfPagingTest(PageRequest pageRequest, int expectedSize) {
List<Studylog> largeStudylogs = IntStream.range(0, 50).mapToObj(it -> studylog1).collect(toList());
insertStudylogs(member1, largeStudylogs);
StudylogsResponse studylogsResponseOfMember1 = studylogService.findStudylogsOf(member1.getUsername(), pageRequest);
assertThat(studylogsResponseOfMember1.getData().size()).isEqualTo(expectedSize);
}
use of wooteco.prolog.studylog.domain.Studylog in project prolog by woowacourse.
the class StudylogRepositoryTest method findByPastDateAndSize.
@DisplayName("주어진 날짜시간 이후의 글 목록을 가져온다.")
@Test
void findByPastDateAndSize() throws InterruptedException {
// given
// 2초간 정지
TimeUnit.SECONDS.sleep(2);
Studylog studylog = studylogRepository.save(new Studylog(member1, "새로운 글", "새로운 글이얌", mission1, asList(tag1, tag2)));
// when
LocalDateTime localDateTime = LocalDateTime.now().minusSeconds(1);
List<Studylog> studylogs = studylogRepository.findByPastDays(localDateTime);
// then
assertThat(studylogs).hasSize(1);
assertThat(studylogs).containsExactly(studylog);
}
use of wooteco.prolog.studylog.domain.Studylog in project prolog by woowacourse.
the class StudylogScrapRepositoryTest method setUp.
@BeforeEach
void setUp() {
member = memberRepository.save(웨지);
Session session = sessionRepository.save(new Session("세션1"));
Mission mission = missionRepository.save(new Mission("미션", session));
studylog = studylogRepository.save(new Studylog(member, "제목", "내용", mission, Lists.emptyList()));
}
use of wooteco.prolog.studylog.domain.Studylog in project prolog by woowacourse.
the class StudylogTagRepositoryTest method findByTagIn.
@DisplayName("Tag 리스트와 매칭되는 StudylogTag 리스트 조회")
@Test
void findByTagIn() {
// given
Member member = memberRepository.save(웨지);
Session session = sessionRepository.save(new Session("세션1"));
Mission mission = missionRepository.save(new Mission("미션", session));
Studylog studylog1 = studylogRepository.save(new Studylog(member, "제목1", "내용1", mission, Lists.emptyList()));
Studylog studylog2 = studylogRepository.save(new Studylog(member, "제목2", "내용2", mission, Lists.emptyList()));
Tag tag1 = tagRepository.save(new Tag("태그1"));
Tag tag2 = tagRepository.save(new Tag("태그2"));
StudylogTag studylogTag1 = studylogTagRepository.save(new StudylogTag(studylog1, tag1));
StudylogTag studylogTag2 = studylogTagRepository.save(new StudylogTag(studylog1, tag2));
StudylogTag studylogTag3 = studylogTagRepository.save(new StudylogTag(studylog2, tag2));
// when
List<StudylogTag> studylogTags = studylogTagRepository.findByTagIn(Arrays.asList(tag1, tag2));
// then
assertThat(studylogTags).usingFieldByFieldElementComparator().containsExactlyInAnyOrder(studylogTag1, studylogTag2, studylogTag3);
}
Aggregations