Search in sources :

Example 1 with Tag

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

the class MemberTagApplicationListener method updateMemberTags.

private void updateMemberTags() {
    final List<StudylogTag> studylogTags = studylogTagService.findAll();
    for (StudylogTag studylogTag : studylogTags) {
        final Tag tag = studylogTag.getTag();
        final Member member = studylogTag.getStudylog().getMember();
        memberTagRepository.register(new MemberTags(Collections.singletonList(new MemberTag(member, tag))));
    }
}
Also used : MemberTags(wooteco.prolog.member.domain.MemberTags) MemberTag(wooteco.prolog.member.domain.MemberTag) MemberTag(wooteco.prolog.member.domain.MemberTag) Tag(wooteco.prolog.studylog.domain.Tag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) Member(wooteco.prolog.member.domain.Member)

Example 2 with Tag

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

the class StudylogTagRepositoryTest method findByTagInEmpty.

@DisplayName("Tag 리스트와 매칭되는 studylogTag가 없을시 빈 리스트 조회")
@Test
void findByTagInEmpty() {
    // given
    Tag tag1 = tagRepository.save(new Tag("태그1"));
    Tag tag2 = tagRepository.save(new Tag("태그2"));
    // when
    List<StudylogTag> studylogTags = studylogTagRepository.findByTagIn(Arrays.asList(tag1, tag2));
    // then
    assertThat(studylogTags).isEmpty();
}
Also used : Tag(wooteco.prolog.studylog.domain.Tag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) Test(org.junit.jupiter.api.Test) RepositoryTest(wooteco.support.utils.RepositoryTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with Tag

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

the class StudylogTagsTest method addTest.

@DisplayName("StudylogTag가 add 될 때 중복된 이름의 Tag는 배제된다.")
@Test
void addTest() {
    // given
    Tag 워니_태그 = new Tag("워니");
    Tag 세션1_태그 = new Tag("세션1");
    StudylogTag 워니_스터디로그태그 = new StudylogTag(2L, 웨지가_쓴_글, 워니_태그);
    StudylogTag 세션1_스터디로그태그 = new StudylogTag(3L, 웨지가_쓴_글, 세션1_태그);
    List<StudylogTag> studylogTags = Arrays.asList(워니_스터디로그태그, 세션1_스터디로그태그);
    // when
    this.studylogTags.add(studylogTags);
    // then
    assertThat(this.studylogTags.getValues()).containsExactlyInAnyOrder(this.워니_스터디로그태그, 세션1_스터디로그태그);
}
Also used : Tag(wooteco.prolog.studylog.domain.Tag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with Tag

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

the class StudylogTagsTest method updateTest.

@DisplayName("update로 StudylogTag 리스트를 교체한다.")
@Test
void updateTest() {
    // given
    Tag 포비_태그 = new Tag("포비");
    Tag 세션1_태그 = new Tag("세션1");
    StudylogTag 포비_스터디로그태그 = new StudylogTag(2L, 웨지가_쓴_글, 포비_태그);
    StudylogTag 세션1_스터디로그태그 = new StudylogTag(3L, 웨지가_쓴_글, 세션1_태그);
    List<StudylogTag> studylogTags = Arrays.asList(포비_스터디로그태그, 세션1_스터디로그태그);
    // when
    this.studylogTags.update(studylogTags);
    // then
    assertThat(this.studylogTags.getValues()).containsExactlyInAnyOrder(포비_스터디로그태그, 세션1_스터디로그태그);
}
Also used : Tag(wooteco.prolog.studylog.domain.Tag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with Tag

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

the class StudylogTagRepositoryTest method findByTagInEmpty.

@DisplayName("Tag 리스트와 매칭되는 StudylogTag가 없을시 빈 리스트 조회")
@Test
void findByTagInEmpty() {
    // given
    Tag tag1 = tagRepository.save(new Tag("태그1"));
    Tag tag2 = tagRepository.save(new Tag("태그2"));
    // when
    List<StudylogTag> studylogTags = studylogTagRepository.findByTagIn(Arrays.asList(tag1, tag2));
    // then
    assertThat(studylogTags).isEmpty();
}
Also used : Tag(wooteco.prolog.studylog.domain.Tag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) StudylogTag(wooteco.prolog.studylog.domain.StudylogTag) Test(org.junit.jupiter.api.Test) RepositoryTest(wooteco.support.utils.RepositoryTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Tag (wooteco.prolog.studylog.domain.Tag)11 DisplayName (org.junit.jupiter.api.DisplayName)10 Test (org.junit.jupiter.api.Test)10 StudylogTag (wooteco.prolog.studylog.domain.StudylogTag)9 RepositoryTest (wooteco.support.utils.RepositoryTest)8 Member (wooteco.prolog.member.domain.Member)5 Mission (wooteco.prolog.session.domain.Mission)4 Session (wooteco.prolog.session.domain.Session)4 Studylog (wooteco.prolog.studylog.domain.Studylog)4 MemberTag (wooteco.prolog.member.domain.MemberTag)1 MemberTags (wooteco.prolog.member.domain.MemberTags)1