diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt index d16871e25dc..11b567c70ca 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/multiplechoiceinput/MultipleChoiceInputEqualsRuleClassifierProviderTest.kt @@ -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 @@ -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: @@ -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 ) @@ -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 ) @@ -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 ) } @@ -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 ) } @@ -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 ) } @@ -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())