Search in sources :

Example 6 with Mission

use of wooteco.prolog.session.domain.Mission 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 7 with Mission

use of wooteco.prolog.session.domain.Mission 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 8 with Mission

use of wooteco.prolog.session.domain.Mission in project prolog by woowacourse.

the class StudylogService method insertStudylog.

@Transactional
public StudylogResponse insertStudylog(Long memberId, StudylogRequest studylogRequest) {
    Member member = memberService.findById(memberId);
    Tags tags = tagService.findOrCreate(studylogRequest.getTags());
    Session session = sessionService.findSessionById(studylogRequest.getSessionId()).orElse(null);
    Mission mission = missionService.findMissionById(studylogRequest.getMissionId()).orElse(null);
    Studylog persistStudylog = studylogRepository.save(new Studylog(member, studylogRequest.getTitle(), studylogRequest.getContent(), session, mission, tags.getList()));
    onStudylogCreatedEvent(member, tags, persistStudylog);
    deleteStudylogTemp(memberId);
    return StudylogResponse.of(persistStudylog);
}
Also used : Mission(wooteco.prolog.session.domain.Mission) LoginMember(wooteco.prolog.login.ui.LoginMember) Member(wooteco.prolog.member.domain.Member) Tags(wooteco.prolog.studylog.domain.Tags) Studylog(wooteco.prolog.studylog.domain.Studylog) Session(wooteco.prolog.session.domain.Session) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with Mission

use of wooteco.prolog.session.domain.Mission in project prolog by woowacourse.

the class StudylogService method updateStudylogMission.

@Transactional
public void updateStudylogMission(Long memberId, Long studylogId, StudylogMissionRequest studylogMissionRequest) {
    Studylog studylog = studylogRepository.findById(studylogId).orElseThrow(StudylogNotFoundException::new);
    studylog.validateBelongTo(memberId);
    Mission mission = missionService.findMissionById(studylogMissionRequest.getMissionId()).orElse(null);
    studylog.updateMission(mission);
}
Also used : StudylogNotFoundException(wooteco.prolog.studylog.exception.StudylogNotFoundException) Mission(wooteco.prolog.session.domain.Mission) Studylog(wooteco.prolog.studylog.domain.Studylog) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with Mission

use of wooteco.prolog.session.domain.Mission in project prolog by woowacourse.

the class MissionService method create.

@Transactional
public MissionResponse create(MissionRequest missionRequest) {
    validateName(missionRequest.getName());
    Session session = sessionService.findById(missionRequest.getSessionId());
    return MissionResponse.of(missionRepository.save(new Mission(missionRequest.getName(), session)));
}
Also used : Mission(wooteco.prolog.session.domain.Mission) Session(wooteco.prolog.session.domain.Session) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Mission (wooteco.prolog.session.domain.Mission)18 Session (wooteco.prolog.session.domain.Session)12 Studylog (wooteco.prolog.studylog.domain.Studylog)11 DisplayName (org.junit.jupiter.api.DisplayName)9 Test (org.junit.jupiter.api.Test)9 Member (wooteco.prolog.member.domain.Member)8 RepositoryTest (wooteco.support.utils.RepositoryTest)6 Transactional (org.springframework.transaction.annotation.Transactional)5 LoginMember (wooteco.prolog.login.ui.LoginMember)5 BeforeEach (org.junit.jupiter.api.BeforeEach)4 MissionRequest (wooteco.prolog.session.application.dto.MissionRequest)4 MissionResponse (wooteco.prolog.session.application.dto.MissionResponse)4 StudylogTag (wooteco.prolog.studylog.domain.StudylogTag)4 Tag (wooteco.prolog.studylog.domain.Tag)4 Tags (wooteco.prolog.studylog.domain.Tags)3 GithubProfileResponse (wooteco.prolog.login.application.dto.GithubProfileResponse)2 SessionRequest (wooteco.prolog.session.application.dto.SessionRequest)2 SessionResponse (wooteco.prolog.session.application.dto.SessionResponse)2 StudylogNotFoundException (wooteco.prolog.studylog.exception.StudylogNotFoundException)2 IntegrationTest (wooteco.support.utils.IntegrationTest)2