From 6c1fba476c4191caa11d87b7d54a429f86d8c429 Mon Sep 17 00:00:00 2001 From: Hyeonjun Park Date: Sun, 17 Dec 2023 15:36:08 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat=20:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=ED=95=9C=20=EC=82=AC=EB=9E=8C=EC=9D=98=20lecture=20bookmark=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../query/LectureBookmarkDao.kt | 34 +++++++++++++++++++ .../query/LectureBookmarkQueryCtrl.kt | 17 ++++++++++ .../query/dto/LectureBookmarkRes.kt | 9 +++++ .../query/LectureBookmarkDaoTest.kt | 8 +++++ .../query/LectureBookmarkQueryCtrlTest.kt | 19 +++++++++++ 5 files changed, 87 insertions(+) create mode 100644 src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt create mode 100644 src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrl.kt create mode 100644 src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/dto/LectureBookmarkRes.kt create mode 100644 src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt create mode 100644 src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrlTest.kt diff --git a/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt new file mode 100644 index 0000000..2e37768 --- /dev/null +++ b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt @@ -0,0 +1,34 @@ +package site.qbox.qboxserver.domain.lecturebookmark.query + +import com.querydsl.core.group.GroupBy.list +import com.querydsl.jpa.impl.JPAQueryFactory +import site.qbox.qboxserver.domain.lecture.command.entity.QLecture.lecture +import site.qbox.qboxserver.domain.lecture.query.dto.QLectureRes +import site.qbox.qboxserver.domain.lecturebookmark.command.entity.QLectureBookmark.lectureBookmark +import site.qbox.qboxserver.domain.lecturebookmark.query.dto.LectureBookmarkRes +import site.qbox.qboxserver.domain.lecturebookmark.query.dto.QLectureBookmarkRes +import site.qbox.qboxserver.global.annotation.QueryService + +@QueryService +class LectureBookmarkDao( + private val queryFactory: JPAQueryFactory, +) { + fun findAllByMemberId(memberId: String): LectureBookmarkRes { + return queryFactory.select( + QLectureBookmarkRes( + lectureBookmark.id.memberId, + list( + QLectureRes( + lecture.name, + lecture.id.code, + lecture.id.departId) + ))) + .from(lectureBookmark) + .join(lecture).on(lectureBookmark.id.lectureId.eq(lecture.id)) + .groupBy(lectureBookmark.id.memberId) + .having(lectureBookmark.id.memberId.eq(memberId)) + .fetchFirst() + + + } +} \ No newline at end of file diff --git a/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrl.kt b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrl.kt new file mode 100644 index 0000000..d439f9a --- /dev/null +++ b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrl.kt @@ -0,0 +1,17 @@ +package site.qbox.qboxserver.domain.lecturebookmark.query + +import org.springframework.security.core.Authentication +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import site.qbox.qboxserver.domain.lecturebookmark.query.dto.LectureBookmarkRes + +@RestController +@RequestMapping("lecture-bookmarks") +class LectureBookmarkQueryCtrl ( + private val lectureBookmarkDao: LectureBookmarkDao +) { + @GetMapping("me") + fun getByMe(auth: Authentication) : LectureBookmarkRes = + lectureBookmarkDao.findAllByMemberId(auth.name) +} \ No newline at end of file diff --git a/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/dto/LectureBookmarkRes.kt b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/dto/LectureBookmarkRes.kt new file mode 100644 index 0000000..6f10531 --- /dev/null +++ b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/dto/LectureBookmarkRes.kt @@ -0,0 +1,9 @@ +package site.qbox.qboxserver.domain.lecturebookmark.query.dto + +import com.querydsl.core.annotations.QueryProjection +import site.qbox.qboxserver.domain.lecture.query.dto.LectureRes + +data class LectureBookmarkRes @QueryProjection constructor ( + val memberId: String, + val lectures: List, +) \ No newline at end of file diff --git a/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt b/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt new file mode 100644 index 0000000..e389caa --- /dev/null +++ b/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt @@ -0,0 +1,8 @@ +package site.qbox.qboxserver.domain.lecturebookmark.query + +import io.kotest.core.spec.style.DescribeSpec + +class LectureBookmarkDaoTest : DescribeSpec() { + + +} diff --git a/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrlTest.kt b/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrlTest.kt new file mode 100644 index 0000000..39b2f0f --- /dev/null +++ b/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrlTest.kt @@ -0,0 +1,19 @@ +package site.qbox.qboxserver.domain.lecturebookmark.query + +import org.springframework.boot.test.mock.mockito.MockBean +import site.qbox.qboxserver.config.WebClientDocsTest + +class LectureBookmarkQueryCtrlTest : WebClientDocsTest() { + @MockBean + lateinit var lectureBookmarkDao: LectureBookmarkDao + + init { + beforeEach { + + } + + it("로그인한 사람의 lecture bookmark를 조회한다.") { + + } + } +} From 9a9ce6f920c34f05a89d4a91360ce08b8aa702c3 Mon Sep 17 00:00:00 2001 From: Hyeonjun Park Date: Mon, 18 Dec 2023 13:02:13 +0900 Subject: [PATCH 2/4] =?UTF-8?q?test=20:=20LectureBookmarkqueryCtrl=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../query/LectureBookmarkDao.kt | 1 - .../query/LectureBookmarkQueryCtrlTest.kt | 42 ++++++++++++++++--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt index 2e37768..9180c64 100644 --- a/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt +++ b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt @@ -29,6 +29,5 @@ class LectureBookmarkDao( .having(lectureBookmark.id.memberId.eq(memberId)) .fetchFirst() - } } \ No newline at end of file diff --git a/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrlTest.kt b/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrlTest.kt index 39b2f0f..bc3299d 100644 --- a/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrlTest.kt +++ b/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkQueryCtrlTest.kt @@ -1,18 +1,50 @@ package site.qbox.qboxserver.domain.lecturebookmark.query -import org.springframework.boot.test.mock.mockito.MockBean +import com.ninjasquad.springmockk.MockkBean +import io.kotest.core.spec.DisplayName +import io.mockk.every +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest +import org.springframework.restdocs.payload.JsonFieldType +import org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath +import org.springframework.restdocs.payload.PayloadDocumentation.responseFields +import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status import site.qbox.qboxserver.config.WebClientDocsTest +import site.qbox.qboxserver.domain.lecture.query.dto.LectureRes +import site.qbox.qboxserver.domain.lecturebookmark.query.dto.LectureBookmarkRes +@WebMvcTest(LectureBookmarkQueryCtrl::class) +@DisplayName("LectureBookmarkQueryCtrl") class LectureBookmarkQueryCtrlTest : WebClientDocsTest() { - @MockBean + @MockkBean lateinit var lectureBookmarkDao: LectureBookmarkDao init { - beforeEach { - - } it("로그인한 사람의 lecture bookmark를 조회한다.") { + val res = LectureBookmarkRes( + "kkk@gg.com", listOf( + LectureRes("소프트웨어공학", "aaaa", 4), + LectureRes("디자인원리", "bbbb", 5), + LectureRes("C언어기초", "cccc", 6), + )) + + every { lectureBookmarkDao.findAllByMemberId(any(String::class)) } returns res + + val action = performGet("/lecture-bookmarks/me") + + action.andExpect(status().isOk) + + action.andDo( + print( + "find-all-lecture-bookmarks-by-me", + responseFields( + fieldWithPath("memberId").type(JsonFieldType.STRING).description("조회자 ID"), + fieldWithPath("lectures.[].name").type(JsonFieldType.STRING).description("강의명"), + fieldWithPath("lectures.[].code").type(JsonFieldType.STRING).description("강의코드"), + fieldWithPath("lectures.[].departId").type(JsonFieldType.NUMBER).description("강의 소속 학과 ID"), + ) + ) + ) } } From 3620e36eabf0982f7f17a60fde074bfe1e74a741 Mon Sep 17 00:00:00 2001 From: phjppo0918 Date: Mon, 1 Jan 2024 01:31:22 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat=20:=20member=20=EB=B3=84=20lecture=20b?= =?UTF-8?q?ookmark=20=EC=A1=B0=ED=9A=8C=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/answer/query/AnswerDao.kt | 2 +- .../query/LectureBookmarkDao.kt | 28 ++++----- .../domain/member/command/entity/Member.kt | 2 + .../email/svc/EmailAuthenticationSvc.kt | 4 +- .../query/LectureBookmarkDaoTest.kt | 63 +++++++++++++++++++ 5 files changed, 82 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/site/qbox/qboxserver/domain/answer/query/AnswerDao.kt b/src/main/kotlin/site/qbox/qboxserver/domain/answer/query/AnswerDao.kt index 4ab072b..b20aeb9 100644 --- a/src/main/kotlin/site/qbox/qboxserver/domain/answer/query/AnswerDao.kt +++ b/src/main/kotlin/site/qbox/qboxserver/domain/answer/query/AnswerDao.kt @@ -55,7 +55,7 @@ class AnswerDao( } private fun mapToRes( - summary: MutableList, + summary: List, comments: MutableMap> ) = summary.map { AnswerRes(it, comments[getAnswerId(it)] ?: emptyList()) diff --git a/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt index 9180c64..4a7053e 100644 --- a/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt +++ b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt @@ -1,7 +1,9 @@ package site.qbox.qboxserver.domain.lecturebookmark.query +import com.querydsl.core.group.GroupBy.groupBy import com.querydsl.core.group.GroupBy.list import com.querydsl.jpa.impl.JPAQueryFactory +import jakarta.persistence.EntityNotFoundException import site.qbox.qboxserver.domain.lecture.command.entity.QLecture.lecture import site.qbox.qboxserver.domain.lecture.query.dto.QLectureRes import site.qbox.qboxserver.domain.lecturebookmark.command.entity.QLectureBookmark.lectureBookmark @@ -14,20 +16,18 @@ class LectureBookmarkDao( private val queryFactory: JPAQueryFactory, ) { fun findAllByMemberId(memberId: String): LectureBookmarkRes { - return queryFactory.select( - QLectureBookmarkRes( - lectureBookmark.id.memberId, - list( - QLectureRes( - lecture.name, - lecture.id.code, - lecture.id.departId) - ))) - .from(lectureBookmark) + return queryFactory.from(lectureBookmark) + .where(lectureBookmark.id.memberId.eq(memberId)) .join(lecture).on(lectureBookmark.id.lectureId.eq(lecture.id)) - .groupBy(lectureBookmark.id.memberId) - .having(lectureBookmark.id.memberId.eq(memberId)) - .fetchFirst() - + .transform(groupBy(lectureBookmark.id.memberId).`as`( + QLectureBookmarkRes( + lectureBookmark.id.memberId, + list( + QLectureRes( + lecture.name, + lecture.id.code, + lecture.id.departId) + )) + ))[memberId] ?: throw EntityNotFoundException() } } \ No newline at end of file diff --git a/src/main/kotlin/site/qbox/qboxserver/domain/member/command/entity/Member.kt b/src/main/kotlin/site/qbox/qboxserver/domain/member/command/entity/Member.kt index cde877b..9f78449 100644 --- a/src/main/kotlin/site/qbox/qboxserver/domain/member/command/entity/Member.kt +++ b/src/main/kotlin/site/qbox/qboxserver/domain/member/command/entity/Member.kt @@ -1,6 +1,7 @@ package site.qbox.qboxserver.domain.member.command.entity import jakarta.persistence.Column +import jakarta.persistence.ElementCollection import jakarta.persistence.EmbeddedId import jakarta.persistence.Entity import org.springframework.security.crypto.password.PasswordEncoder @@ -14,6 +15,7 @@ class Member( @Column(nullable = false, unique = true) var nickname: String, @Column(nullable = false) var password: String, @Column(nullable = false) var departId: Long, + @ElementCollection val role: Set = setOf(Role.USER) ) : BaseEntity() { constructor( diff --git a/src/main/kotlin/site/qbox/qboxserver/domain/member/email/svc/EmailAuthenticationSvc.kt b/src/main/kotlin/site/qbox/qboxserver/domain/member/email/svc/EmailAuthenticationSvc.kt index 6f5e05f..b140ece 100644 --- a/src/main/kotlin/site/qbox/qboxserver/domain/member/email/svc/EmailAuthenticationSvc.kt +++ b/src/main/kotlin/site/qbox/qboxserver/domain/member/email/svc/EmailAuthenticationSvc.kt @@ -1,7 +1,6 @@ package site.qbox.qboxserver.domain.member.email.svc import org.springframework.context.ApplicationEventPublisher -import org.springframework.stereotype.Service import site.qbox.qboxserver.domain.member.email.dto.CertifyKeyReq import site.qbox.qboxserver.domain.member.email.dto.RegisterEmailReq import site.qbox.qboxserver.domain.member.email.dto.event.RegisteredEmailEvent @@ -10,9 +9,10 @@ import site.qbox.qboxserver.domain.member.email.entity.EmailAuthKey import site.qbox.qboxserver.domain.member.email.exception.EmailNotAuthenticatedException import site.qbox.qboxserver.domain.member.email.infra.AuthenticatedEmailRepo import site.qbox.qboxserver.domain.member.email.infra.EmailAuthKeyRepo +import site.qbox.qboxserver.global.annotation.CommandService import java.util.* -@Service +@CommandService class EmailAuthenticationSvc ( private val authenticationEmailRepo: AuthenticatedEmailRepo, private val emailAuthKeyRepo: EmailAuthKeyRepo, diff --git a/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt b/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt index e389caa..0ff2106 100644 --- a/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt +++ b/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt @@ -1,8 +1,71 @@ package site.qbox.qboxserver.domain.lecturebookmark.query +import io.kotest.core.spec.DisplayName import io.kotest.core.spec.style.DescribeSpec +import io.kotest.extensions.spring.SpringExtension +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import site.qbox.qboxserver.domain.lecture.command.LectureRepo +import site.qbox.qboxserver.domain.lecture.command.entity.Lecture +import site.qbox.qboxserver.domain.lecture.command.entity.LectureId +import site.qbox.qboxserver.domain.lecturebookmark.command.LectureBookmarkRepo +import site.qbox.qboxserver.domain.lecturebookmark.command.entity.LectureBookmark +@SpringBootTest +@DisplayName("LectureBookmarkDao") class LectureBookmarkDaoTest : DescribeSpec() { + override fun extensions() = listOf(SpringExtension) + + @Autowired + lateinit var lectureBookmarkDao: LectureBookmarkDao + + @Autowired + lateinit var lectureBookmarkRepo: LectureBookmarkRepo + + @Autowired + lateinit var lectureRepo: LectureRepo + + init { + beforeEach { + val lectureIds = listOf( + LectureId("111", 1), + LectureId("222", 2), + LectureId("333", 3), + LectureId("444", 4), + LectureId("555", 5), + LectureId("666", 5), + ) + lectureRepo.saveAll( + listOf( + Lecture(lectureIds[0], "디자인기초"), + Lecture(lectureIds[1], "한국사기초"), + Lecture(lectureIds[2], "수학기초"), + Lecture(lectureIds[3], "영어기초"), + Lecture(lectureIds[4], "서양사기초"), + Lecture(lectureIds[5], "동양사기초"), + ), + ) + + lectureBookmarkRepo.saveAll( + listOf( + LectureBookmark("aaa", lectureIds[0]), + LectureBookmark("aaa", lectureIds[1]), + LectureBookmark("aaa", lectureIds[2]), + LectureBookmark("aaa", lectureIds[3]), + LectureBookmark("aaa", lectureIds[4]), + LectureBookmark("bbb", lectureIds[4]), + LectureBookmark("bbb", lectureIds[5]), + LectureBookmark("ccc", lectureIds[5]), + ) + ) + } + + it("memberId를 통한 북마크 목록 조회를 수행한다.") { + lectureBookmarkDao.findAllByMemberId("aaa") + } + + } + } From a3c90b9c073c66872b58b002b3a62a7fe55f94fb Mon Sep 17 00:00:00 2001 From: phjppo0918 Date: Mon, 1 Jan 2024 14:01:03 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat=20:=20lectureBookmark=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=8B=9C=20=EB=B6=81=EB=A7=88=ED=81=AC=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=9D=B4=20=EC=97=86=EC=9C=BC=EB=A9=B4=20=EB=B9=88=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=A5=BC=20=EC=A0=9C=EA=B3=B5?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lecturebookmark/query/LectureBookmarkDao.kt | 3 +-- .../qboxserver/domain/member/command/entity/Member.kt | 1 - .../lecturebookmark/query/LectureBookmarkDaoTest.kt | 11 ++++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt index 4a7053e..7b28491 100644 --- a/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt +++ b/src/main/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDao.kt @@ -3,7 +3,6 @@ package site.qbox.qboxserver.domain.lecturebookmark.query import com.querydsl.core.group.GroupBy.groupBy import com.querydsl.core.group.GroupBy.list import com.querydsl.jpa.impl.JPAQueryFactory -import jakarta.persistence.EntityNotFoundException import site.qbox.qboxserver.domain.lecture.command.entity.QLecture.lecture import site.qbox.qboxserver.domain.lecture.query.dto.QLectureRes import site.qbox.qboxserver.domain.lecturebookmark.command.entity.QLectureBookmark.lectureBookmark @@ -28,6 +27,6 @@ class LectureBookmarkDao( lecture.id.code, lecture.id.departId) )) - ))[memberId] ?: throw EntityNotFoundException() + ))[memberId] ?: LectureBookmarkRes(memberId, emptyList()) } } \ No newline at end of file diff --git a/src/main/kotlin/site/qbox/qboxserver/domain/member/command/entity/Member.kt b/src/main/kotlin/site/qbox/qboxserver/domain/member/command/entity/Member.kt index 9f78449..15b143d 100644 --- a/src/main/kotlin/site/qbox/qboxserver/domain/member/command/entity/Member.kt +++ b/src/main/kotlin/site/qbox/qboxserver/domain/member/command/entity/Member.kt @@ -15,7 +15,6 @@ class Member( @Column(nullable = false, unique = true) var nickname: String, @Column(nullable = false) var password: String, @Column(nullable = false) var departId: Long, - @ElementCollection val role: Set = setOf(Role.USER) ) : BaseEntity() { constructor( diff --git a/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt b/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt index 0ff2106..e02cd69 100644 --- a/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt +++ b/src/test/kotlin/site/qbox/qboxserver/domain/lecturebookmark/query/LectureBookmarkDaoTest.kt @@ -3,6 +3,7 @@ package site.qbox.qboxserver.domain.lecturebookmark.query import io.kotest.core.spec.DisplayName import io.kotest.core.spec.style.DescribeSpec import io.kotest.extensions.spring.SpringExtension +import io.kotest.matchers.shouldBe import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import site.qbox.qboxserver.domain.lecture.command.LectureRepo @@ -62,7 +63,15 @@ class LectureBookmarkDaoTest : DescribeSpec() { } it("memberId를 통한 북마크 목록 조회를 수행한다.") { - lectureBookmarkDao.findAllByMemberId("aaa") + val result = lectureBookmarkDao.findAllByMemberId("aaa") + + result.lectures.count() shouldBe 5 + + } + + it("북마크 등록을 안한 유저의 letcure list는 비어있다.") { + val result = lectureBookmarkDao.findAllByMemberId("kkk") + result.lectures shouldBe emptyList() } }