forked from YAPP-Github/24th-Web-Team-1-BE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RELEASE] v24.08.12.01 YAPP-Github#342
* [Refactor/YAPP-Github#329] 테스트 코드 보강 및 개선 (YAPP-Github#330) * [Fix/YAPP-Github#338] 구독 학습지 마지막 아티클을 받고 progess를 증가하는 문제해결 (YAPP-Github#339)
- Loading branch information
Showing
50 changed files
with
1,672 additions
and
893 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
110 changes: 110 additions & 0 deletions
110
...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,110 @@ | ||
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.jooq.JSON | ||
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) | ||
.set(ArticleMainCard.ARTICLE_MAIN_CARD.CREATED_AT, LocalDateTime.now()) | ||
.set(ArticleMainCard.ARTICLE_MAIN_CARD.WRITER_ID, 1L) | ||
.set(ArticleMainCard.ARTICLE_MAIN_CARD.WRITER_EMAIL, "[email protected]") | ||
.set( | ||
ArticleMainCard.ARTICLE_MAIN_CARD.WRITER_DESCRIPTION, | ||
JSON.valueOf("{ \"name\": \"writer\", \"url\": \"http://localhost:8080/writer\", \"imgUrl\": \"http://localhost:8080/writer.jpg\" }") | ||
) | ||
.set( | ||
ArticleMainCard.ARTICLE_MAIN_CARD.WORKBOOKS, | ||
JSON.valueOf("[{\"id\": 1, \"title\": \"title\"}]") | ||
) | ||
.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
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
Oops, something went wrong.