Search in sources :

Example 26 with Studylog

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

the class StudylogReadRepositoryTest method setUp.

@BeforeEach
void setUp() {
    member = memberRepository.save(웨지);
    bada = 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 27 with Studylog

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

the class StudylogRepositoryTest method findTop50OrderByCreatedAtDesc.

@DisplayName("스터디로그 중 최신 50개만 조회한다.")
@Test
void findTop50OrderByCreatedAtDesc() {
    // given
    List<String> titles = new ArrayList<>();
    for (int i = 1; i <= 100; i++) {
        Studylog studylog = new Studylog(member1, String.valueOf(i), String.valueOf(i), mission1, asList(tag1, tag2));
        Studylog savedStudylog = studylogRepository.save(studylog);
        titles.add(savedStudylog.getTitle());
    }
    // when
    List<Studylog> studylogs = studylogRepository.findTop50ByDeletedFalseOrderByIdDesc();
    // then
    assertThat(studylogs).hasSize(50);
}
Also used : ArrayList(java.util.ArrayList) Studylog(wooteco.prolog.studylog.domain.Studylog) RepositoryTest(wooteco.support.utils.RepositoryTest) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 28 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 29 with Studylog

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

the class AbilityStudylogResponse method of.

public static AbilityStudylogResponse of(Studylog studylog, List<StudylogAbility> studylogAbilities) {
    StudylogResponse studylogResponse = StudylogResponse.of(studylog);
    List<AbilityResponse> abilityResponses = studylogAbilities.stream().map(it -> AbilityResponse.of(it.getAbility())).collect(Collectors.toList());
    return new AbilityStudylogResponse(studylogResponse, abilityResponses);
}
Also used : Ability(wooteco.prolog.ability.domain.Ability) StudylogAbility(wooteco.prolog.ability.domain.StudylogAbility) List(java.util.List) 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)

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