Search in sources :

Example 11 with Studylog

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);
}
Also used : List(java.util.List) ReportStudylog(wooteco.prolog.report.domain.ReportStudylog) Getter(lombok.Getter) StudylogResponse(wooteco.prolog.studylog.application.dto.StudylogResponse) Studylog(wooteco.prolog.studylog.domain.Studylog) AllArgsConstructor(lombok.AllArgsConstructor) Collectors(java.util.stream.Collectors) StudylogResponse(wooteco.prolog.studylog.application.dto.StudylogResponse)

Example 12 with Studylog

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);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) MissionResponse(wooteco.prolog.session.application.dto.MissionResponse) StudylogRssFeedResponse(wooteco.prolog.studylog.application.dto.StudylogRssFeedResponse) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) StudylogService(wooteco.prolog.studylog.application.StudylogService) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) DocumentService(wooteco.prolog.studylog.application.DocumentService) MissionService(wooteco.prolog.session.application.MissionService) Assertions.assertAll(org.junit.jupiter.api.Assertions.assertAll) Pageable(org.springframework.data.domain.Pageable) StudylogRequest(wooteco.prolog.studylog.application.dto.StudylogRequest) TagRequest(wooteco.prolog.studylog.application.dto.TagRequest) MethodSource(org.junit.jupiter.params.provider.MethodSource) SessionResponse(wooteco.prolog.session.application.dto.SessionResponse) StudylogResponse(wooteco.prolog.studylog.application.dto.StudylogResponse) Collections.emptyList(java.util.Collections.emptyList) StudylogDocumentNotFoundException(wooteco.prolog.studylog.exception.StudylogDocumentNotFoundException) Session(wooteco.prolog.session.domain.Session) PageRequest(org.springframework.data.domain.PageRequest) Tag(wooteco.prolog.studylog.domain.Tag) Member(wooteco.prolog.member.domain.Member) StudylogsSearchRequest(wooteco.prolog.studylog.application.dto.search.StudylogsSearchRequest) Arguments(org.junit.jupiter.params.provider.Arguments) GithubProfileResponse(wooteco.prolog.login.application.dto.GithubProfileResponse) Test(org.junit.jupiter.api.Test) MemberResponse(wooteco.prolog.member.application.dto.MemberResponse) List(java.util.List) Stream(java.util.stream.Stream) StudylogsResponse(wooteco.prolog.studylog.application.dto.StudylogsResponse) LocalDate(java.time.LocalDate) SessionService(wooteco.prolog.session.application.SessionService) MissionRequest(wooteco.prolog.session.application.dto.MissionRequest) StudylogDocument(wooteco.prolog.studylog.domain.StudylogDocument) Studylog(wooteco.prolog.studylog.domain.Studylog) IntStream(java.util.stream.IntStream) CalendarStudylogResponse(wooteco.prolog.studylog.application.dto.CalendarStudylogResponse) ArrayList(java.util.ArrayList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) LoginMember(wooteco.prolog.login.ui.LoginMember) SessionRequest(wooteco.prolog.session.application.dto.SessionRequest) Authority(wooteco.prolog.login.ui.LoginMember.Authority) MemberService(wooteco.prolog.member.application.MemberService) Mission(wooteco.prolog.session.domain.Mission) TagResponse(wooteco.prolog.studylog.application.dto.TagResponse) DisplayName(org.junit.jupiter.api.DisplayName) Collectors.toList(java.util.stream.Collectors.toList) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) IntegrationTest(wooteco.support.utils.IntegrationTest) StudylogScrapService(wooteco.prolog.studylog.application.StudylogScrapService) DateTimeFormatter(java.time.format.DateTimeFormatter) Transactional(org.springframework.transaction.annotation.Transactional) StudylogsResponse(wooteco.prolog.studylog.application.dto.StudylogsResponse) Studylog(wooteco.prolog.studylog.domain.Studylog) DisplayName(org.junit.jupiter.api.DisplayName) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 13 with Studylog

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);
}
Also used : LocalDateTime(java.time.LocalDateTime) Studylog(wooteco.prolog.studylog.domain.Studylog) RepositoryTest(wooteco.support.utils.RepositoryTest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 14 with 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()));
}
Also used : Mission(wooteco.prolog.session.domain.Mission) Studylog(wooteco.prolog.studylog.domain.Studylog) Session(wooteco.prolog.session.domain.Session) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with Studylog

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);
}
Also used : Mission(wooteco.prolog.session.domain.Mission) Tag(wooteco.prolog.studylog.domain.Tag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) Member(wooteco.prolog.member.domain.Member) Studylog(wooteco.prolog.studylog.domain.Studylog) Session(wooteco.prolog.session.domain.Session) Test(org.junit.jupiter.api.Test) RepositoryTest(wooteco.support.utils.RepositoryTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Studylog (wooteco.prolog.studylog.domain.Studylog)29 Member (wooteco.prolog.member.domain.Member)13 Mission (wooteco.prolog.session.domain.Mission)12 Session (wooteco.prolog.session.domain.Session)12 Transactional (org.springframework.transaction.annotation.Transactional)11 StudylogNotFoundException (wooteco.prolog.studylog.exception.StudylogNotFoundException)9 DisplayName (org.junit.jupiter.api.DisplayName)8 Test (org.junit.jupiter.api.Test)8 LoginMember (wooteco.prolog.login.ui.LoginMember)7 RepositoryTest (wooteco.support.utils.RepositoryTest)6 BeforeEach (org.junit.jupiter.api.BeforeEach)5 StudylogResponse (wooteco.prolog.studylog.application.dto.StudylogResponse)5 Tag (wooteco.prolog.studylog.domain.Tag)5 List (java.util.List)4 Collectors (java.util.stream.Collectors)3 Pageable (org.springframework.data.domain.Pageable)3 StudylogTag (wooteco.prolog.studylog.domain.StudylogTag)3 Tags (wooteco.prolog.studylog.domain.Tags)3 LocalDate (java.time.LocalDate)2 ArrayList (java.util.ArrayList)2