Search in sources :

Example 21 with Studylog

use of wooteco.prolog.studylog.domain.Studylog in project prolog by woowacourse.

the class StudylogTagRepositoryTest method createStudylogTag.

@DisplayName("StudylogTag 생성")
@Test
void createStudylogTag() {
    // given
    Member member = memberRepository.save(웨지);
    Session session = sessionRepository.save(new Session("세션1"));
    Mission mission = missionRepository.save(new Mission("미션", session));
    Tag tag = tagRepository.save(new Tag("태그"));
    Studylog studylog = studylogRepository.save(new Studylog(member, "제목", "내용", mission, Lists.emptyList()));
    // when
    StudylogTag studylogTag = new StudylogTag(studylog, tag);
    StudylogTag savedStudylogTag = studylogTagRepository.save(studylogTag);
    // then
    assertThat(savedStudylogTag.getId()).isNotNull();
    assertThat(savedStudylogTag).usingRecursiveComparison().ignoringFields("id", "createdAt", "updatedAt").isEqualTo(studylogTag);
}
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)

Example 22 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)

Example 23 with Studylog

use of wooteco.prolog.studylog.domain.Studylog in project prolog by woowacourse.

the class PopularStudylogServiceTest method setUp.

@BeforeEach
void setUp() {
    SessionResponse sessionResponse1 = sessionService.create(new SessionRequest("세션1"));
    SessionResponse sessionResponse2 = sessionService.create(new SessionRequest("세션2"));
    this.session1 = new Session(sessionResponse1.getId(), sessionResponse1.getName());
    this.session2 = new Session(sessionResponse2.getId(), sessionResponse2.getName());
    MissionResponse missionResponse1 = missionService.create(new MissionRequest("자동차 미션", session1.getId()));
    MissionResponse missionResponse2 = missionService.create(new MissionRequest("수동차 미션", session2.getId()));
    this.mission1 = new Mission(missionResponse1.getId(), missionResponse1.getName(), session1);
    this.mission2 = new Mission(missionResponse2.getId(), missionResponse2.getName(), session1);
    this.member1 = memberService.findOrCreateMember(new GithubProfileResponse("이름1", "별명1", "1", "image"));
    this.member2 = memberService.findOrCreateMember(new GithubProfileResponse("이름2", "별명2", "2", "image"));
    this.loginMember1 = new LoginMember(member1.getId(), Authority.MEMBER);
    this.loginMember2 = new LoginMember(member2.getId(), Authority.MEMBER);
    this.loginMember3 = new LoginMember(null, Authority.ANONYMOUS);
    this.studylog1 = new Studylog(member1, STUDYLOG1_TITLE, "피케이와 포모의 스터디로그", mission1, asList(tag1, tag2));
    this.studylog2 = new Studylog(member1, STUDYLOG2_TITLE, "피케이와 포모의 스터디로그 2", mission1, asList(tag2, tag3));
    this.studylog3 = new Studylog(member2, STUDYLOG3_TITLE, "피케이 스터디로그", mission2, asList(tag3, tag4, tag5));
    this.studylog4 = new Studylog(member2, STUDYLOG4_TITLE, "포모의 스터디로그", mission2, emptyList());
}
Also used : MissionRequest(wooteco.prolog.session.application.dto.MissionRequest) GithubProfileResponse(wooteco.prolog.login.application.dto.GithubProfileResponse) MissionResponse(wooteco.prolog.session.application.dto.MissionResponse) LoginMember(wooteco.prolog.login.ui.LoginMember) Mission(wooteco.prolog.session.domain.Mission) SessionResponse(wooteco.prolog.session.application.dto.SessionResponse) SessionRequest(wooteco.prolog.session.application.dto.SessionRequest) Studylog(wooteco.prolog.studylog.domain.Studylog) Session(wooteco.prolog.session.domain.Session) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 24 with Studylog

use of wooteco.prolog.studylog.domain.Studylog in project prolog by woowacourse.

the class StudylogServiceTest method setUp.

@BeforeEach
void setUp() {
    SessionResponse sessionResponse1 = sessionService.create(new SessionRequest("세션1"));
    SessionResponse sessionResponse2 = sessionService.create(new SessionRequest("세션2"));
    this.session1 = new Session(sessionResponse1.getId(), sessionResponse1.getName());
    this.session2 = new Session(sessionResponse2.getId(), sessionResponse2.getName());
    MissionResponse missionResponse1 = missionService.create(new MissionRequest("자동차 미션", session1.getId()));
    MissionResponse missionResponse2 = missionService.create(new MissionRequest("수동차 미션", session2.getId()));
    this.mission1 = new Mission(missionResponse1.getId(), missionResponse1.getName(), session1);
    this.mission2 = new Mission(missionResponse2.getId(), missionResponse2.getName(), session1);
    this.member1 = memberService.findOrCreateMember(new GithubProfileResponse("이름1", "별명1", "1", "image"));
    this.member2 = memberService.findOrCreateMember(new GithubProfileResponse("이름2", "별명2", "2", "image"));
    this.loginMember1 = new LoginMember(member1.getId(), Authority.MEMBER);
    this.loginMember2 = new LoginMember(member2.getId(), Authority.MEMBER);
    this.loginMember3 = new LoginMember(null, Authority.ANONYMOUS);
    this.studylog1 = new Studylog(member1, STUDYLOG1_TITLE, "피케이와 포모의 스터디로그", session1, mission1, asList(tag1, tag2));
    this.studylog2 = new Studylog(member1, STUDYLOG2_TITLE, "피케이와 포모의 스터디로그 2", session1, mission1, asList(tag2, tag3));
    this.studylog3 = new Studylog(member2, STUDYLOG3_TITLE, "피케이 스터디로그", session1, mission2, asList(tag3, tag4, tag5));
    this.studylog4 = new Studylog(member2, STUDYLOG4_TITLE, "포모의 스터디로그", session1, mission2, emptyList());
}
Also used : MissionRequest(wooteco.prolog.session.application.dto.MissionRequest) GithubProfileResponse(wooteco.prolog.login.application.dto.GithubProfileResponse) MissionResponse(wooteco.prolog.session.application.dto.MissionResponse) LoginMember(wooteco.prolog.login.ui.LoginMember) Mission(wooteco.prolog.session.domain.Mission) SessionResponse(wooteco.prolog.session.application.dto.SessionResponse) SessionRequest(wooteco.prolog.session.application.dto.SessionRequest) Studylog(wooteco.prolog.studylog.domain.Studylog) Session(wooteco.prolog.session.domain.Session) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 25 with Studylog

use of wooteco.prolog.studylog.domain.Studylog in project prolog by woowacourse.

the class StudylogServiceTest method deleteStudylogTest.

@DisplayName("스터디로그를 삭제한다.")
@Test
void deleteStudylogTest() {
    // given
    List<StudylogResponse> studylogs = insertStudylogs(member1, studylog1);
    StudylogResponse studylog = studylogs.get(0);
    // when
    studylogService.deleteStudylog(member1.getId(), studylog.getId());
    // then
    Studylog deletedStudylog = studylogService.findStudylogById(studylog.getId());
    assertThat(deletedStudylog.isDeleted()).isTrue();
}
Also used : StudylogResponse(wooteco.prolog.studylog.application.dto.StudylogResponse) CalendarStudylogResponse(wooteco.prolog.studylog.application.dto.CalendarStudylogResponse) Studylog(wooteco.prolog.studylog.domain.Studylog) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) IntegrationTest(wooteco.support.utils.IntegrationTest) 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