-
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.
Merge pull request #207 from swm-standard/seyeon/swm-170
Test: jacoco test coverage์ ๋ง๊ฒ ํ ์คํธ ์ฝ๋ ์์ฑ
- Loading branch information
Showing
10 changed files
with
175 additions
and
20 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
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/com/swm_standard/phote/common/module/Qualifier.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,8 @@ | ||
package com.swm_standard.phote.common.module | ||
|
||
class Qualifier { | ||
@MustBeDocumented | ||
@Retention(AnnotationRetention.RUNTIME) | ||
@Target(AnnotationTarget.TYPE, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER) | ||
annotation class Generated | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
package com.swm_standard.phote.entity | ||
|
||
import org.junit.jupiter.api.Assertions | ||
import com.navercorp.fixturemonkey.FixtureMonkey | ||
import com.navercorp.fixturemonkey.kotlin.KotlinPlugin | ||
import com.navercorp.fixturemonkey.kotlin.giveMeOne | ||
import org.assertj.core.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
import java.util.UUID | ||
|
||
class AnswerTest { | ||
private val fixtureMonkey: FixtureMonkey = | ||
FixtureMonkey | ||
.builder() | ||
.plugin(KotlinPlugin()) | ||
.build() | ||
|
||
@Test | ||
fun `๋ฌธ์ ๊ฐ ๊ฐ๊ด์์ด๋ฉด ์ ์ค๋ต ์ฒดํฌํ๋ค`() { | ||
val category = Category.MULTIPLE | ||
|
@@ -14,29 +23,41 @@ class AnswerTest { | |
|
||
answer.checkMultipleAnswer() | ||
|
||
Assertions.assertEquals(submittedAnswer == correctAnswer, answer.isCorrect) | ||
Assertions.assertFalse(answer.isCorrect) | ||
Assertions.assertThat(submittedAnswer == correctAnswer).isEqualTo(answer.isCorrect) | ||
Assertions.assertThat(answer.isCorrect).isFalse() | ||
} | ||
|
||
@Test | ||
fun `์ ์ถํ ๋ต์์ ์์ฑํ๋ค`() { | ||
val exam = createExam() | ||
val submittedAnswer = "1" | ||
val question = createQuestion(answer = submittedAnswer) | ||
val sequence = 2 | ||
|
||
val createAnswer = | ||
Answer.createAnswer( | ||
question = question, | ||
exam = exam, | ||
submittedAnswer = submittedAnswer, | ||
sequence = sequence, | ||
) | ||
|
||
Assertions.assertThat(createAnswer.submittedAnswer).isEqualTo(submittedAnswer) | ||
Assertions.assertThat(createAnswer.exam).isEqualTo(exam) | ||
Assertions.assertThat(createAnswer.sequence).isEqualTo(sequence) | ||
} | ||
|
||
fun createWorkbook(): Workbook = | ||
Workbook( | ||
title = "hinc", | ||
description = null, | ||
member = createMember(), | ||
member = fixtureMonkey.giveMeOne(), | ||
emoji = "๐", | ||
) | ||
|
||
fun createMember(): Member = | ||
Member( | ||
name = "Mayra Payne", | ||
email = "[email protected]", | ||
image = "dicant", | ||
provider = Provider.APPLE, | ||
) | ||
|
||
fun createExam() = | ||
Exam( | ||
member = createMember(), | ||
member = fixtureMonkey.giveMeOne(), | ||
workbook = createWorkbook(), | ||
sequence = 4282, | ||
time = 40, | ||
|
@@ -69,4 +90,24 @@ class AnswerTest { | |
submittedAnswer = submittedAnswer, | ||
sequence = 2017, | ||
) | ||
|
||
private fun createQuestion(answer: String) = | ||
Question( | ||
id = UUID.randomUUID(), | ||
member = | ||
Member( | ||
name = "Charmaine Joseph", | ||
email = "[email protected]", | ||
image = "maiorum", | ||
provider = Provider.APPLE, | ||
), | ||
statement = "Missouri", | ||
options = null, | ||
image = null, | ||
answer = answer, | ||
category = Category.MULTIPLE, | ||
questionSet = listOf(), | ||
tags = mutableListOf(), | ||
memo = null, | ||
) | ||
} |
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
52 changes: 52 additions & 0 deletions
52
src/test/kotlin/com/swm_standard/phote/entity/QuestionSetTest.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,52 @@ | ||
package com.swm_standard.phote.entity | ||
|
||
import com.navercorp.fixturemonkey.FixtureMonkey | ||
import com.navercorp.fixturemonkey.api.introspector.ConstructorPropertiesArbitraryIntrospector | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class QuestionSetTest { | ||
private val fixtureMonkey: FixtureMonkey = | ||
FixtureMonkey | ||
.builder() | ||
.objectIntrospector(ConstructorPropertiesArbitraryIntrospector.INSTANCE) | ||
.build() | ||
|
||
@Test | ||
fun `questionSet์ ์์๋ฅผ ๋ณ๊ฒฝํ๋๋ฐ ์ฑ๊ณตํ๋ค`() { | ||
val questionSet = fixtureMonkey.giveMeOne(QuestionSet::class.java) | ||
val newSequence = 4 | ||
|
||
questionSet.updateSequence(newSequence) | ||
|
||
assertEquals(newSequence, questionSet.sequence) | ||
} | ||
|
||
@Test | ||
fun `questionSet์ ์์ฑํ๋๋ฐ ์ฑ๊ณตํ๋ค`() { | ||
val question = createQuestion() | ||
val workbook = fixtureMonkey.giveMeOne(Workbook::class.java) | ||
val newSequence = 1 | ||
|
||
val questionSet = | ||
QuestionSet.createQuestionSet( | ||
question = question, | ||
workbook = workbook, | ||
nextSequence = newSequence, | ||
) | ||
|
||
assertEquals(newSequence, questionSet.sequence) | ||
assertEquals(workbook, questionSet.workbook) | ||
assertEquals(question, questionSet.question) | ||
} | ||
|
||
private fun createQuestion(): Question = | ||
Question( | ||
member = Member("phote", "[email protected]", "image", Provider.KAKAO), | ||
statement = "๋ชจ๋ ๊ฐ์ด ๋์ผํ ์ผ๊ฐํ์?", | ||
image = "http://example.com/image.jpg", | ||
answer = "์ ์ผ๊ฐํ", | ||
category = Category.ESSAY, | ||
memo = "์ผ๊ฐํ ๋ด๊ฐ์ ํฉ์ 180๋์ด๋ค.", | ||
) | ||
} |
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 |
---|---|---|
|
@@ -2,10 +2,20 @@ package com.swm_standard.phote.entity | |
|
||
import com.fasterxml.jackson.databind.JsonNode | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.navercorp.fixturemonkey.FixtureMonkey | ||
import com.navercorp.fixturemonkey.kotlin.KotlinPlugin | ||
import com.navercorp.fixturemonkey.kotlin.giveMeOne | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import java.util.UUID | ||
|
||
class QuestionTest { | ||
private val fixtureMonkey: FixtureMonkey = | ||
FixtureMonkey | ||
.builder() | ||
.plugin(KotlinPlugin()) | ||
.build() | ||
|
||
private fun createQuestion(): Question { | ||
val objectMapper = ObjectMapper() | ||
val jsonString = """ | ||
|
@@ -27,6 +37,32 @@ class QuestionTest { | |
answer = "1", | ||
category = Category.MULTIPLE, | ||
memo = "์ผ๊ฐํ์ ๊ผญ์ง์ ์ด 3๊ฐ๋ค", | ||
tags = | ||
mutableListOf( | ||
Tag( | ||
id = 1, | ||
name = "์ํ", | ||
question = | ||
Question( | ||
id = UUID.randomUUID(), | ||
member = | ||
Member( | ||
name = "Luella Kline", | ||
email = "[email protected]", | ||
image = "et", | ||
provider = Provider.APPLE, | ||
), | ||
statement = "Louisiana", | ||
options = null, | ||
image = null, | ||
answer = "hac", | ||
category = Category.MULTIPLE, | ||
questionSet = listOf(), | ||
tags = mutableListOf(), | ||
memo = null, | ||
), | ||
), | ||
), | ||
) | ||
} | ||
|
||
|
@@ -42,4 +78,19 @@ class QuestionTest { | |
val expectedList = listOf("์ผ๊ฐํ", "์ฌ๊ฐํ", "๋ง๋ฆ๋ชจ", "ํํ์ฌ๋ณํ", "์") | ||
assertEquals(expectedList, deserializedOptions) | ||
} | ||
|
||
@Test | ||
fun `๊ณต์ ๋ฐ์ ๋ฌธ์ ๋ฅผ ๋ณต์ฌํด์ ์ ์ฅํ๋ค`() { | ||
val questions = listOf(createQuestion(), createQuestion(), createQuestion()) | ||
// val questions = fixtureMonkey.giveMeBuilder<Question>().size(Question::tags, 0).sampleList(5) | ||
val member: Member = fixtureMonkey.giveMeOne() | ||
|
||
val sharedQuestions = Question.createSharedQuestions(questions, member) | ||
|
||
assertEquals(sharedQuestions.size, questions.size) | ||
assertEquals(sharedQuestions[0].member, member) | ||
assertEquals(sharedQuestions[2].answer, questions[2].answer) | ||
assertEquals(sharedQuestions[1].tags[0].name, questions[1].tags[0].name) | ||
assertEquals(sharedQuestions[1].tags[0].id, questions[1].tags[0].id) | ||
} | ||
} |
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