-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf38e16
commit 64c136e
Showing
9 changed files
with
216 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...src/test/kotlin/com/few/api/repo/explain/article/ArticleMainCardDaoExplainGenerateTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.few.api.repo.explain.article | ||
|
||
import com.few.api.repo.dao.article.ArticleMainCardDao | ||
import com.few.api.repo.dao.article.command.ArticleMainCardExcludeWorkbookCommand | ||
import com.few.api.repo.dao.article.command.UpdateArticleMainCardWorkbookCommand | ||
import com.few.api.repo.dao.article.command.WorkbookCommand | ||
import com.few.api.repo.explain.ResultGenerator | ||
import com.few.api.repo.jooq.JooqTestSpec | ||
import com.few.data.common.code.CategoryType | ||
import io.github.oshai.kotlinlogging.KotlinLogging | ||
import jooq.jooq_dsl.tables.ArticleMainCard | ||
import org.jooq.DSLContext | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Tag | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import java.net.URL | ||
import java.time.LocalDateTime | ||
|
||
@Tag("explain") | ||
class ArticleMainCardDaoExplainGenerateTest : JooqTestSpec() { | ||
private val log = KotlinLogging.logger {} | ||
|
||
@Autowired | ||
private lateinit var dslContext: DSLContext | ||
|
||
@Autowired | ||
private lateinit var articleMainCardDao: ArticleMainCardDao | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
log.debug { "===== start setUp =====" } | ||
dslContext.deleteFrom(ArticleMainCard.ARTICLE_MAIN_CARD).execute() | ||
dslContext.insertInto(ArticleMainCard.ARTICLE_MAIN_CARD) | ||
.set(ArticleMainCard.ARTICLE_MAIN_CARD.ID, 1L) | ||
.set(ArticleMainCard.ARTICLE_MAIN_CARD.TITLE, "this is title1") | ||
.set(ArticleMainCard.ARTICLE_MAIN_CARD.MAIN_IMAGE_URL, "http://localhost:8080/image1.jpg") | ||
.set(ArticleMainCard.ARTICLE_MAIN_CARD.CATEGORY_CD, CategoryType.fromCode(0)!!.code) | ||
.execute() | ||
log.debug { "===== finish setUp =====" } | ||
} | ||
|
||
@Test | ||
fun selectArticleMainCardsRecordQueryExplain() { | ||
val query = articleMainCardDao.selectArticleMainCardsRecordQuery(setOf(1L)) | ||
|
||
val explain = dslContext.explain(query).toString() | ||
ResultGenerator.execute(query, explain, "selectArticleMainCardsRecordQueryExplain") | ||
} | ||
|
||
@Test | ||
fun insertArticleMainCardCommandExplain() { | ||
val command = ArticleMainCardExcludeWorkbookCommand( | ||
articleId = 2L, | ||
articleTitle = "this is title2", | ||
mainImageUrl = URL("http://localhost:8080/image2.jpg"), | ||
categoryCd = CategoryType.fromCode(0)!!.code, | ||
createdAt = LocalDateTime.now(), | ||
writerId = 1L, | ||
writerEmail = "[email protected]", | ||
writerName = "writer", | ||
writerUrl = URL("http://localhost:8080/writer"), | ||
writerImgUrl = URL("http://localhost:8080/writer.jpg") | ||
).let { | ||
articleMainCardDao.insertArticleMainCardCommand(it) | ||
} | ||
|
||
val explain = command.toString() | ||
|
||
ResultGenerator.execute(command, explain, "insertArticleMainCardCommandExplain") | ||
} | ||
|
||
@Test | ||
fun updateArticleMainCardSetWorkbookCommandExplain() { | ||
val command = UpdateArticleMainCardWorkbookCommand( | ||
articleId = 1L, | ||
workbooks = listOf( | ||
WorkbookCommand( | ||
id = 1L, | ||
title = "workbook1" | ||
), | ||
WorkbookCommand( | ||
id = 2L, | ||
title = "workbook2" | ||
) | ||
) | ||
).let { | ||
articleMainCardDao.updateArticleMainCardSetWorkbookCommand(it) | ||
} | ||
|
||
val explain = command.toString() | ||
|
||
ResultGenerator.execute(command, explain, "updateArticleMainCardSetWorkbookCommandExplain") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package com.few.api.repo.explain.member | ||
|
||
import com.few.api.repo.dao.member.MemberDao | ||
import com.few.api.repo.dao.member.command.DeleteMemberCommand | ||
import com.few.api.repo.dao.member.command.InsertMemberCommand | ||
import com.few.api.repo.dao.member.command.UpdateDeletedMemberTypeCommand | ||
import com.few.api.repo.dao.member.command.UpdateMemberTypeCommand | ||
import com.few.api.repo.dao.member.query.BrowseWorkbookWritersQuery | ||
import com.few.api.repo.dao.member.query.SelectMemberByEmailNotConsiderDeletedAtQuery | ||
import com.few.api.repo.dao.member.query.SelectMemberByEmailQuery | ||
import com.few.api.repo.dao.member.query.SelectWriterQuery | ||
import com.few.api.repo.dao.member.support.WriterDescription | ||
|
@@ -117,7 +119,7 @@ class MemberDaoExplainGenerateTest : JooqTestSpec() { | |
|
||
@Test | ||
fun selectMemberByEmailNotConsiderDeletedAtQueryExplain() { | ||
val query = SelectMemberByEmailQuery("[email protected]").let { | ||
val query = SelectMemberByEmailNotConsiderDeletedAtQuery("[email protected]").let { | ||
memberDao.selectMemberByEmailQuery(it) | ||
} | ||
|
||
|
@@ -181,11 +183,10 @@ class MemberDaoExplainGenerateTest : JooqTestSpec() { | |
|
||
@Test | ||
fun deleteMemberCommandExplain() { | ||
val command = UpdateDeletedMemberTypeCommand( | ||
id = 1, | ||
memberType = MemberType.WRITER | ||
val command = DeleteMemberCommand( | ||
memberId = 1 | ||
).let { | ||
memberDao.updateMemberTypeCommand(it) | ||
memberDao.deleteMemberCommand(it) | ||
} | ||
|
||
val explain = InsertUpdateExplainGenerator.execute(dslContext, command.sql, command.bindValues) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters