use of wooteco.prolog.session.domain.Mission in project prolog by woowacourse.
the class StudylogService method updateStudylog.
@Transactional
public void updateStudylog(Long memberId, Long studylogId, StudylogRequest studylogRequest) {
Studylog studylog = studylogRepository.findById(studylogId).orElseThrow(StudylogNotFoundException::new);
studylog.validateBelongTo(memberId);
Session session = sessionService.findSessionById(studylogRequest.getSessionId()).orElse(null);
Mission mission = missionService.findMissionById(studylogRequest.getMissionId()).orElse(null);
final Member foundMember = memberService.findById(memberId);
final Tags originalTags = tagService.findByStudylogsAndMember(studylog, foundMember);
Tags newTags = tagService.findOrCreate(studylogRequest.getTags());
studylog.update(studylogRequest.getTitle(), studylogRequest.getContent(), session, mission, newTags);
memberTagService.updateMemberTag(originalTags, newTags, foundMember);
studylogDocumentService.update(studylog.toStudylogDocument());
}
use of wooteco.prolog.session.domain.Mission in project prolog by woowacourse.
the class StudylogService method insertStudylogTemp.
@Transactional
public StudylogTempResponse insertStudylogTemp(Long memberId, StudylogRequest studylogRequest) {
Member member = memberService.findById(memberId);
Tags tags = tagService.findOrCreate(studylogRequest.getTags());
Mission mission = missionService.findById(studylogRequest.getMissionId());
StudylogTemp requestedStudylogTemp = new StudylogTemp(member, studylogRequest.getTitle(), studylogRequest.getContent(), mission, tags.getList());
deleteStudylogTemp(memberId);
StudylogTemp createdStudylogTemp = studylogTempRepository.save(requestedStudylogTemp);
return StudylogTempResponse.from(createdStudylogTemp);
}
use of wooteco.prolog.session.domain.Mission in project prolog by woowacourse.
the class StudylogTest method getPopularScore.
@DisplayName("좋아요와 조회를 기준으로 인기점수를 반환한다.")
@Test
void getPopularScore() {
// given
Member member = new Member("최현구", "현구막", Role.CREW, 1L, "image");
Session session = new Session("세션 1");
Mission mission = new Mission("자동차 미션", session);
Tag tag1 = new Tag("Java");
Tag tag2 = new Tag("Spring");
Studylog studylog = new Studylog(member, "제목", "내용", mission, Arrays.asList(tag1, tag2));
// when, then
assertThat(studylog.getPopularScore()).isEqualTo(0);
studylog.increaseViewCount();
assertThat(studylog.getPopularScore()).isEqualTo(1);
studylog.like(1L);
assertThat(studylog.getPopularScore()).isEqualTo(3 + 1);
}
use of wooteco.prolog.session.domain.Mission in project prolog by woowacourse.
the class MissionServiceTest method findByIdTest.
@DisplayName("ID를 통해서 Mission을 조회한다.")
@Test
void findByIdTest() {
// given
MissionRequest request = new MissionRequest("세션1 - 자동차 경주 미션", session1.getId());
MissionResponse savedMission = missionService.create(request);
// when
Mission foundMission = missionService.findById(savedMission.getId());
// then
assertThat(foundMission).usingRecursiveComparison().isEqualTo(savedMission);
}
use of wooteco.prolog.session.domain.Mission in project prolog by woowacourse.
the class MissionRepositoryTest method findByName.
@DisplayName("name으로 Mission 검색 - 성공")
@Test
void findByName() {
// given
String name = "[BE] 자동차 미션";
Mission mission = missionRepository.save(new Mission(name, session));
// when
Optional<Mission> foundMission = missionRepository.findByName(name);
// then
assertThat(foundMission).isPresent();
assertThat(foundMission.get()).usingRecursiveComparison().isEqualTo(mission);
}
Aggregations