Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2037: file formatting under multiplechoiceinput package #2049

Merged
merged 5 commits into from
Oct 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import dagger.Component
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.app.model.InteractionObject
import org.oppia.android.domain.classify.InteractionObjectTestBuilder
import org.robolectric.annotation.Config
import org.robolectric.annotation.LooperMode
import javax.inject.Inject
Expand All @@ -23,9 +23,12 @@ import kotlin.test.fail
@LooperMode(LooperMode.Mode.PAUSED)
@Config(manifest = Config.NONE)
class MultipleChoiceInputEqualsRuleClassifierProviderTest {
private val NON_NEGATIVE_VALUE_0 = createNonNegativeInt(value = 0)
private val NON_NEGATIVE_VALUE_1 = createNonNegativeInt(value = 1)
private val STRING_VALUE_2 = createString(value = "test")

private val NON_NEGATIVE_VALUE_TEST_0 =
InteractionObjectTestBuilder.createNonNegativeInt(value = 0)
private val NON_NEGATIVE_VALUE_TEST_1 =
InteractionObjectTestBuilder.createNonNegativeInt(value = 1)
private val STRING_VALUE_TEST = InteractionObjectTestBuilder.createString(value = "test")

@Inject
internal lateinit var multipleChoiceInputEqualsRuleClassifierProvider:
Expand All @@ -42,10 +45,10 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest {

@Test
fun testNonNegativeAnswer_nonNegativeInput_sameValue_bothValuesMatch() {
val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0)
val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0)

val matches = inputEqualsRuleClassifier.matches(
answer = NON_NEGATIVE_VALUE_0,
answer = NON_NEGATIVE_VALUE_TEST_0,
inputs = inputs
)

Expand All @@ -54,10 +57,10 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest {

@Test
fun testNonNegativeAnswer_nonNegativeInput_differentValue_bothValuesDoNotMatch() {
val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0)
val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0)

val matches = inputEqualsRuleClassifier.matches(
answer = NON_NEGATIVE_VALUE_1,
answer = NON_NEGATIVE_VALUE_TEST_1,
inputs = inputs
)

Expand All @@ -66,11 +69,11 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest {

@Test
fun testNonNegativeAnswer_missingInput_throwsException() {
val inputs = mapOf("y" to NON_NEGATIVE_VALUE_0)
val inputs = mapOf("y" to NON_NEGATIVE_VALUE_TEST_0)

val exception = assertThrows(IllegalStateException::class) {
inputEqualsRuleClassifier.matches(
answer = NON_NEGATIVE_VALUE_0,
answer = NON_NEGATIVE_VALUE_TEST_0,
inputs = inputs
)
}
Expand All @@ -82,11 +85,11 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest {

@Test
fun testUnexpectedStringAnswer_nonNegativeIntInput_throwsException() {
val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0)
val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0)

val exception = assertThrows(IllegalStateException::class) {
inputEqualsRuleClassifier.matches(
answer = STRING_VALUE_2,
answer = STRING_VALUE_TEST,
inputs = inputs
)
}
Expand All @@ -98,11 +101,11 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest {

@Test
fun testNonNegativeAnswer_stringInput_throwsException() {
val inputs = mapOf("x" to STRING_VALUE_2)
val inputs = mapOf("x" to STRING_VALUE_TEST)

val exception = assertThrows(IllegalStateException::class) {
inputEqualsRuleClassifier.matches(
answer = NON_NEGATIVE_VALUE_0,
answer = NON_NEGATIVE_VALUE_TEST_0,
inputs = inputs
)
}
Expand All @@ -112,14 +115,6 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest {
.contains("Expected input value to be of type NON_NEGATIVE_INT")
}

private fun createNonNegativeInt(value: Int): InteractionObject {
return InteractionObject.newBuilder().setNonNegativeInt(value).build()
}

private fun createString(value: String): InteractionObject {
return InteractionObject.newBuilder().setNormalizedString(value).build()
}

private fun setUpTestApplicationComponent() {
DaggerMultipleChoiceInputEqualsRuleClassifierProviderTest_TestApplicationComponent.builder()
.setApplication(ApplicationProvider.getApplicationContext())
Expand Down