From 667bf89a8fe8eb5eb8d1abe606a14370d7a7793b Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Tue, 22 Aug 2023 01:30:00 +0000 Subject: [PATCH 01/21] Fix a variety of dev platform-specific issues. These issues were found after I started using a new development environment. --- .../ProfileAndDeviceIdFragmentTest.kt | 855 +++++++++--------- .../DeveloperOptionsFragmentTest.kt | 4 +- .../app/parser/StringToRatioParserTest.kt | 2 +- .../AppLanguageLocaleHandlerTest.kt | 8 +- .../AppLanguageResourceHandlerTest.kt | 14 +- .../LoggingIdentifierController.kt | 14 +- .../domain/audio/AudioPlayerControllerTest.kt | 8 +- .../AnswerClassificationControllerTest.kt | 4 +- ...tXAtPositionYRuleClassifierProviderTest.kt | 12 +- ...eforeElementYRuleClassifierProviderTest.kt | 12 +- ...IsEqualToOrderingClassifierProviderTest.kt | 2 +- ...IncorrectPositionClassifierProviderTest.kt | 4 +- ...inatorEqualToRuleClassifierProviderTest.kt | 4 +- ...xactlyEqualToRuleClassifierProviderTest.kt | 4 +- ...erPartEqualToRuleClassifierProviderTest.kt | 4 +- ...eratorEqualToRuleClassifierProviderTest.kt | 4 +- ...nSimplestFormRuleClassifierProviderTest.kt | 6 +- ...sEquivalentToRuleClassifierProviderTest.kt | 2 +- ...xactlyEqualToRuleClassifierProviderTest.kt | 4 +- ...IsGreaterThanRuleClassifierProviderTest.kt | 4 +- ...putIsLessThanRuleClassifierProviderTest.kt | 4 +- ...putIsInRegionRuleClassifierProviderTest.kt | 4 +- ...nAtLeastOneOfRuleClassifierProviderTest.kt | 6 +- ...onInputEqualsRuleClassifierProviderTest.kt | 2 +- ...roperSubsetOfRuleClassifierProviderTest.kt | 6 +- ...ceInputEqualsRuleClassifierProviderTest.kt | 6 +- ...nitsIsEqualToRuleClassifierProviderTest.kt | 2 +- ...sEquivalentToRuleClassifierProviderTest.kt | 4 +- ...icInputEqualsRuleClassifierProviderTest.kt | 4 +- ...ThanOrEqualToRuleClassifierProviderTest.kt | 4 +- ...IsGreaterThanRuleClassifierProviderTest.kt | 4 +- ...sivelyBetweenRuleClassifierProviderTest.kt | 16 +- ...ThanOrEqualToRuleClassifierProviderTest.kt | 8 +- ...putIsLessThanRuleClassifierProviderTest.kt | 8 +- ...thinToleranceRuleClassifierProviderTest.kt | 20 +- ...ioInputEqualsRuleClassifierProviderTest.kt | 4 +- ...berOfTermsEqualToClassifierProviderTest.kt | 4 +- ...icTermEqualToRuleClassifierProviderTest.kt | 10 +- ...tIsEquivalentRuleClassifierProviderTest.kt | 4 +- ...InputContainsRuleClassifierProviderTest.kt | 4 +- ...xtInputEqualsRuleClassifierProviderTest.kt | 4 +- ...utFuzzyEqualsRuleClassifierProviderTest.kt | 2 +- ...putStartsWithRuleClassifierProviderTest.kt | 4 +- .../ExplorationActiveTimeControllerTest.kt | 2 +- .../ExplorationProgressControllerTest.kt | 2 +- .../testing/FakeExplorationRetrieverTest.kt | 10 +- .../HintHandlerProdImplTest.kt | 18 +- .../domain/locale/LocaleControllerTest.kt | 2 +- .../LoggingIdentifierControllerTest.kt | 38 +- .../CpuPerformanceSnapshotterTest.kt | 2 +- .../analytics/LearnerAnalyticsLoggerTest.kt | 2 +- .../ProfileManagementControllerTest.kt | 8 +- ...uestionAssessmentProgressControllerTest.kt | 2 +- model/src/main/proto/BUILD.bazel | 5 +- .../scripts/testing/TestGitRepository.kt | 64 +- .../build/FilterPerLanguageResourcesTest.kt | 12 +- .../build/TransformAndroidManifestTest.kt | 30 +- .../org/oppia/android/scripts/ci/BUILD.bazel | 2 +- .../scripts/ci/ComputeAffectedTestsTest.kt | 18 +- .../scripts/ci/RetrieveAffectedTestsTest.kt | 8 +- .../oppia/android/scripts/common/BUILD.bazel | 1 + .../android/scripts/common/BazelClientTest.kt | 4 +- .../scripts/common/CommandExecutorImplTest.kt | 6 +- .../android/scripts/common/GitClientTest.kt | 6 +- .../scripts/common/ProtoStringEncoderTest.kt | 4 +- .../scripts/docs/KdocValidityCheckTest.kt | 36 +- .../label/AccessibilityLabelCheckTest.kt | 12 +- .../scripts/license/LicenseTextsCheckTest.kt | 8 +- .../license/MavenDependenciesListCheckTest.kt | 22 +- .../GenerateMavenDependenciesListTest.kt | 20 +- .../scripts/maven/RetrieveLicenseTextsTest.kt | 10 +- .../regex/RegexPatternValidationCheckTest.kt | 186 ++-- .../scripts/testfile/TestFileCheckTest.kt | 6 +- .../scripts/testing/TestBazelWorkspaceTest.kt | 16 +- .../scripts/testing/TestGitRepositoryTest.kt | 52 +- .../scripts/todo/TodoIssueCommentCheckTest.kt | 6 +- .../todo/TodoIssueResolvedCheckTest.kt | 6 +- .../android/scripts/todo/TodoOpenCheckTest.kt | 14 +- .../xml/StringLanguageTranslationCheckTest.kt | 4 +- .../scripts/xml/StringResourceParserTest.kt | 18 +- .../xml/StringResourceValidationCheckTest.kt | 14 +- .../android/scripts/xml/XmlSyntaxCheckTest.kt | 6 +- .../oppia/android/testing/AssertionHelpers.kt | 39 +- .../testing/FakeAnalyticsEventLoggerTest.kt | 10 +- .../testing/FakeExceptionLoggerTest.kt | 4 +- .../FakePerformanceMetricsEventLoggerTest.kt | 10 +- .../data/DataProviderTestMonitorTest.kt | 77 +- ...InitializeDefaultLocaleRuleOmissionTest.kt | 2 +- .../threading/CoroutineExecutorServiceTest.kt | 34 +- .../testing/time/FakeOppiaClockTest.kt | 8 +- .../testing/TestNoOpAssetRepositoryTest.kt | 12 +- .../data/AsyncDataSubscriptionManagerTest.kt | 6 +- .../util/data/InMemoryBlockingCacheTest.kt | 8 +- .../util/locale/AndroidLocaleFactoryTest.kt | 14 +- .../util/locale/DisplayLocaleImplTest.kt | 16 +- .../testing/TestOppiaBidiFormatterTest.kt | 2 +- .../util/logging/SyncStatusManagerTestBase.kt | 2 +- .../util/math/FractionExtensionsTest.kt | 10 +- .../android/util/math/FractionParserTest.kt | 4 +- .../android/util/math/PeekableIteratorTest.kt | 2 +- .../android/util/math/RealExtensionsTest.kt | 24 +- 101 files changed, 1075 insertions(+), 996 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index 632098510b5..f1caf58e449 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -9,6 +9,7 @@ import android.view.View import androidx.annotation.IdRes import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.RecyclerView +import androidx.test.core.app.ActivityScenario import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView import androidx.test.espresso.ViewInteraction @@ -23,7 +24,6 @@ import androidx.test.espresso.matcher.ViewMatchers.isEnabled import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText -import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.truth.content.IntentSubject.assertThat import androidx.work.Configuration @@ -62,6 +62,7 @@ import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.atPositi import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.hasItemCount import org.oppia.android.app.shim.ViewBindingShimModule import org.oppia.android.app.testing.activity.TestActivity +import org.oppia.android.app.testing.activity.TestActivity.Companion.createIntent import org.oppia.android.app.translation.testing.ActivityRecreatorTestModule import org.oppia.android.app.utility.OrientationChangeAction.Companion.orientationLandscape import org.oppia.android.data.backends.gae.NetworkConfigProdModule @@ -147,12 +148,6 @@ import javax.inject.Singleton class ProfileAndDeviceIdFragmentTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @get:Rule val oppiaTestRule = OppiaTestRule() - @get:Rule - var activityRule = - ActivityScenarioRule( - TestActivity.createIntent(ApplicationProvider.getApplicationContext()) - ) - @Inject lateinit var profileTestHelper: ProfileTestHelper @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject lateinit var context: Context @@ -193,559 +188,587 @@ class ProfileAndDeviceIdFragmentTest { @Test fun testFragment_withOnlyAdminProfile_hasThreeItems() { - initializeActivityAndAddFragment() - - // There should be three items: a header, a profile, and the sync status. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) + runInTestActivityAndAddFragment { + // There should be three items: a header, a profile, and the sync status. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) + } } @Test fun testFragment_withOnlyAdminProfile_hasDeviceIdHeader() { - initializeActivityAndAddFragment() - - onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) + runInTestActivityAndAddFragment { + onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) + } } @Test fun testFragment_hasDeviceId() { - initializeActivityAndAddFragment() - - onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("0347439ebe8b")))) + runInTestActivityAndAddFragment { + onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("113e04cc09a3")))) + } } @Test fun testFragment_deviceId_hasCopyButton() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) + runInTestActivityAndAddFragment { + onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) + } } @Test fun testFragment_deviceId_clickCopyButton_copiesDeviceIdToClipboard() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() - - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("Oppia installation ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("0347439ebe8b") + runInTestActivityAndAddFragment { + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() + + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("Oppia installation ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("113e04cc09a3") + } } @Test fun testFragment_withOnlyAdminProfile_hasOneProfileListed() { - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(isDisplayed())) + runInTestActivityAndAddFragment { + onProfileNameAt(position = 1).check(matches(isDisplayed())) + } } @Test fun testFragment_profileEntry_hasProfileName() { - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(withText("Admin"))) + runInTestActivityAndAddFragment { + onProfileNameAt(position = 1).check(matches(withText("Admin"))) + } } @Test fun testFragment_profileEntry_hasLearnerId() { - initializeActivityAndAddFragment() - - onLearnerIdAt(position = 1).check(matches(withText("a9fe66ab"))) + runInTestActivityAndAddFragment { + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + } } @Test fun testFragment_profileEntry_hasCopyButton() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) + } } @Test fun testFragment_profileEntry_clickFirstCopyButton_copiesAdminLearnerIdToClipboard() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() - - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("Admin's learner ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("a9fe66ab") + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() + + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("Admin's learner ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("8dcbbd21") + } } @Test fun testFragment_multipleProfiles_listsAllProfiles() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // Header + admin + 5 new profiles + sync status = 8 items. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + runInTestActivityAndAddFragment { + // Header + admin + 5 new profiles + sync status = 8 items. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + } } @Test fun testFragment_multipleProfiles_adminIsFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(withText("Admin"))) + runInTestActivityAndAddFragment { + onProfileNameAt(position = 1).check(matches(withText("Admin"))) + } } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentName() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // The second entry is not the admin. - onProfileNameAt(position = 2).check(matches(withText("A"))) + runInTestActivityAndAddFragment { + // The second entry is not the admin. + onProfileNameAt(position = 2).check(matches(withText("A"))) + } } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // The second profile has a different learner ID. - onLearnerIdAt(position = 1).check(matches(withText("a9fe66ab"))) - onLearnerIdAt(position = 2).check(matches(withText("6e563e2f"))) + runInTestActivityAndAddFragment { + // The second profile has a different learner ID. + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + onLearnerIdAt(position = 2).check(matches(withText("208663b0"))) + } } @Test fun testFragment_multipleProfiles_copySecondEntry_copiesDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 2).perform(click()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 2).perform(click()) + testCoroutineDispatchers.runCurrent() - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("A's learner ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("6e563e2f") + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("A's learner ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("208663b0") + } } @Test fun testFragment_initialState_deviceIdCopyButtonHasCopyLabel() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + runInTestActivityAndAddFragment { + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_initialState_learnerIdCopyButtonHasCopyLabel() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickDeviceIdCopyButton_deviceIdIsCopiedButNotLearnerId() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_learnerIdIsCopiedButNotDeviceId() { - initializeActivityAndAddFragment() + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() - - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_copyInOtherApp_nothingIsCopied() { - initializeActivityAndAddFragment() - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - updateClipDataAsThoughFromAnotherApp() + updateClipDataAsThoughFromAnotherApp() - // Changing the clipboard in a different app should reset the labels. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + // Changing the clipboard in a different app should reset the labels. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_rotate_learnerIdStillCopied() { - initializeActivityAndAddFragment() - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - // The button label should be restored after a rotation. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + // The button label should be restored after a rotation. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + } } @Test fun testFragment_multipleProfiles_rotate_profilesStillPresent() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + } } @Test fun testFragment_firstEntry_noAdminEvents_hasZeroAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + runInTestActivityAndAddFragment { + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_adminEvents_notUploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_adminEvents_uploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + } } @Test fun testFragment_firstEntry_noGenericEvents_hasZeroGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + runInTestActivityAndAddFragment { + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_genericEvents_notUploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events off of the admin profile. - logTwoAnalyticsEvents(profileId = null) + // Log a couple of events off of the admin profile. + logTwoAnalyticsEvents(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_genericEvents_uploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event, off of the admin profile. - logTwoAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) + // Log a couple of events, upload them, then log one more event, off of the admin profile. + logTwoAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + } } @Test fun testFragment_firstEntry_mixOfAdminAndGenericEvents_someUploaded_reportsAllEvents() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log & upload a mix of events with and without the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logThreeAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - - // Event counts should be represented in the correct places. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Log & upload a mix of events with and without the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logThreeAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + + // Event counts should be represented in the correct places. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) + } } @Test fun testFragment_secondEntry_noLearnerEvents_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + runInTestActivityAndAddFragment { + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_learnerEvents_notUploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_learnerEvents_uploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + } } @Test fun testFragment_secondEntry_learnerEvents_hasZeroAdminOrGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events, upload them, then log one more event, for a learner profile. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - - // The admin profile's event counts shouldn't change since the only logged events were for a - // specific learner profile. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events, upload them, then log one more event, for a learner profile. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + + // The admin profile's event counts shouldn't change since the only logged events were for a + // specific learner profile. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_adminAndGenericEvents_uploaded_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events generically and for the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - - // No events should be reported for the learner since it didn't have any events uploaded. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events generically and for the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + + // No events should be reported for the learner since it didn't have any events uploaded. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_initialState_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + runInTestActivityAndAddFragment { + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_initialState_wait_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() + runInTestActivityAndAddFragment { + testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) - testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_indicatorTextMentionsWaiting() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. Note - // that the extra event log is a slight hack to force a refresh of the status indicator (since - // network changes are polled when there are other changes to represent rather than being - // actively "pushed" by the system). - logAnalyticsEvent() - connectNetwork() - logAnalyticsEvent() - - // The status indicator is suggesting that events can be uploaded (and there are some available - // to upload), they just haven't been scheduled yet. - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. + // Note that the extra event log is a slight hack to force a refresh of the status indicator + // (since network changes are polled when there are other changes to represent rather than + // being actively "pushed" by the system). + logAnalyticsEvent() + connectNetwork() + logAnalyticsEvent() + + // The status indicator is suggesting that events can be uploaded (and there are some + // available to upload), they just haven't been scheduled yet. + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_uploadStarted_profileDataIsCurrentlyUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to - // produce the same situation to ensure the label is correct. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to + // produce the same situation to ensure the label is correct. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) + } } @Test fun testFragment_noConnectivity_indicatorTextMentionsDataCannotBeUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Enqueue an event but don't reconnect to the network. - logAnalyticsEvent() - - // The status indicator is suggesting that internet connectivity needs to resume in order to - // upload events. - onSyncStatusAt(position = 2) - .check( - matches( - withText( - containsString( - "Please connect to a WiFi or Cellular network in order to upload profile data" + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Enqueue an event but don't reconnect to the network. + logAnalyticsEvent() + + // The status indicator is suggesting that internet connectivity needs to resume in order to + // upload events. + onSyncStatusAt(position = 2) + .check( + matches( + withText( + containsString( + "Please connect to a WiFi or Cellular network in order to upload profile data" + ) ) ) ) - ) + } } @Test fun testFragment_eventLogged_waitForUpload_profileDataIsUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_eventLogged_uploadError_profileDataHasError() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() - // An upload error can currently only be simulated by directly influencing the sync manager. - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() + // An upload error can currently only be simulated by directly influencing the sync manager. + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Something went wrong when trying to upload events")))) + onSyncStatusAt(position = 2) + .check( + matches(withText(containsString("Something went wrong when trying to upload events"))) + ) + } } @Test fun testFragment_eventLogged_uploadError_anotherLogged_wait_profileDataIsUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.reportUploadError() - testCoroutineDispatchers.runCurrent() - - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.reportUploadError() + testCoroutineDispatchers.runCurrent() + + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_rotate_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() - - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_rotate_profileDataIsCurrentlyUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) + } } @Test fun testFragment_eventLogged_waitForUpload_rotate_profileDataIsUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_eventsLogged_uploadError_rotate_profileDataHasError() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() - - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Something went wrong when trying to upload events")))) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() + + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() + + onSyncStatusAt(position = 2) + .check( + matches(withText(containsString("Something went wrong when trying to upload events"))) + ) + } } @Test @@ -753,129 +776,141 @@ class ProfileAndDeviceIdFragmentTest { // Use fake time so that the generated event logs are consistent across runs. fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) profileTestHelper.addMoreProfiles(numProfiles = 2) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log & upload some events, then enqueue others. - logThreeAnalyticsEvents(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - - onShareIdsAndEventsButtonAt(position = 5).perform(click()) - testCoroutineDispatchers.runCurrent() - - val expectedShareText = - """ - Oppia app installation ID: 932459768f39 - - Profile name: Admin, learner ID: a9fe66ab - - Uploading learner events: 3 - - Uploaded learner events: 2 - - Uploading uncategorized events: 1 - - Uploaded uncategorized events: 4 - - Profile name: A, learner ID: 6e563e2f - - Uploading learner events: 2 - - Uploaded learner events: 1 - - Profile name: B, learner ID: 5c0710a2 - - Uploading learner events: 1 - - Uploaded learner events: 2 - Current sync status: Waiting to schedule data uploading worker…. - Event log encoding integrity checks: - - First 40 chars of encoded string: H4sIAAAAAAAAAOPSlGBUUj3FqMTFX5JaXBKfk5pY - - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - - SHA-1 hash (unwrapped event string): 76f7a26348b4034787982f9505c6b5697efc6567 - - Total event string length (unwrapped): 140 - Encoded event logs: - H4sIAAAAAAAAAOPSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ - gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - """.trimIndent() - val intents = getIntents() - assertThat(intents).hasSize(1) - assertThat(intents.single()).hasAction(Intent.ACTION_SEND) - assertThat(intents.single()).hasType("text/plain") - assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) - assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + + // Log & upload some events, then enqueue others. + logThreeAnalyticsEvents(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + + onShareIdsAndEventsButtonAt(position = 5).perform(click()) + testCoroutineDispatchers.runCurrent() + + val expectedShareText = + """ + Oppia app installation ID: 113e04cc09a3 + - Profile name: Admin, learner ID: 8dcbbd21 + - Uploading learner events: 3 + - Uploaded learner events: 2 + - Uploading uncategorized events: 1 + - Uploaded uncategorized events: 4 + - Profile name: A, learner ID: 208663b0 + - Uploading learner events: 2 + - Uploaded learner events: 1 + - Profile name: B, learner ID: 92d0c6e2 + - Uploading learner events: 1 + - Uploaded learner events: 2 + Current sync status: Waiting to schedule data uploading worker…. + Event log encoding integrity checks: + - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY + - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 + - Total event string length (unwrapped): 140 + Encoded event logs: + H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ + gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + """.trimIndent() + val intents = getIntents() + assertThat(intents).hasSize(1) + assertThat(intents.single()).hasAction(Intent.ACTION_SEND) + assertThat(intents.single()).hasType("text/plain") + assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) + assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) + } } @Test fun testFragment_noEventsPending_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - // The upload button should be disabled when there are no events to upload. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + // The upload button should be disabled when there are no events to upload. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + } } @Test fun testFragment_multipleEventsPending_noConnection_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // The button is still disabled since there's no internet connection. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + // The button is still disabled since there's no internet connection. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + } } @Test fun testFragment_multipleEventsPending_uploadLogsButtonEnabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - // With events pending & connectivity, the upload button should now be available to press. - onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) + // With events pending & connectivity, the upload button should now be available to press. + onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) + } } @Test fun testFragment_multipleEventsPending_clickUploadLogs_wait_uploadsEventLogs() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - fakeAnalyticsEventLogger.clearAllEvents() - - // Click the 'upload logs' button and wait. - onUploadLogsButtonAt(position = 4).perform(click()) - testCoroutineDispatchers.runCurrent() - - // The events should be uploaded. - assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) + runInTestActivityAndAddFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + fakeAnalyticsEventLogger.clearAllEvents() + + // Click the 'upload logs' button and wait. + onUploadLogsButtonAt(position = 4).perform(click()) + testCoroutineDispatchers.runCurrent() + + // The events should be uploaded. + assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) + } } - private fun initializeActivityAndAddFragment() { - activityRule.scenario.onActivity { activity -> - activity.setContentView(R.layout.test_activity) + private fun runInTestActivityAndAddFragment(testBlock: () -> Unit) { + launchActivityAndAddFragment().use { scenario -> + scenario.onActivity { activity -> + activity.setContentView(R.layout.test_activity) + + activity.supportFragmentManager.beginTransaction() + .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) + .commitNow() + } + connectNetwork() // Start with internet connectivity. + testCoroutineDispatchers.runCurrent() - activity.supportFragmentManager.beginTransaction() - .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) - .commitNow() + testBlock() } - connectNetwork() // Start with internet connectivity. - testCoroutineDispatchers.runCurrent() } + private fun launchActivityAndAddFragment() = + ActivityScenario.launch(createIntent(ApplicationProvider.getApplicationContext())) + private fun scrollTo(position: Int) { onView(withId(R.id.profile_and_device_id_recycler_view)) .perform(actionOnItemAtPosition(position, scrollTo())) diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt index e0340041713..9833c9b75c4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt @@ -417,7 +417,7 @@ class DeveloperOptionsFragmentTest { createDeveloperOptionsTestActivityIntent(internalProfileId) ).use { testCoroutineDispatchers.runCurrent() - val exception = assertThrows(RuntimeException::class) { + val exception = assertThrows() { scrollToPosition(position = 2) onView(withId(R.id.force_crash_text_view)).perform(click()) } @@ -432,7 +432,7 @@ class DeveloperOptionsFragmentTest { ).use { testCoroutineDispatchers.runCurrent() onView(isRoot()).perform(orientationLandscape()) - val exception = assertThrows(RuntimeException::class) { + val exception = assertThrows() { scrollToPosition(position = 2) onView(withId(R.id.force_crash_text_view)).perform(click()) } diff --git a/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt b/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt index 2b9845c78b8..2b8b3ae2296 100644 --- a/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt +++ b/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt @@ -231,7 +231,7 @@ class StringToRatioParserTest { @Test fun testParser_parseRatioOrThrow_ratioWithInvalidRatio_throwsException() { - val exception = assertThrows(IllegalArgumentException::class) { + val exception = assertThrows() { stringToRatioParser.parseRatioOrThrow("a:b:c") } assertThat(exception) diff --git a/app/src/test/java/org/oppia/android/app/translation/AppLanguageLocaleHandlerTest.kt b/app/src/test/java/org/oppia/android/app/translation/AppLanguageLocaleHandlerTest.kt index 942fb06d5b6..67846ded7ad 100644 --- a/app/src/test/java/org/oppia/android/app/translation/AppLanguageLocaleHandlerTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/AppLanguageLocaleHandlerTest.kt @@ -73,7 +73,7 @@ class AppLanguageLocaleHandlerTest { @Test fun testGetDisplayLocale_initialState_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { appLanguageLocaleHandler.getDisplayLocale() } @@ -103,7 +103,7 @@ class AppLanguageLocaleHandlerTest { fun testInitializeLocale_twice_throwsException() { appLanguageLocaleHandler.initializeLocale(computeNewAppLanguageLocale(ENGLISH)) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { appLanguageLocaleHandler.initializeLocale(retrieveAppLanguageLocale()) } @@ -117,7 +117,7 @@ class AppLanguageLocaleHandlerTest { fun testUpdateLocale_uninitialized_throwsException() { setAppLanguage(ENGLISH) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { appLanguageLocaleHandler.updateLocale(retrieveAppLanguageLocale()) } @@ -186,7 +186,7 @@ class AppLanguageLocaleHandlerTest { fun testInitializeLocaleForActivity_uninitialized_throwsException() { val configuration = Configuration() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { appLanguageLocaleHandler.initializeLocaleForActivity(configuration) } diff --git a/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt b/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt index 95db3cf4cd7..6206712d72d 100644 --- a/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt @@ -241,7 +241,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { handler.getStringInLocale(-1) } + assertThrows() { handler.getStringInLocale(-1) } } @Test @@ -278,7 +278,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { handler.getStringInLocaleWithWrapping(-1) } + assertThrows() { handler.getStringInLocaleWithWrapping(-1) } } @Test @@ -315,7 +315,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { + assertThrows() { handler.getStringInLocaleWithoutWrapping(-1) } } @@ -335,7 +335,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { handler.getStringArrayInLocale(-1) } + assertThrows() { handler.getStringArrayInLocale(-1) } } @Test @@ -365,7 +365,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { handler.getQuantityStringInLocale(-1, 0) } + assertThrows() { handler.getQuantityStringInLocale(-1, 0) } } @Test @@ -396,7 +396,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { + assertThrows() { handler.getQuantityStringInLocaleWithWrapping(-1, 0) } } @@ -431,7 +431,7 @@ class AppLanguageResourceHandlerTest { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() - assertThrows(Resources.NotFoundException::class) { + assertThrows() { handler.getQuantityStringInLocaleWithoutWrapping(-1, 0) } } diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt index 5ce84fc4bcf..f0e35b7d079 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/LoggingIdentifierController.kt @@ -28,7 +28,15 @@ class LoggingIdentifierController @Inject constructor( private val persistentCacheStoreFactory: PersistentCacheStore.Factory, private val oppiaLogger: OppiaLogger ) { - private val learnerIdRandom by lazy { Random(applicationIdSeed) } + // Use a base random to compute the per-ID random IDs in order so that test behaviors are + // consistent and deterministic when fixing the application ID seed. + private val baseRandom = Random(applicationIdSeed) + private val installationRandomSeed = baseRandom.nextLong() + private val sessionRandomSeed = baseRandom.nextLong() + private val learnerRandomSeed = baseRandom.nextLong() + private val installationIdRandom by lazy { Random(installationRandomSeed) } + private val sessionIdRandom by lazy { Random(sessionRandomSeed) } + private val learnerIdRandom by lazy { Random(learnerRandomSeed) } private val sessionId by lazy { MutableStateFlow(computeSessionId()) } private val sessionIdDataProvider by lazy { @@ -113,12 +121,12 @@ class LoggingIdentifierController @Inject constructor( sessionId.value = computeSessionId() } - private fun computeSessionId(): String = learnerIdRandom.randomUuid().toString() + private fun computeSessionId(): String = sessionIdRandom.randomUuid().toString() private fun computeInstallationId(): String { return machineLocale.run { MessageDigest.getInstance("SHA-1") - .digest(learnerIdRandom.randomUuid().toString().toByteArray()) + .digest(installationIdRandom.randomUuid().toString().toByteArray()) .joinToString("") { "%02x".formatForMachines(it) } .substring(startIndex = 0, endIndex = 12) } diff --git a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt index 1730f091d1b..960cfb995e3 100644 --- a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt @@ -433,7 +433,7 @@ class AudioPlayerControllerTest { @Test fun testController_notInitialized_releasePlayer_fails() { setUpMediaReadyApplication() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { audioPlayerController.releaseMediaPlayer() } @@ -444,7 +444,7 @@ class AudioPlayerControllerTest { @Test fun testError_notPrepared_invokePlay_fails() { setUpMediaReadyApplication() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { audioPlayerController.play(isPlayingFromAutoPlay = false, reloadingMainContent = false) } @@ -454,7 +454,7 @@ class AudioPlayerControllerTest { @Test fun testError_notPrepared_invokePause_fails() { setUpMediaReadyApplication() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { audioPlayerController.pause(isFromExplicitUserAction = true) } @@ -464,7 +464,7 @@ class AudioPlayerControllerTest { @Test fun testError_notPrepared_invokeSeekTo_fails() { setUpMediaReadyApplication() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { audioPlayerController.seekTo(500) } diff --git a/domain/src/test/java/org/oppia/android/domain/classify/AnswerClassificationControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/AnswerClassificationControllerTest.kt index 712ad585e86..8553d8d1f99 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/AnswerClassificationControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/AnswerClassificationControllerTest.kt @@ -152,7 +152,7 @@ class AnswerClassificationControllerTest { fun testClassify_forUnknownInteraction_throwsException() { val interaction = Interaction.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { answerClassificationController.classify( interaction, TEST_STRING_0, @@ -170,7 +170,7 @@ class AnswerClassificationControllerTest { .addAnswerGroups(AnswerGroup.newBuilder().addRuleSpecs(RuleSpec.getDefaultInstance())) .build() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { answerClassificationController.classify( interaction, TEST_STRING_0, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest.kt index 53be477a285..c7d224753c4 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest.kt @@ -55,7 +55,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { // Reverse the x and y parameters to ensure both have the incorrect type. val inputs = mapOf("x" to NON_NEGATIVE_VALUE_1, "y" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -75,7 +75,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { "y" to NON_NEGATIVE_VALUE_1 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -92,7 +92,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_testString_yInputWithIncorrectType_throwsException() { val inputs = mapOf("x" to VALID_CONTENT_ID_2, "y" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -109,7 +109,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { fun testAnswer_testString_missingInputX_throwsException() { val inputs = mapOf("y" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -126,7 +126,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_missingInputY_throwsException() { val inputs = mapOf("x" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -143,7 +143,7 @@ class DragDropSortInputHasElementXAtPositionYRuleClassifierProviderTest { fun testAnswer_bothInputsMissing_throwsException() { val inputs = mapOf("z" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXAtPositionYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest.kt index c706db71f64..a40e47d06f4 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest.kt @@ -56,7 +56,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { "y" to NON_NEGATIVE_VALUE_1 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -73,7 +73,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_testString_xInputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_1, "y" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -90,7 +90,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_testString_yInputWithIncorrectType_throwsException() { val inputs = mapOf("x" to VALID_CONTENT_ID_2, "y" to NON_NEGATIVE_VALUE_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -107,7 +107,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { fun testAnswer_testString_missingInputX_throwsException() { val inputs = mapOf("y" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -124,7 +124,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_missingInputY_throwsException() { val inputs = mapOf("x" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, @@ -141,7 +141,7 @@ class DragDropSortInputHasElementXBeforeElementYRuleClassifierProviderTest { fun testAnswer_bothInputsMissing_throwsException() { val inputs = mapOf("z" to VALID_CONTENT_ID_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasElementXBeforeElementYRuleClassifier.matches( answer = LIST_OF_SETS_OF_CONTENT_IDS, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProviderTest.kt index 2c65122884d..c6783f37ca1 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingClassifierProviderTest.kt @@ -137,7 +137,7 @@ class DragDropSortInputIsEqualToOrderingClassifierProviderTest { fun testAnswer_testLisOfSetsOfHtmlString_incorrectInputMap_throwsException() { val inputs = mapOf("y" to LIST_OF_SETS_12_3_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isEqualToOrderingClassifierProvider.matches( answer = LIST_OF_SETS_12_3_4, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifierProviderTest.kt index d62690db395..9da1c50711e 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/dragAndDropSortInput/DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifierProviderTest.kt @@ -69,7 +69,7 @@ class DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifier fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isEqualToOrderingWithOneItemIncorrectClassifier.matches( answer = LIST_OF_SETS_12_4_5, inputs = inputs, @@ -144,7 +144,7 @@ class DragDropSortInputIsEqualToOrderingWithOneItemAtIncorrectPositionClassifier fun testAnswer_testLisOfSetsOfHtmlString_incorrectInputMap_throwsException() { val inputs = mapOf("y" to LIST_OF_SETS_12_4_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isEqualToOrderingWithOneItemIncorrectClassifier.matches( answer = LIST_OF_SETS_12_4_5, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProviderTest.kt index a4641cc64ad..c0be3182da6 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProviderTest.kt @@ -124,7 +124,7 @@ class FractionInputHasDenominatorEqualToRuleClassifierProviderTest { fun testDenominatorEquals_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to FRACTION_VALUE_TEST_2_OVER_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { denominatorIsEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, @@ -143,7 +143,7 @@ class FractionInputHasDenominatorEqualToRuleClassifierProviderTest { fun testDenominatorEquals_missingInputF_throwsException() { val inputs = mapOf("y" to NON_NEGATIVE_VALUE_TEST_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { denominatorIsEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest.kt index 56212d736d9..d5d95ca9253 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest.kt @@ -208,7 +208,7 @@ class FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest { fun testFractionalEquals_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("f" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fractionalPartIsExactlyEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, @@ -227,7 +227,7 @@ class FractionInputHasFractionalPartExactlyEqualToRuleClassifierProviderTest { fun testFractionalEquals_missingInputF_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_2_OVER_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fractionalPartIsExactlyEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProviderTest.kt index 3d58861f475..c1212a3a082 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProviderTest.kt @@ -405,7 +405,7 @@ class FractionInputHasIntegerPartEqualToRuleClassifierProviderTest { fun testAnswer1Over2_inputMissing_throwsException() { val inputs = mapOf("y" to WHOLE_NUMBER_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputHasIntegerPartEqualToRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, @@ -423,7 +423,7 @@ class FractionInputHasIntegerPartEqualToRuleClassifierProviderTest { fun testAnswer1Over2_inputString_throwsException() { val inputs = mapOf("x" to STRING_VALUE_TEST_LOWERCASE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputHasIntegerPartEqualToRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProviderTest.kt index 647d37cbdd3..bc4bb343c03 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProviderTest.kt @@ -145,7 +145,7 @@ class FractionInputHasNumeratorEqualToRuleClassifierProviderTest { fun testNumeratorEquals_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { numeratorIsEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, @@ -164,7 +164,7 @@ class FractionInputHasNumeratorEqualToRuleClassifierProviderTest { fun testNumeratorEquals_missingInputF_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_2_OVER_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { numeratorIsEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest.kt index 1afbb516319..8a2d65bf340 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest.kt @@ -288,7 +288,7 @@ class FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest { val inputs = mapOf("y" to FRACTION_VALUE_TEST_1_OVER_2) val answer = FRACTION_VALUE_TEST_1_OVER_2 - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsEquivalentToAndInSimplestFormRuleClassifier.matches( answer = answer, inputs = inputs, @@ -306,7 +306,7 @@ class FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest { val inputs = mapOf("f" to FRACTION_VALUE_TEST_1_OVER_2) val answer = STRING_VALUE_TEST - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsEquivalentToAndInSimplestFormRuleClassifier.matches( answer = answer, inputs = inputs, @@ -324,7 +324,7 @@ class FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProviderTest { val inputs = mapOf("f" to STRING_VALUE_TEST) val answer = FRACTION_VALUE_TEST_1_OVER_2 - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsEquivalentToAndInSimplestFormRuleClassifier.matches( answer = answer, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProviderTest.kt index a61d6a03b41..4788fa0e9d9 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProviderTest.kt @@ -250,7 +250,7 @@ class FractionInputIsEquivalentToRuleClassifierProviderTest { fun testEquivalence_missingInput_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_2_OVER_8) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsEquivalentToRuleClassifier.matches( answer = FRACTION_VALUE_TEST_2_OVER_8, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProviderTest.kt index 5280da48f8a..67f4cdba623 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProviderTest.kt @@ -235,7 +235,7 @@ class FractionInputIsExactlyEqualToRuleClassifierProviderTest { fun testEquals_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("f" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isExactlyEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, @@ -254,7 +254,7 @@ class FractionInputIsExactlyEqualToRuleClassifierProviderTest { fun testEquals_missingInputF_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_2_OVER_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isExactlyEqualClassifierProvider.matches( answer = FRACTION_VALUE_TEST_2_OVER_4, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProviderTest.kt index b14d9993e06..aecd631ac68 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProviderTest.kt @@ -409,7 +409,7 @@ class FractionInputIsGreaterThanRuleClassifierProviderTest { fun testFractionalAnswer_missingInput_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_1_OVER_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputGreaterThanRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, @@ -427,7 +427,7 @@ class FractionInputIsGreaterThanRuleClassifierProviderTest { fun testFractionalAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE_TEST_LOWERCASE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputGreaterThanRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProviderTest.kt index 1dda20b3d7c..03a00646b82 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProviderTest.kt @@ -409,7 +409,7 @@ class FractionInputIsLessThanRuleClassifierProviderTest { fun testAnswer1Over2_inputMissing_throwsException() { val inputs = mapOf("y" to FRACTION_VALUE_TEST_1_OVER_2) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputLessThanRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, @@ -427,7 +427,7 @@ class FractionInputIsLessThanRuleClassifierProviderTest { fun testAnswer1Over2_inputString_throwsException() { val inputs = mapOf("x" to STRING_VALUE_TEST_LOWERCASE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputLessThanRuleClassifier .matches( answer = FRACTION_VALUE_TEST_1_OVER_2, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProviderTest.kt index 0694388d0c9..565da313100 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/imageClickInput/ImageClickInputIsInRegionRuleClassifierProviderTest.kt @@ -89,7 +89,7 @@ class ImageClickInputIsInRegionRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isInRegionClassifierProvider.matches( answer = IMAGE_REGION_ABC_POSITION_1, inputs = inputs, @@ -108,7 +108,7 @@ class ImageClickInputIsInRegionRuleClassifierProviderTest { fun testAnswer_testString_missingInputX_throwsException() { val inputs = mapOf("y" to createString(ITEM_REGION_A)) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isInRegionClassifierProvider.matches( answer = IMAGE_REGION_ABC_POSITION_1, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest.kt index 99be995d0bc..b6eedff3056 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest.kt @@ -156,7 +156,7 @@ class ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest { fun testItemSet_inputIsMissing_throwsException() { val inputs = mapOf("y" to ITEM_SET_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputDoesNotContainAtLeastOneOfRuleClassifier.matches( answer = ITEM_SET_12345, inputs = inputs, @@ -173,7 +173,7 @@ class ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest { fun testItemSet_inputHasTheWrongType_throwsException() { val inputs = mapOf("x" to DIFFERENT_INTERACTION_OBJECT_TYPE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputDoesNotContainAtLeastOneOfRuleClassifier.matches( answer = ITEM_SET_12345, inputs = inputs, @@ -190,7 +190,7 @@ class ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest { fun testItemSet_answerHasTheWrongType_throwsException() { val inputs = mapOf("x" to ITEM_SET_12345) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputDoesNotContainAtLeastOneOfRuleClassifier.matches( answer = DIFFERENT_INTERACTION_OBJECT_TYPE, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProviderTest.kt index 927dcdc5f3f..a3c467dcbdc 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProviderTest.kt @@ -162,7 +162,7 @@ class ItemSelectionInputEqualsRuleClassifierProviderTest { fun testLowercaseAnswer_missingInput_throwsException() { val inputs = mapOf("y" to TEST_HTML_STRING_SET_LOWERCASE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifierProvider.matches( answer = TEST_HTML_STRING_SET_LOWERCASE, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest.kt index 8997d85c434..a4d3a9fadb4 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest.kt @@ -169,7 +169,7 @@ class ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest() { fun testIsProperSubset_withInvalidInput_forAnswer12345_throwsException() { val inputs = mapOf("x" to ITEM_SELECTION_INVAILD) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputContainsAtLeastOneOfRuleClassifier.matches( answer = ITEM_SELECTION_12345, inputs = inputs, @@ -186,7 +186,7 @@ class ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest() { fun testIsProperSubset_withInput12345_forInvalidAnswer_throwsException() { val inputs = mapOf("x" to ITEM_SELECTION_12345) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputContainsAtLeastOneOfRuleClassifier.matches( answer = ITEM_SELECTION_INVAILD, inputs = inputs, @@ -203,7 +203,7 @@ class ItemSelectionInputIsProperSubsetOfRuleClassifierProviderTest() { fun testIsProperSubset_missingInputX_throwsException() { val inputs = mapOf("a" to ITEM_SELECTION_12345) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputContainsAtLeastOneOfRuleClassifier.matches( answer = ITEM_SELECTION_12345, inputs = inputs, 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 d193f4c795b..c66ab000848 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 @@ -72,7 +72,7 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { fun testNonNegativeAnswer_missingInput_throwsException() { val inputs = mapOf("y" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = NON_NEGATIVE_VALUE_TEST_0, inputs = inputs, @@ -89,7 +89,7 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { fun testUnexpectedStringAnswer_nonNegativeIntInput_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = STRING_VALUE_TEST, inputs = inputs, @@ -106,7 +106,7 @@ class MultipleChoiceInputEqualsRuleClassifierProviderTest { fun testNonNegativeAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE_TEST) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = NON_NEGATIVE_VALUE_TEST_0, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProviderTest.kt index 048e5574066..ee150667497 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProviderTest.kt @@ -185,7 +185,7 @@ class NumberWithUnitsIsEqualToRuleClassifierProviderTest { fun testWholeNumberInputValue_withRealAnswerNumWithUnits_throwsException() { val inputs = mapOf("f" to WHOLE_NUMBER_VALUE_9) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { unitsIsEqualsRuleClassifier.matches( answer = DOUBLE_VALUE_TEST_DIFFERENT_TYPE, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProviderTest.kt index d53553b9d79..4e6ed68a7e7 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProviderTest.kt @@ -179,7 +179,7 @@ class NumberWithUnitsIsEquivalentToRuleClassifierProviderTest { fun testInputNumberWithUnits_testAnswer_inputWithIncorrectType_verifyThrowsException() { val inputs = mapOf("f" to INPUT_TEST_NUMBER_WITH_UNITS) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { unitIsEquivalentRuleClassifier.matches( answer = DOUBLE_VALUE_TEST_DIFFERENT_TYPE, inputs = inputs, @@ -198,7 +198,7 @@ class NumberWithUnitsIsEquivalentToRuleClassifierProviderTest { fun testInputNumberWithUnits_testAnswerNumberWithUnits_withXMapping_verifyThrowsException() { val inputs = mapOf("x" to INPUT_TEST_NUMBER_WITH_UNITS) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { unitIsEquivalentRuleClassifier.matches( answer = ANSWER_TEST_NUMBER_WITH_UNITS, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProviderTest.kt index 1a4c4c8b07a..daa27f53145 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputEqualsRuleClassifierProviderTest.kt @@ -144,7 +144,7 @@ class NumericInputEqualsRuleClassifierProviderTest { fun testRealAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_REAL_VALUE_1_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -161,7 +161,7 @@ class NumericInputEqualsRuleClassifierProviderTest { fun testRealAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest.kt index b7298602e46..95bab873ae0 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest.kt @@ -199,7 +199,7 @@ class NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest { fun testRealAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_REAL_VALUE_1_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsGreaterThanOrEqualToRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -216,7 +216,7 @@ class NumericInputIsGreaterThanOrEqualToRuleClassifierProviderTest { fun testRealAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsGreaterThanOrEqualToRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProviderTest.kt index aa4f78a021d..d488eba6b5a 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProviderTest.kt @@ -200,7 +200,7 @@ class NumericInputIsGreaterThanRuleClassifierProviderTest { fun testRealAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_REAL_VALUE_1_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsGreaterThanRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -217,7 +217,7 @@ class NumericInputIsGreaterThanRuleClassifierProviderTest { fun testRealAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsGreaterThanRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProviderTest.kt index 504117c488e..948327a4ec9 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProviderTest.kt @@ -231,7 +231,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "c" to NEGATIVE_REAL_VALUE_3_5, "b" to POSITIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -250,7 +250,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to NEGATIVE_REAL_VALUE_3_5, "c" to POSITIVE_REAL_VALUE_1_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -269,7 +269,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to STRING_VALUE_1, "b" to NEGATIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -288,7 +288,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to POSITIVE_REAL_VALUE_1_5, "b" to STRING_VALUE_2 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -307,7 +307,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "c" to POSITIVE_INT_VALUE_1, "b" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -326,7 +326,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to POSITIVE_INT_VALUE_1, "c" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -345,7 +345,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to STRING_VALUE_1, "b" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_INT_VALUE_1, inputs = inputs, @@ -364,7 +364,7 @@ class NumericInputIsInclusivelyBetweenRuleClassifierProviderTest { "a" to NEGATIVE_INT_VALUE_3, "b" to STRING_VALUE_2 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsInclusivelyBetweenRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProviderTest.kt index 1bcc688f8c3..90cba1612af 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProviderTest.kt @@ -199,7 +199,7 @@ class NumericInputIsLessThanOrEqualToRuleClassifierProviderTest { fun testRealAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_REAL_VALUE_1_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanOrEqualToRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -216,7 +216,7 @@ class NumericInputIsLessThanOrEqualToRuleClassifierProviderTest { fun testRealAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanOrEqualToRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -233,7 +233,7 @@ class NumericInputIsLessThanOrEqualToRuleClassifierProviderTest { fun testIntAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_INT_VALUE_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanOrEqualToRuleClassifier.matches( answer = POSITIVE_INT_VALUE_1, inputs = inputs, @@ -250,7 +250,7 @@ class NumericInputIsLessThanOrEqualToRuleClassifierProviderTest { fun testIntAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanOrEqualToRuleClassifier.matches( answer = POSITIVE_INT_VALUE_1, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProviderTest.kt index 97d152ce3e4..e1819859a89 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProviderTest.kt @@ -199,7 +199,7 @@ class NumericInputIsLessThanRuleClassifierProviderTest { fun testRealAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_REAL_VALUE_1_5) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -216,7 +216,7 @@ class NumericInputIsLessThanRuleClassifierProviderTest { fun testRealAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -233,7 +233,7 @@ class NumericInputIsLessThanRuleClassifierProviderTest { fun testIntAnswer_missingInput_throwsException() { val inputs = mapOf("y" to POSITIVE_INT_VALUE_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanRuleClassifier.matches( answer = POSITIVE_INT_VALUE_3, inputs = inputs, @@ -250,7 +250,7 @@ class NumericInputIsLessThanRuleClassifierProviderTest { fun testIntAnswer_stringInput_throwsException() { val inputs = mapOf("x" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsLessThanRuleClassifier.matches( answer = NEGATIVE_INT_VALUE_1, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProviderTest.kt index d5481c0ac89..710210dcc39 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProviderTest.kt @@ -393,7 +393,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { val inputs = mapOf( "tol" to POSITIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -411,7 +411,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { val inputs = mapOf( "x" to NEGATIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -430,7 +430,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "c" to NEGATIVE_REAL_VALUE_3_5, "tol" to POSITIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -449,7 +449,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "x" to NEGATIVE_REAL_VALUE_3_5, "c" to POSITIVE_REAL_VALUE_1_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -468,7 +468,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "x" to STRING_VALUE_1, "tol" to NEGATIVE_REAL_VALUE_3_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_REAL_VALUE_1_5, inputs = inputs, @@ -486,7 +486,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { val inputs = mapOf( "tol" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -504,7 +504,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { val inputs = mapOf( "x" to POSITIVE_INT_VALUE_1 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -523,7 +523,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "c" to POSITIVE_INT_VALUE_1, "tol" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -542,7 +542,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "x" to POSITIVE_INT_VALUE_1, "c" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_INT_VALUE_2, inputs = inputs, @@ -561,7 +561,7 @@ class NumericInputIsWithinToleranceRuleClassifierProviderTest { "x" to STRING_VALUE_1, "tol" to POSITIVE_INT_VALUE_3 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputIsWithinToleranceRuleClassifier.matches( answer = POSITIVE_INT_VALUE_1, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt index 244cb981571..07945a20691 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProviderTest.kt @@ -100,7 +100,7 @@ class RatioInputEqualsRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { equalsClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -119,7 +119,7 @@ class RatioInputEqualsRuleClassifierProviderTest { fun testAnswer_testRatio_missingInputX_throwsException() { val inputs = mapOf("y" to RATIO_VALUE_TEST_1_2_3) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { equalsClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt index 2cbb3b324a4..a8c1b27243c 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProviderTest.kt @@ -82,7 +82,7 @@ class RatioInputHasNumberOfTermsEqualToClassifierProviderTest { fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("y" to RATIO_VALUE_TEST_1_2_3) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasNumberOfTermsEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -101,7 +101,7 @@ class RatioInputHasNumberOfTermsEqualToClassifierProviderTest { fun testAnswer_testRatio_missingInputY_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasNumberOfTermsEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasSpecificTermEqualToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasSpecificTermEqualToRuleClassifierProviderTest.kt index 81968647149..14101f1d79e 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasSpecificTermEqualToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasSpecificTermEqualToRuleClassifierProviderTest.kt @@ -198,7 +198,7 @@ class RatioInputHasSpecificTermEqualToRuleClassifierProviderTest { fun testAnswer_threeTerms_indexInputWithIncorrectType_throwsException() { val inputs = mapOf("x" to STRING_VALUE, "y" to NON_NEGATIVE_VALUE_TEST_3) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasSpecificTermEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -215,7 +215,7 @@ class RatioInputHasSpecificTermEqualToRuleClassifierProviderTest { fun testAnswer_threeTerms_valueInputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_4, "y" to STRING_VALUE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasSpecificTermEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -232,7 +232,7 @@ class RatioInputHasSpecificTermEqualToRuleClassifierProviderTest { fun testAnswer_threeTerms_missingIndexInput_throwsException() { val inputs = mapOf("y" to NON_NEGATIVE_VALUE_TEST_3) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasSpecificTermEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -249,7 +249,7 @@ class RatioInputHasSpecificTermEqualToRuleClassifierProviderTest { fun testAnswer_threeTerms_missingValueInput_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_4) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasSpecificTermEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -264,7 +264,7 @@ class RatioInputHasSpecificTermEqualToRuleClassifierProviderTest { @Test fun testAnswer_threeTerms_missingBothInputs_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hasSpecificTermEqualToClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = mapOf(), diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt index c93b44f8dc2..09fdeb952bb 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProviderTest.kt @@ -146,7 +146,7 @@ class RatioInputIsEquivalentRuleClassifierProviderTest { fun testAnswer_nonNegativeInput_inputWithIncorrectType_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_0) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isEquivalentClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, @@ -165,7 +165,7 @@ class RatioInputIsEquivalentRuleClassifierProviderTest { fun testAnswer_testRatio_missingInputX_throwsException() { val inputs = mapOf("y" to RATIO_VALUE_TEST_1_2_3) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { isEquivalentClassifierProvider.matches( answer = RATIO_VALUE_TEST_1_2_3, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputContainsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputContainsRuleClassifierProviderTest.kt index 6f4fc9013b1..1c258aec94e 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputContainsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputContainsRuleClassifierProviderTest.kt @@ -268,7 +268,7 @@ class TextInputContainsRuleClassifierProviderTest { fun testStringAnswer_missingInput_throwsException() { val inputs = mapOf("y" to STRING_VALUE_TEST_ANSWER_INPUT_SET) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputContainsRuleClassifier.matches( answer = STRING_VALUE_TEST_ANSWER, inputs = inputs, @@ -285,7 +285,7 @@ class TextInputContainsRuleClassifierProviderTest { fun testStringAnswer_nonNegativeIntInput_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_VALUE_TEST_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputContainsRuleClassifier.matches( answer = STRING_VALUE_TEST_ANSWER, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt index 3b658cca5df..6c5c53471c2 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputEqualsRuleClassifierProviderTest.kt @@ -210,7 +210,7 @@ class TextInputEqualsRuleClassifierProviderTest { fun testStringAnswer_missingInput_throwsException() { val inputs = mapOf("y" to STRING_VALUE_TEST_LOWERCASE_INPUT_SET) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = STRING_VALUE_TEST_LOWERCASE, inputs = inputs, @@ -227,7 +227,7 @@ class TextInputEqualsRuleClassifierProviderTest { fun testStringAnswer_nonNegativeIntInput_throwsException() { val inputs = mapOf("x" to INT_VALUE_TEST_NON_NEGATIVE) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputEqualsRuleClassifier.matches( answer = STRING_VALUE_TEST_UPPERCASE, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProviderTest.kt index 67c7874d515..3bb592d1499 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProviderTest.kt @@ -267,7 +267,7 @@ class TextInputFuzzyEqualsRuleClassifierProviderTest { fun testStringAnswer_nonNegativeIntInput_verifyThrowsException() { val inputs = mapOf("x" to NON_NEGATIVE_TEST_VALUE_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputFuzzyEqualsRuleClassifier.matches( answer = STRING_VALUE_TEST_ANSWER_UPPERCASE, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProviderTest.kt index c88983ed5fc..60ea011ad34 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProviderTest.kt @@ -292,7 +292,7 @@ class TextInputStartsWithRuleClassifierProviderTest { fun testStringAns_missingInput_throwsException() { val inputs = mapOf("y" to STRING_VALUE_TEST_STRING_LOWERCASE_INPUT_SET) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputStartsWithRuleClassifier.matches( answer = STRING_VALUE_TEST_STRING_LOWERCASE, inputs = inputs, @@ -309,7 +309,7 @@ class TextInputStartsWithRuleClassifierProviderTest { fun testStringAns_nonNegativeIntInput_throwsException() { val inputs = mapOf("x" to NON_NEGATIVE_TEST_VALUE_1) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { inputStartsWithRuleClassifier.matches( answer = STRING_VALUE_TEST_STRING_LOWERCASE, inputs = inputs, diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt index 39414c42791..867da17b125 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationActiveTimeControllerTest.kt @@ -223,7 +223,7 @@ class ExplorationActiveTimeControllerTest { fun testStopTimer_beforeStarting_isFailure() { setUpTestApplicationComponent() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { stopExploration() } assertThat(exception) diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt index ed37c3bc9b8..fc2985ec84e 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt @@ -165,7 +165,7 @@ class ExplorationProgressControllerTest { @Test fun testGetCurrentState_noExploration_throwsException() { // Can't retrieve the current state until the play session is started. - assertThrows(UninitializedPropertyAccessException::class) { + assertThrows() { explorationProgressController.getCurrentState() } } diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/testing/FakeExplorationRetrieverTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/testing/FakeExplorationRetrieverTest.kt index ae53ac8a2e0..6d8ed9c82fa 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/testing/FakeExplorationRetrieverTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/testing/FakeExplorationRetrieverTest.kt @@ -58,7 +58,7 @@ class FakeExplorationRetrieverTest { @Test fun testLoadExploration_noProxySet_fakeExpId_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runBlocking { fakeExplorationRetriever.loadExploration("fake_id") } } @@ -83,7 +83,7 @@ class FakeExplorationRetrieverTest { expIdToLoad = TEST_EXPLORATION_ID_2, expIdToLoadInstead = "fake_id" ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runBlocking { fakeExplorationRetriever.loadExploration(TEST_EXPLORATION_ID_2) } } @@ -120,7 +120,7 @@ class FakeExplorationRetrieverTest { expIdToLoad = "fake_id", expIdToLoadInstead = "other_fake_id" ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runBlocking { fakeExplorationRetriever.loadExploration("fake_id") } } @@ -133,7 +133,7 @@ class FakeExplorationRetrieverTest { expIdToLoad = TEST_EXPLORATION_ID_2, expIdToLoadInstead = TEST_EXPLORATION_ID_5 ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runBlocking { fakeExplorationRetriever.loadExploration("fake_id") } } @@ -175,7 +175,7 @@ class FakeExplorationRetrieverTest { ) fakeExplorationRetriever.clearExplorationProxy("fake_id") - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runBlocking { fakeExplorationRetriever.loadExploration("fake_id") } } diff --git a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerProdImplTest.kt b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerProdImplTest.kt index faa4e98c9f2..c66cc01efe6 100644 --- a/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerProdImplTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/hintsandsolution/HintHandlerProdImplTest.kt @@ -976,7 +976,7 @@ class HintHandlerProdImplTest { val state = expWithHintsAndSolution.getInitialState() hintHandler.startWatchingForHintsInNewStateSync(state) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewHintSync(hintIndex = 0) } @@ -1157,7 +1157,7 @@ class HintHandlerProdImplTest { hintHandler.startWatchingForHintsInNewStateSync(state) triggerAndRevealFirstHint() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewHintSync(hintIndex = 0) } @@ -1172,7 +1172,7 @@ class HintHandlerProdImplTest { triggerAndRevealFirstHint() triggerAndRevealSecondHint() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewHintSync(hintIndex = 0) } @@ -1188,7 +1188,7 @@ class HintHandlerProdImplTest { triggerAndRevealSecondHint() triggerAndRevealSolution() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewHintSync(hintIndex = 0) } @@ -1203,7 +1203,7 @@ class HintHandlerProdImplTest { val state = expWithHintsAndSolution.getInitialState() hintHandler.startWatchingForHintsInNewStateSync(state) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewSolutionSync() } @@ -1217,7 +1217,7 @@ class HintHandlerProdImplTest { hintHandler.startWatchingForHintsInNewStateSync(state) triggerFirstHint() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewSolutionSync() } @@ -1231,7 +1231,7 @@ class HintHandlerProdImplTest { hintHandler.startWatchingForHintsInNewStateSync(state) triggerAndRevealFirstHint() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewSolutionSync() } @@ -1247,7 +1247,7 @@ class HintHandlerProdImplTest { triggerAndRevealFirstHint() triggerAndRevealSecondHint() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewSolutionSync() } @@ -1344,7 +1344,7 @@ class HintHandlerProdImplTest { triggerAndRevealSecondHint() triggerAndRevealSolution() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { hintHandler.viewSolutionSync() } diff --git a/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt index 098fcde27de..30467ee6263 100644 --- a/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/locale/LocaleControllerTest.kt @@ -775,7 +775,7 @@ class LocaleControllerTest { @Test fun testSetAsDefault_customLocaleImpl_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { localeController.setAsDefault(mockDisplayLocale, Configuration()) } diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt index 6c30c8200d5..9e2178fc924 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/LoggingIdentifierControllerTest.kt @@ -54,7 +54,6 @@ import org.robolectric.annotation.LooperMode import java.io.File import java.io.FileOutputStream import java.lang.IllegalStateException -import java.util.Random import javax.inject.Inject import javax.inject.Singleton @@ -79,17 +78,6 @@ class LoggingIdentifierControllerTest { setUpTestApplicationComponent() } - @Test - fun testCreateLearnerId_verifyCreatesCorrectRandomValue() { - val randomLearnerId = loggingIdentifierController.createLearnerId() - - val testLearnerId = machineLocale.run { - "%08x".formatForMachines(Random(TestLoggingIdentifierModule.applicationIdSeed).nextInt()) - } - assertThat(randomLearnerId).isEqualTo(testLearnerId) - assertThat(randomLearnerId.length).isEqualTo(8) - } - @Test fun testCreateLearnerId_twice_bothAreDifferent() { val learnerId1 = loggingIdentifierController.createLearnerId() @@ -106,7 +94,7 @@ class LoggingIdentifierControllerTest { val installationId = monitorFactory.waitForNextSuccessfulResult(loggingIdentifierController.getInstallationId()) - assertThat(installationId).isEqualTo("bc1f80ab5d8c") + assertThat(installationId).isEqualTo("1d079efe67ee") assertThat(installationId.length).isEqualTo(12) } @@ -119,7 +107,7 @@ class LoggingIdentifierControllerTest { monitorFactory.waitForNextSuccessfulResult(loggingIdentifierController.getInstallationId()) // The same value should return for the second instance of the controller. - assertThat(installationId).isEqualTo("bc1f80ab5d8c") + assertThat(installationId).isEqualTo("1d079efe67ee") } @Test @@ -137,7 +125,7 @@ class LoggingIdentifierControllerTest { fun testFetchInstallationId_initialAppState_returnsNewInstallationIdValue() { val installationId = fetchSuccessfulAsyncValue(loggingIdentifierController::fetchInstallationId) - assertThat(installationId).isEqualTo("bc1f80ab5d8c") + assertThat(installationId).isEqualTo("1d079efe67ee") assertThat(installationId?.length).isEqualTo(12) } @@ -149,7 +137,7 @@ class LoggingIdentifierControllerTest { val installationId = fetchSuccessfulAsyncValue(loggingIdentifierController::fetchInstallationId) // The same value should return for the second instance of the controller. - assertThat(installationId).isEqualTo("bc1f80ab5d8c") + assertThat(installationId).isEqualTo("1d079efe67ee") } @Test @@ -167,7 +155,7 @@ class LoggingIdentifierControllerTest { val sessionIdProvider = loggingIdentifierController.getSessionId() val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) - assertThat(sessionId).isEqualTo("1c46e9d5-5902-311a-bbba-a75973c3ccd2") + assertThat(sessionId).isEqualTo("4d0a66f3-82b6-3aa9-8f61-140bdd5f49d3") } @Test @@ -178,7 +166,7 @@ class LoggingIdentifierControllerTest { // The second call should return the same ID (since the ID doesn't automatically change). val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) - assertThat(sessionId).isEqualTo("1c46e9d5-5902-311a-bbba-a75973c3ccd2") + assertThat(sessionId).isEqualTo("4d0a66f3-82b6-3aa9-8f61-140bdd5f49d3") } @Test @@ -186,7 +174,7 @@ class LoggingIdentifierControllerTest { val sessionIdFlow = loggingIdentifierController.getSessionIdFlow() val sessionId = sessionIdFlow.waitForLatestValue() - assertThat(sessionId).isEqualTo("1c46e9d5-5902-311a-bbba-a75973c3ccd2") + assertThat(sessionId).isEqualTo("4d0a66f3-82b6-3aa9-8f61-140bdd5f49d3") } @Test @@ -197,7 +185,7 @@ class LoggingIdentifierControllerTest { // The second call should return the same ID (since the ID doesn't automatically change). val sessionId = sessionIdFlow.waitForLatestValue() - assertThat(sessionId).isEqualTo("1c46e9d5-5902-311a-bbba-a75973c3ccd2") + assertThat(sessionId).isEqualTo("4d0a66f3-82b6-3aa9-8f61-140bdd5f49d3") } @Test @@ -209,7 +197,7 @@ class LoggingIdentifierControllerTest { // The session ID should be changed since updateSessionId() was called. val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) - assertThat(sessionId).isEqualTo("8808493e-6576-3e26-9cbf-d1008051b253") + assertThat(sessionId).isEqualTo("59aea8d4-af4b-3249-b889-dfeba06d0495") } @Test @@ -223,7 +211,7 @@ class LoggingIdentifierControllerTest { // The existing provider should've been notified of the changed session ID. val sessionId = monitor.ensureNextResultIsSuccess() - assertThat(sessionId).isEqualTo("8808493e-6576-3e26-9cbf-d1008051b253") + assertThat(sessionId).isEqualTo("59aea8d4-af4b-3249-b889-dfeba06d0495") } @Test @@ -238,7 +226,7 @@ class LoggingIdentifierControllerTest { // The session ID should be changed yet again due to updateSessionId() being called twice. val sessionId = monitorFactory.waitForNextSuccessfulResult(sessionIdProvider) - assertThat(sessionId).isEqualTo("8aeabb00-af70-39e4-89b3-c47c9900ec4f") + assertThat(sessionId).isEqualTo("8cbd31f7-bb52-3129-9fac-78dcb5cb857a") } @Test @@ -250,7 +238,7 @@ class LoggingIdentifierControllerTest { // The session ID should be changed since updateSessionId() was called. val sessionId = sessionIdFlow.waitForLatestValue() - assertThat(sessionId).isEqualTo("8808493e-6576-3e26-9cbf-d1008051b253") + assertThat(sessionId).isEqualTo("59aea8d4-af4b-3249-b889-dfeba06d0495") } @Test @@ -262,7 +250,7 @@ class LoggingIdentifierControllerTest { testCoroutineDispatchers.runCurrent() // The current value of the exist flow should be changed now since the session ID was updated. - assertThat(sessionIdFlow.value).isEqualTo("8808493e-6576-3e26-9cbf-d1008051b253") + assertThat(sessionIdFlow.value).isEqualTo("59aea8d4-af4b-3249-b889-dfeba06d0495") } private fun writeFileCache(cacheName: String, value: T) { diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterTest.kt index 1641eb00223..adf3376b77d 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotterTest.kt @@ -426,7 +426,7 @@ class CpuPerformanceSnapshotterTest { @Test fun testSnapshotter_initializeOnce_initializeAgain_throwsErrorOnReinitialization() { cpuPerformanceSnapshotter.initialiseSnapshotter() - val exception = assertThrows(IllegalArgumentException::class) { + val exception = assertThrows() { cpuPerformanceSnapshotter.initialiseSnapshotter() } diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt index 462dd3f04ad..3cc8a0e848a 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt @@ -86,7 +86,7 @@ class LearnerAnalyticsLoggerTest { private const val TEST_STORY_ID = "test_story_id" private const val TEST_EXP_5_STATE_THREE_NAME = "NumericExpressionInput.IsEquivalentTo" private const val TEST_EXP_5_STATE_FOUR_NAME = "AlgebraicExpressionInput.MatchesExactlyWith" - private const val DEFAULT_INITIAL_SESSION_ID = "e6eacc69-e636-3c90-ba29-32bf3dd17161" + private const val DEFAULT_INITIAL_SESSION_ID = "ab4532d6-476c-3727-bc5a-ad84e5dae60f" } @Inject diff --git a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt index 62733f8119c..6d782dbc3bc 100644 --- a/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/profile/ProfileManagementControllerTest.kt @@ -156,7 +156,7 @@ class ProfileManagementControllerTest { val profileDatabase = readProfileDatabase() val profile = profileDatabase.profilesMap[0]!! - assertThat(profile.learnerId).isEqualTo("bb1ad573") + assertThat(profile.learnerId).isEqualTo("26504347") } @Test @@ -255,7 +255,7 @@ class ProfileManagementControllerTest { val profileProvider = profileManagementController.getProfile(profileId) val profile = monitorFactory.waitForNextSuccessfulResult(profileProvider) - assertThat(profile.learnerId).isEqualTo("68fb0e6f") + assertThat(profile.learnerId).isEqualTo("a625db55") } @Test @@ -430,7 +430,7 @@ class ProfileManagementControllerTest { val learnerId = fetchSuccessfulAsyncValue(profileManagementController::fetchCurrentLearnerId) - assertThat(learnerId).isEqualTo("19b89cd8") + assertThat(learnerId).isEqualTo("02308fa0") } @Test @@ -465,7 +465,7 @@ class ProfileManagementControllerTest { profileManagementController.fetchLearnerId(PROFILE_ID_2) } - assertThat(learnerId).isEqualTo("68fb0e6f") + assertThat(learnerId).isEqualTo("a625db55") } @Test diff --git a/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt index f5aad0432a1..0c686230064 100644 --- a/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/question/QuestionAssessmentProgressControllerTest.kt @@ -134,7 +134,7 @@ class QuestionAssessmentProgressControllerTest { setUpTestApplicationWithSeed(questionSeed = 0) // Can't retrieve the current question until the training session is started. - assertThrows(UninitializedPropertyAccessException::class) { + assertThrows() { questionAssessmentProgressController.getCurrentQuestion() } } diff --git a/model/src/main/proto/BUILD.bazel b/model/src/main/proto/BUILD.bazel index a168e981191..e512512b10f 100644 --- a/model/src/main/proto/BUILD.bazel +++ b/model/src/main/proto/BUILD.bazel @@ -273,7 +273,10 @@ java_lite_proto_library( oppia_proto_library( name = "feedback_reporting_proto", srcs = ["feedback_reporting.proto"], - deps = [":profile_proto"], + deps = [ + ":languages_proto", + ":profile_proto", + ], ) java_lite_proto_library( diff --git a/scripts/src/java/org/oppia/android/scripts/testing/TestGitRepository.kt b/scripts/src/java/org/oppia/android/scripts/testing/TestGitRepository.kt index 61d5c055992..2de94e3fc1f 100644 --- a/scripts/src/java/org/oppia/android/scripts/testing/TestGitRepository.kt +++ b/scripts/src/java/org/oppia/android/scripts/testing/TestGitRepository.kt @@ -19,20 +19,29 @@ class TestGitRepository( private val commandExecutor: CommandExecutor ) { private val rootDirectory by lazy { temporaryRootFolder.root } + private val gitDirectory: File get() = File(rootDirectory, ".git") + private val userEmail: String? + get() = maybeExecuteGitCommand("config", "--local", "--get", "user.email")?.joinOutput()?.trim() + private val userName: String? + get() = maybeExecuteGitCommand("config", "--local", "--get", "user.name")?.joinOutput()?.trim() /** Creates the repository using git init. */ fun init() { + verifyNotInGitRepository() executeSuccessfulGitCommand("init") } /** Sets the user's [email] and [name] using git config. */ fun setUser(email: String, name: String) { - executeSuccessfulGitCommand("config", "user.email", email) - executeSuccessfulGitCommand("config", "user.name", name) + verifyInGitRepository() + verifyUserIsNotSet() + executeSuccessfulGitCommand("config", "--local", "user.email", email) + executeSuccessfulGitCommand("config", "--local", "user.name", name) } /** Creates a new branch with the specified name, and switches to it. */ fun checkoutNewBranch(branchName: String) { + verifyInGitRepository() executeSuccessfulGitCommand("checkout", "-b", branchName) } @@ -42,6 +51,7 @@ class TestGitRepository( * This does not perform a commit. See [commit] for actually committing the change. */ fun stageFileForCommit(file: File) { + verifyInGitRepository() executeSuccessfulGitCommand("add", file.toRelativeString(rootDirectory)) } @@ -57,6 +67,7 @@ class TestGitRepository( * This does not perform a commit. See [commit] for actually committing the change. */ fun removeFileForCommit(file: File) { + verifyInGitRepository() executeSuccessfulGitCommand("rm", file.toRelativeString(rootDirectory)) } @@ -67,6 +78,7 @@ class TestGitRepository( * This does not perform a commit. See [commit] for actually committing the change. */ fun moveFileForCommit(oldFile: File, newFile: File) { + verifyInGitRepository() executeSuccessfulGitCommand( "mv", oldFile.toRelativeString(rootDirectory), @@ -81,25 +93,59 @@ class TestGitRepository( * @param allowEmpty whether to allow empty commits (i.e. committing with no staged files) */ fun commit(message: String, allowEmpty: Boolean = false) { + verifyInGitRepository() + verifyUserIsSet() val arguments = mutableListOf("commit", "-m", message) if (allowEmpty) arguments += "--allow-empty" executeSuccessfulGitCommand(*arguments.toTypedArray()) } /** Returns the result of git status. */ - fun status(): String { - return commandExecutor.executeCommand(rootDirectory, "git", "status").output.joinOutputString() + fun status(checkForGitRepository: Boolean = true): String { + if (checkForGitRepository) verifyInGitRepository() + return executeGitCommand("status").joinOutput() } - private fun executeSuccessfulGitCommand(vararg arguments: String) { - verifySuccessfulCommand(commandExecutor.executeCommand(rootDirectory, "git", *arguments)) - } + private fun executeGitCommand(vararg arguments: String): CommandResult = + commandExecutor.executeCommand(rootDirectory, "git", *arguments) + + private fun maybeExecuteGitCommand(vararg arguments: String): CommandResult? = + executeGitCommand(*arguments).takeIf { it.exitCode == 0 } + + private fun executeSuccessfulGitCommand(vararg arguments: String) = + verifySuccessfulCommand(executeGitCommand(*arguments)) private fun verifySuccessfulCommand(result: CommandResult) { - assertWithMessage("Output: ${result.output.joinOutputString()}") + assertWithMessage("Output: ${result.joinOutput()}") .that(result.exitCode) .isEqualTo(0) } - private fun List.joinOutputString(): String = joinToString(separator = "\n") { " $it" } + private fun verifyInGitRepository() { + failUnless(gitDirectory.exists()) { "Not operating in an initialized Git repository." } + } + + private fun verifyNotInGitRepository() { + failUnless(!gitDirectory.exists()) { "Git repository is already initialized." } + } + + private fun verifyUserIsNotSet() { + verifyIsNotSet(name = "User email", userEmail) + verifyIsNotSet(name = "User name", userName) + } + + private fun verifyUserIsSet() { + failUnless(userEmail != null) { "User email has not yet been set." } + failUnless(userName != null) { "User name has not yet been set." } + } + + private fun verifyIsNotSet(name: String, value: String?) { + failUnless(value == null) { "$name has already been set: $value." } + } + + private fun failUnless(condition: Boolean, lazyMessage: () -> String) { + if (!condition) throw AssertionError(lazyMessage()) + } + + private fun CommandResult.joinOutput(): String = output.joinToString(separator = "\n") { " $it" } } diff --git a/scripts/src/javatests/org/oppia/android/scripts/build/FilterPerLanguageResourcesTest.kt b/scripts/src/javatests/org/oppia/android/scripts/build/FilterPerLanguageResourcesTest.kt index 8c217740d10..511b07f37e9 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/build/FilterPerLanguageResourcesTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/build/FilterPerLanguageResourcesTest.kt @@ -86,21 +86,21 @@ class FilterPerLanguageResourcesTest { @Test fun testUtility_noArgs_failsWithUsageString() { - val error = assertThrows(IllegalArgumentException::class) { runScript() } + val error = assertThrows() { runScript() } assertThat(error).hasMessageThat().contains(USAGE_STRING) } @Test fun testUtility_oneArg_failsWithUsageString() { - val error = assertThrows(IllegalArgumentException::class) { runScript("first_file.zip") } + val error = assertThrows() { runScript("first_file.zip") } assertThat(error).hasMessageThat().contains(USAGE_STRING) } @Test fun testUtility_threeArgs_failsWithUsageString() { - val error = assertThrows(IllegalArgumentException::class) { + val error = assertThrows() { runScript( tempFolder.getFilePath("input.zip"), tempFolder.getFilePath("output.zip"), "extra_param" ) @@ -114,7 +114,7 @@ class FilterPerLanguageResourcesTest { // Create an empty zip file. ZipOutputStream(File(tempFolder.root, "input.zip").outputStream()).close() - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { runScript(tempFolder.getFilePath("input.zip"), tempFolder.getFilePath("output.zip")) } @@ -129,7 +129,7 @@ class FilterPerLanguageResourcesTest { ResourceTable.getDefaultInstance().writeTo(outputStream) } - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { runScript(tempFolder.getFilePath("input.zip"), tempFolder.getFilePath("output.zip")) } @@ -147,7 +147,7 @@ class FilterPerLanguageResourcesTest { supportedLanguages = SUPPORTED_LANGUAGES_EN ) - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { runScript(tempFolder.getFilePath("input.zip"), tempFolder.getFilePath("output.zip")) } diff --git a/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt b/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt index 424d22b661f..5d197b04615 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt @@ -70,7 +70,7 @@ class TransformAndroidManifestTest { fun testUtility_noArgs_failsWithUsageString() { initializeEmptyGitRepository() - val exception = assertThrows(IllegalStateException::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(USAGE_STRING) } @@ -79,7 +79,7 @@ class TransformAndroidManifestTest { fun testUtility_oneArg_failsWithUsageString() { initializeEmptyGitRepository() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } @@ -91,7 +91,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript(tempFolder.root.absolutePath, manifestFile.absolutePath) } @@ -103,7 +103,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -119,7 +119,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -136,7 +136,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -154,7 +154,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -173,7 +173,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -193,7 +193,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -214,7 +214,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -236,7 +236,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -258,7 +258,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, @@ -280,7 +280,7 @@ class TransformAndroidManifestTest { initializeEmptyGitRepository() val manifestFile = tempFolder.newFile(TEST_MANIFEST_FILE_NAME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( "nowhere", manifestFile.absolutePath, @@ -301,7 +301,7 @@ class TransformAndroidManifestTest { fun testUtility_allArgs_manifestDoesNotExist_failsWithError() { initializeEmptyGitRepository() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, "fake_manifest_file", @@ -325,7 +325,7 @@ class TransformAndroidManifestTest { writeText(TEST_MANIFEST_CONTENT_WITHOUT_VERSIONS_AND_APPLICATION) } - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript( tempFolder.root.absolutePath, manifestFile.absolutePath, diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel index cb9eafb6d21..3160447f15f 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel @@ -8,7 +8,7 @@ kt_jvm_test( name = "ComputeAffectedTestsTest", size = "large", srcs = ["ComputeAffectedTestsTest.kt"], - shard_count = 4, + shard_count = 8, deps = [ "//scripts/src/java/org/oppia/android/scripts/ci:compute_affected_tests_lib", "//scripts/src/java/org/oppia/android/scripts/common:proto_string_encoder", diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt index 654e42425c8..5bbdc432d62 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt @@ -57,12 +57,12 @@ class ComputeAffectedTestsTest { // Print the status of the git repository to help with debugging in the cases of test failures // and to help manually verify the expect git state at the end of each test. println("git status (at end of test):") - println(testGitRepository.status()) + println(testGitRepository.status(checkForGitRepository = false)) } @Test fun testUtility_noArguments_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { main(arrayOf()) } + val exception = assertThrows() { main(arrayOf()) } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -72,7 +72,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_oneArgument_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { main(arrayOf("first")) } + val exception = assertThrows() { main(arrayOf("first")) } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -82,7 +82,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_twoArguments_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { main(arrayOf("first", "second")) } + val exception = assertThrows() { main(arrayOf("first", "second")) } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -92,7 +92,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_threeArguments_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { + val exception = assertThrows() { main(arrayOf("first", "second", "third")) } @@ -104,7 +104,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_directoryRootDoesNotExist_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { main(arrayOf("fake", "alsofake", "andstillfake", "compute_all_tests=false")) } @@ -113,7 +113,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_invalid_lastArgument_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { main(arrayOf("fake", "alsofake", "andstillfake", "compute_all_testss=false")) } @@ -123,7 +123,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_invalid_lastArgumentValue_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { main(arrayOf("fake", "alsofake", "andstillfake", "compute_all_tests=blah")) } @@ -133,7 +133,7 @@ class ComputeAffectedTestsTest { @Test fun testUtility_emptyDirectory_throwsException() { - val exception = assertThrows(IllegalStateException::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains("run from the workspace's root directory") } diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/RetrieveAffectedTestsTest.kt b/scripts/src/javatests/org/oppia/android/scripts/ci/RetrieveAffectedTestsTest.kt index d43a7055f51..e449b856a6f 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/RetrieveAffectedTestsTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/RetrieveAffectedTestsTest.kt @@ -45,7 +45,7 @@ class RetrieveAffectedTestsTest { @Test fun testUtility_noArguments_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { runScript() } + val exception = assertThrows() { runScript() } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -55,7 +55,7 @@ class RetrieveAffectedTestsTest { @Test fun testUtility_oneArgument_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { runScript("arg1") } + val exception = assertThrows() { runScript("arg1") } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -65,7 +65,7 @@ class RetrieveAffectedTestsTest { @Test fun testUtility_twoArguments_printsUsageStringAndExits() { - val exception = assertThrows(SecurityException::class) { runScript("arg1", "arg2") } + val exception = assertThrows() { runScript("arg1", "arg2") } // Bazel catches the System.exit() call and throws a SecurityException. This is a bit hacky way // to verify that System.exit() is called, but it's helpful. @@ -75,7 +75,7 @@ class RetrieveAffectedTestsTest { @Test fun testUtility_invalidBase64_throwsException() { - assertThrows(IllegalArgumentException::class) { runScript("badbase64", "file1", "file2") } + assertThrows() { runScript("badbase64", "file1", "file2") } } @Test diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel index e47fc741ab6..bceb5cfe864 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel @@ -8,6 +8,7 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_test") kt_jvm_test( name = "BazelClientTest", srcs = ["BazelClientTest.kt"], + shard_count = 4, deps = [ "//scripts/src/java/org/oppia/android/scripts/common:bazel_client", "//scripts/src/java/org/oppia/android/scripts/testing:test_bazel_workspace", diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt index f2e7914682c..07aa4d4134c 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt @@ -48,7 +48,7 @@ class BazelClientTest { fun testRetrieveTestTargets_emptyFolder_fails() { val bazelClient = BazelClient(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { bazelClient.retrieveAllTestTargets() } @@ -62,7 +62,7 @@ class BazelClientTest { val bazelClient = BazelClient(tempFolder.root) testBazelWorkspace.initEmptyWorkspace() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { bazelClient.retrieveAllTestTargets() } diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt index e04c0954b85..78dc945dff6 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt @@ -37,7 +37,7 @@ class CommandExecutorImplTest { fun testExecute_echo_invalidDirectory_throwsException() { val commandExecutor = CommandExecutorImpl() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { commandExecutor.executeCommand(File("invaliddirectory"), "echo", "value") } @@ -53,7 +53,7 @@ class CommandExecutorImplTest { // Produce a large output so that echo takes a bit longer to reduce the likelihood of this test // flaking on faster machines. val largeOutput = "a".repeat(100_000) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { commandExecutor.executeCommand(tempFolder.root, "echo", largeOutput) } @@ -65,7 +65,7 @@ class CommandExecutorImplTest { fun testExecute_nonexistentCommand_throwsException() { val commandExecutor = CommandExecutorImpl() - val exception = assertThrows(IOException::class) { + val exception = assertThrows() { commandExecutor.executeCommand(tempFolder.root, "commanddoesnotexist") } diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt index 9362d7dd006..5cbda509373 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt @@ -37,14 +37,14 @@ class GitClientTest { // Print the status of the git repository to help with debugging in the cases of test failures // and to help manually verify the expect git state at the end of each test. println("git status (at end of test):") - println(testGitRepository.status()) + println(testGitRepository.status(checkForGitRepository = false)) } @Test fun testCurrentCommit_forNonRepository_throwsException() { val gitClient = GitClient(tempFolder.root, "develop") - val exception = assertThrows(IllegalStateException::class) { gitClient.currentCommit } + val exception = assertThrows() { gitClient.currentCommit } assertThat(exception).hasMessageThat().contains("Expected non-zero exit code") assertThat(exception).hasMessageThat().ignoringCase().contains("not a git repository") @@ -80,7 +80,7 @@ class GitClientTest { fun testCurrentBranch_forNonRepository_throwsException() { val gitClient = GitClient(tempFolder.root, "develop") - val exception = assertThrows(IllegalStateException::class) { gitClient.currentBranch } + val exception = assertThrows() { gitClient.currentBranch } assertThat(exception).hasMessageThat().contains("Expected non-zero exit code") assertThat(exception).hasMessageThat().ignoringCase().contains("not a git repository") diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/ProtoStringEncoderTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/ProtoStringEncoderTest.kt index b03c106500a..bed9db19a1b 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/ProtoStringEncoderTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/ProtoStringEncoderTest.kt @@ -34,14 +34,14 @@ class ProtoStringEncoderTest { @Test fun testDecode_emptyString_throwsException() { - assertThrows(EOFException::class) { + assertThrows() { TestMessage.getDefaultInstance().mergeFromCompressedBase64(base64 = "") } } @Test fun testDecode_badString_throwsException() { - assertThrows(ZipException::class) { + assertThrows() { TestMessage.getDefaultInstance().mergeFromCompressedBase64(base64 = "asdf") } } diff --git a/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt index 9a7b61faa6a..58b99cf4db5 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt @@ -281,7 +281,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -357,7 +357,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -387,7 +387,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -416,7 +416,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -442,7 +442,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -468,7 +468,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -495,7 +495,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -522,7 +522,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -550,7 +550,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -577,7 +577,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -604,7 +604,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -632,7 +632,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -668,7 +668,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -709,7 +709,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -755,7 +755,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -800,7 +800,7 @@ class KdocValidityCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -879,7 +879,7 @@ class KdocValidityCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -913,7 +913,7 @@ class KdocValidityCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } diff --git a/scripts/src/javatests/org/oppia/android/scripts/label/AccessibilityLabelCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/label/AccessibilityLabelCheckTest.kt index a1410b3ead2..900140e93f7 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/label/AccessibilityLabelCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/label/AccessibilityLabelCheckTest.kt @@ -92,7 +92,7 @@ class AccessibilityLabelCheckTest { val manifestFile = tempFolder.newFile("testfiles/$tempFileRelativePath") manifestFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", @@ -134,7 +134,7 @@ class AccessibilityLabelCheckTest { val manifestFile = tempFolder.newFile("testfiles/$tempFileRelativePath") manifestFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", @@ -244,7 +244,7 @@ class AccessibilityLabelCheckTest { appManifestFile.writeText(testContent1) splashManifestFile.writeText(testContent2) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", @@ -308,7 +308,7 @@ class AccessibilityLabelCheckTest { appManifestFile.writeText(testContent1) splashManifestFile.writeText(testContent2) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", @@ -393,7 +393,7 @@ class AccessibilityLabelCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", @@ -436,7 +436,7 @@ class AccessibilityLabelCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main( retrieveTestFilesDirectoryPath(), "${tempFolder.root}/$pathToProtoBinary", diff --git a/scripts/src/javatests/org/oppia/android/scripts/license/LicenseTextsCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/license/LicenseTextsCheckTest.kt index 8a70436c6c7..baf034a9095 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/license/LicenseTextsCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/license/LicenseTextsCheckTest.kt @@ -41,7 +41,7 @@ class LicenseTextsCheckTest { val thirdPartyDepsXmlFile = tempFolder.newFile("values/third_party_dependencies.xml") thirdPartyDepsXmlFile.writeText(WARNING_COMMENT) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(arrayOf()) } @@ -53,7 +53,7 @@ class LicenseTextsCheckTest { val thirdPartyDepsXmlFile = tempFolder.newFile("values/third_party_dependencies.xml") thirdPartyDepsXmlFile.writeText("") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(arrayOf("${tempFolder.root}/values/third_party_dependencies.xml")) } @@ -72,7 +72,7 @@ class LicenseTextsCheckTest { """.trimIndent() ) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(arrayOf("${tempFolder.root}/values/third_party_dependencies.xml")) } @@ -110,7 +110,7 @@ class LicenseTextsCheckTest { @Test fun testLicenseTexsCheck_xmlFileNotPresent_checkFailsWithFileNotFoundException() { val pathToThirdPartyDepsXml = "${tempFolder.root}/values/third_party_dependencies.xml" - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(arrayOf("${tempFolder.root}/values/third_party_dependencies.xml")) } diff --git a/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt index f30b261f53a..5fdc807e3db 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt @@ -110,7 +110,7 @@ class MavenDependenciesListCheckTest { val coordsList = listOf(DATA_BINDING_DEP, FIREBASE_ANALYTICS_DEP) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -186,7 +186,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -250,7 +250,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -326,7 +326,7 @@ class MavenDependenciesListCheckTest { val coordsList = listOf(GLIDE_DEP) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -405,7 +405,7 @@ class MavenDependenciesListCheckTest { val coordsList = listOf(GLIDE_DEP) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -481,7 +481,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -559,7 +559,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironmentWithUpdatedFirebaseDependency(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -637,7 +637,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -770,7 +770,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -819,7 +819,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor @@ -874,7 +874,7 @@ class MavenDependenciesListCheckTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, commandExecutor diff --git a/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt b/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt index 6d63a6e9c6d..4507d76a5dc 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt @@ -96,7 +96,7 @@ class GenerateMavenDependenciesListTest { val coordsList = listOf(DEP_WITH_SCRAPABLE_LICENSE, DEP_WITH_DIRECT_LINK_ONLY_LICENSE) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -180,7 +180,7 @@ class GenerateMavenDependenciesListTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -204,7 +204,7 @@ class GenerateMavenDependenciesListTest { val coordsList = listOf(DEP_WITH_DIRECT_LINK_ONLY_LICENSE) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -246,7 +246,7 @@ class GenerateMavenDependenciesListTest { val coordsList = listOf(DEP_WITH_SCRAPABLE_AND_EXTRACTED_COPY_LICENSES) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -313,7 +313,7 @@ class GenerateMavenDependenciesListTest { val coordsList = listOf(DEP_WITH_INVALID_LINKS) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -355,7 +355,7 @@ class GenerateMavenDependenciesListTest { val coordsList = listOf(DEP_WITH_NO_LICENSE) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -614,7 +614,7 @@ class GenerateMavenDependenciesListTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -790,7 +790,7 @@ class GenerateMavenDependenciesListTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -915,7 +915,7 @@ class GenerateMavenDependenciesListTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor @@ -1028,7 +1028,7 @@ class GenerateMavenDependenciesListTest { ) setUpBazelEnvironment(coordsList) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, commandExecutor diff --git a/scripts/src/javatests/org/oppia/android/scripts/maven/RetrieveLicenseTextsTest.kt b/scripts/src/javatests/org/oppia/android/scripts/maven/RetrieveLicenseTextsTest.kt index 6be3f9c0d71..d889d6ede2b 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/maven/RetrieveLicenseTextsTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/maven/RetrieveLicenseTextsTest.kt @@ -63,7 +63,7 @@ class RetrieveLicenseTextsTest { @Test fun testScript_oneArgument_printsUsageStringAndThrowsException() { - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { RetrieveLicenseTexts(mockLicenseFetcher).main(arrayOf()) } @@ -73,7 +73,7 @@ class RetrieveLicenseTextsTest { @Test fun testScript_oneArguments_printsUsageStringAndThrowsException() { - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { RetrieveLicenseTexts(mockLicenseFetcher).main( arrayOf( "${tempFolder.root}/values" @@ -92,7 +92,7 @@ class RetrieveLicenseTextsTest { val pbFile = tempFolder.newFile("scripts/assets/maven_dependencies.pb") pbFile.outputStream().use { mavenDependencyList.writeTo(it) } - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { RetrieveLicenseTexts(mockLicenseFetcher).main( arrayOf( "${tempFolder.root}/values", @@ -111,7 +111,7 @@ class RetrieveLicenseTextsTest { val pbFile = tempFolder.newFile("scripts/assets/maven_dependencies.pb") pbFile.outputStream().use { mavenDependencyList.writeTo(it) } - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { RetrieveLicenseTexts(mockLicenseFetcher).main( arrayOf( "${tempFolder.root}/values", @@ -141,7 +141,7 @@ class RetrieveLicenseTextsTest { val pbFile = tempFolder.newFile("scripts/assets/maven_dependencies.pb") pbFile.outputStream().use { mavenDependencyList.writeTo(it) } - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { RetrieveLicenseTexts(mockLicenseFetcher).main( arrayOf( "${tempFolder.root}/values", diff --git a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt index ae1d4fa60ff..39550f0f8ae 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -257,7 +257,7 @@ class RegexPatternValidationCheckTest { val tempFile = tempFolder.newFile("testfiles/data/src/main/TestActivity.kt") tempFile.writeText(requiredContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -287,7 +287,7 @@ class RegexPatternValidationCheckTest { tempFolder.newFolder("testfiles", "app", "src", "main", "res", "values", "subdir") tempFolder.newFile("testfiles/app/src/main/res/values/subdir/strings.xml") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -307,7 +307,7 @@ class RegexPatternValidationCheckTest { tempFolder.newFolder("testfiles", "domain", "src", "main", "res", "drawable", "subdir") tempFolder.newFile("testfiles/domain/src/main/res/drawable/subdir/example.png") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -337,7 +337,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -357,7 +357,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -377,7 +377,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -397,7 +397,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -417,7 +417,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -437,7 +437,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -457,7 +457,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -477,7 +477,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -497,7 +497,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -517,7 +517,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -537,7 +537,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -557,7 +557,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -577,7 +577,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -597,7 +597,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -617,7 +617,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -637,7 +637,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -657,7 +657,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -677,7 +677,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -697,7 +697,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -717,7 +717,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -737,7 +737,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -757,7 +757,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -777,7 +777,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -797,7 +797,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -817,7 +817,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -837,7 +837,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -857,7 +857,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -877,7 +877,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -897,7 +897,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -917,7 +917,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -937,7 +937,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -957,7 +957,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -977,7 +977,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -997,7 +997,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1018,7 +1018,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1039,7 +1039,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1072,7 +1072,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/untranslated_strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1093,7 +1093,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/untranslated_strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1114,7 +1114,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1135,7 +1135,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1207,7 +1207,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1250,7 +1250,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.java" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1285,7 +1285,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1317,7 +1317,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1345,7 +1345,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1370,7 +1370,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1400,7 +1400,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1443,7 +1443,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1465,7 +1465,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1487,7 +1487,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1508,7 +1508,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeDialogFragment.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1541,7 +1541,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1571,7 +1571,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1601,7 +1601,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1622,7 +1622,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1643,7 +1643,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1669,7 +1669,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1692,7 +1692,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1713,7 +1713,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1745,7 +1745,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = "test_layout.xml" tempFolder.newFile("testfiles/$fileContainsSupportLibraryImport").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1774,7 +1774,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/test/SomeTest.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1796,7 +1796,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1817,7 +1817,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/BUILD" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1838,7 +1838,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/BUILD.bazel" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1859,7 +1859,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1881,7 +1881,7 @@ class RegexPatternValidationCheckTest { val prohibitedFile = tempFolder.newFile("testfiles/data/src/main/TestActivity.kt") prohibitedFile.writeText(prohibitedContent + requiredContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1914,7 +1914,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -1964,7 +1964,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2012,7 +2012,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2059,7 +2059,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2123,7 +2123,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2171,7 +2171,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2218,7 +2218,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2263,7 +2263,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2311,7 +2311,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/layout/test_layout.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2381,7 +2381,7 @@ class RegexPatternValidationCheckTest { tempFolder.newFile("testfiles/$stringFilePath5").writeText(prohibitedContent) tempFolder.newFile("testfiles/$stringFilePath6").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2438,7 +2438,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2460,7 +2460,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/activity/HomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2492,7 +2492,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/activity/HomeActivityTest.kt" tempFolder.newFile("testfiles/$stringFilePath") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2528,7 +2528,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/SomeInitializer.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2553,7 +2553,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2578,7 +2578,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2603,7 +2603,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -2633,7 +2633,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2657,7 +2657,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2682,7 +2682,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2720,7 +2720,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } // Two patterns are combined in this check because they slightly overlap in affected cases (e.g. // line 2 fails due to three different checks), and one pattern is subequently needed for the @@ -2752,7 +2752,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2782,7 +2782,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2807,7 +2807,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { runScript() } + val exception = assertThrows() { runScript() } // 'Punctuation' currently assumes a period. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) diff --git a/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt index a0fc700b720..3c22ca1ac31 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt @@ -52,7 +52,7 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile1Test.kt") tempFolder.newFile("testfiles/ProdFile2.kt") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -73,7 +73,7 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile2.kt") tempFolder.newFile("testfiles/ProdFile3.kt") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -95,7 +95,7 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile3.kt") tempFolder.newFile("testfiles/ProdFile2.kt") - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } diff --git a/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt b/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt index 9bec557f4ac..00cbba1f19c 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt @@ -59,7 +59,7 @@ class TestBazelWorkspaceTest { // Verify that when initializing an empty workspace fails, an AssertionError is thrown (which // would fail for calling tests). - assertThrows(AssertionError::class) { testBazelWorkspace.initEmptyWorkspace() } + assertThrows() { testBazelWorkspace.initEmptyWorkspace() } } @Test @@ -215,7 +215,7 @@ class TestBazelWorkspaceTest { testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTestOther.kt") @@ -492,7 +492,7 @@ class TestBazelWorkspaceTest { testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { testBazelWorkspace.createTest(testName = "FirstTest") } @@ -786,7 +786,7 @@ class TestBazelWorkspaceTest { testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "FirstLib") - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { testBazelWorkspace.createLibrary(dependencyName = "FirstLib") } @@ -822,7 +822,7 @@ class TestBazelWorkspaceTest { val testBazelWorkspace = TestBazelWorkspace(tempFolder) // A non-existent test file cannot be retrieved. - assertThrows(NoSuchElementException::class) { + assertThrows() { testBazelWorkspace.retrieveTestFile(testName = "Invalid") } } @@ -844,7 +844,7 @@ class TestBazelWorkspaceTest { val testBazelWorkspace = TestBazelWorkspace(tempFolder) // A non-existent library file cannot be retrieved. - assertThrows(NoSuchElementException::class) { + assertThrows() { testBazelWorkspace.retrieveLibraryFile(dependencyName = "Invalid") } } @@ -865,7 +865,7 @@ class TestBazelWorkspaceTest { fun testRetrieveTestDependencyFile_noTest_throwsExceptionWithHelpfulMessage() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { testBazelWorkspace.retrieveTestDependencyFile(testName = "Invalid") } @@ -878,7 +878,7 @@ class TestBazelWorkspaceTest { val testBazelWorkspace = TestBazelWorkspace(tempFolder) testBazelWorkspace.createTest("ValidWithoutDep") - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { testBazelWorkspace.retrieveTestDependencyFile(testName = "ValidWithoutDep") } diff --git a/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt b/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt index 59aa28bdc84..453f17da044 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt @@ -59,11 +59,11 @@ class TestGitRepositoryTest { fun testSetUser_noGitRepository_throwsAssertionError() { val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.setUser(email = "test@oppia.org", name = "Test User") } - assertThat(error).hasMessageThat().contains("not in a git directory") + assertThat(error).hasMessageThat().contains("Not operating in an initialized Git repository.") } @Test @@ -92,11 +92,11 @@ class TestGitRepositoryTest { fun testCheckOutNewBranch_notGitRepository_throwsAssertionError() { val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.checkoutNewBranch("develop") } - assertThat(error).hasMessageThat().ignoringCase().contains("not a git repository") + assertThat(error).hasMessageThat().contains("Not operating in an initialized Git repository.") } @Test @@ -116,7 +116,7 @@ class TestGitRepositoryTest { testGitRepository.init() testGitRepository.checkoutNewBranch("develop") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.stageFileForCommit(File(tempFolder.root, "fake_file")) } @@ -188,7 +188,7 @@ class TestGitRepositoryTest { testGitRepository.init() testGitRepository.checkoutNewBranch("develop") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.stageFilesForCommit( listOf( tempFolder.newFile("new_file1"), @@ -207,7 +207,7 @@ class TestGitRepositoryTest { testGitRepository.init() testGitRepository.checkoutNewBranch("develop") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.removeFileForCommit(File(tempFolder.root, "nonexistent_file")) } @@ -221,7 +221,7 @@ class TestGitRepositoryTest { testGitRepository.checkoutNewBranch("develop") tempFolder.newFile("untracked_file") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.removeFileForCommit(File(tempFolder.root, "untracked_file")) } @@ -250,7 +250,7 @@ class TestGitRepositoryTest { testGitRepository.init() testGitRepository.checkoutNewBranch("develop") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.moveFileForCommit( File(tempFolder.root, "nonexistent_file"), File(tempFolder.root, "new_file") ) @@ -266,7 +266,7 @@ class TestGitRepositoryTest { testGitRepository.checkoutNewBranch("develop") tempFolder.newFile("untracked_file") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.moveFileForCommit( File(tempFolder.root, "untracked_file"), File(tempFolder.root, "new_file") ) @@ -304,11 +304,9 @@ class TestGitRepositoryTest { testGitRepository.checkoutNewBranch("develop") testGitRepository.stageFileForCommit(tempFolder.newFile("file_to_be_committed")) - val error = assertThrows(AssertionError::class) { - testGitRepository.commit("Commit new file.") - } + val error = assertThrows { testGitRepository.commit("Commit new file.") } - assertThat(error).hasMessageThat().contains("Please tell me who you are") + assertThat(error).hasMessageThat().contains("User email has not yet been set.") } @Test @@ -318,7 +316,7 @@ class TestGitRepositoryTest { testGitRepository.checkoutNewBranch("develop") testGitRepository.setUser(email = "test@oppia.org", name = "Test User") - val error = assertThrows(AssertionError::class) { + val error = assertThrows() { testGitRepository.commit("Attempting empty commit.", allowEmpty = false) } @@ -357,14 +355,34 @@ class TestGitRepositoryTest { } @Test - fun testStatus_noGitRepository_hasStatusWithError() { + fun testStatus_noGitRepository_doNotCheckForRepository_hasStatusWithError() { val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) - val status = testGitRepository.status() + val status = testGitRepository.status(checkForGitRepository = false) assertThat(status).ignoringCase().contains("not a git repository") } + @Test + fun testStatus_noGitRepository_checkForRepository_throwsAssertionError() { + val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) + + val error = assertThrows() { + testGitRepository.status(checkForGitRepository = true) + } + + assertThat(error).hasMessageThat().contains("Not operating in an initialized Git repository.") + } + + @Test + fun testStatus_noGitRepository_defaultCheckForRepository_throwsAssertionError() { + val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) + + val error = assertThrows() { testGitRepository.status() } + + assertThat(error).hasMessageThat().contains("Not operating in an initialized Git repository.") + } + @Test fun testStatus_onBranch_nothingStaged_statusEmpty() { val testGitRepository = TestGitRepository(tempFolder, commandExecutorInterceptor) diff --git a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueCommentCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueCommentCheckTest.kt index 6c4d5fb8a8c..2d33e0e2a60 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueCommentCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueCommentCheckTest.kt @@ -51,7 +51,7 @@ class TodoIssueCommentCheckTest { latestCommentFile.writeText(latestCommentContent) scriptFailureCommentFile.writeText(scriptFailureCommentContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(tempFolder.root.toString(), "latest_comment.txt", "script_failures.txt") } assertThat(exception).hasMessageThat().contains("NEW COMMENT SHOULD BE POSTED") @@ -80,7 +80,7 @@ class TodoIssueCommentCheckTest { latestCommentFile.writeText(latestCommentContent) scriptFailureCommentFile.writeText(scriptFailureCommentContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(tempFolder.root.toString(), "latest_comment.txt", "script_failures.txt") } assertThat(exception).hasMessageThat().contains("NEW COMMENT SHOULD BE POSTED") @@ -109,7 +109,7 @@ class TodoIssueCommentCheckTest { latestCommentFile.writeText(latestCommentContent) scriptFailureCommentFile.writeText(scriptFailureCommentContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(tempFolder.root.toString(), "latest_comment.txt", "script_failures.txt") } assertThat(exception).hasMessageThat().contains("NEW COMMENT SHOULD BE POSTED") diff --git a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueResolvedCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueResolvedCheckTest.kt index ae273159b92..4880c092ec5 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueResolvedCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoIssueResolvedCheckTest.kt @@ -105,7 +105,7 @@ class TodoIssueResolvedCheckTest { tempFile1.writeText(testContent1) tempFile2.writeText(testContent2) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(retrieveTestFilesDirectoryPath(), "169877", "abmzuyt") } @@ -149,7 +149,7 @@ class TodoIssueResolvedCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(retrieveTestFilesDirectoryPath(), "169877", "abmzuyt") } @@ -195,7 +195,7 @@ class TodoIssueResolvedCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { main(retrieveTestFilesDirectoryPath(), "169877", "abmzuyt") } val fileContentList = diff --git a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt index 23f42c53f2c..68b162340ac 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt @@ -43,7 +43,7 @@ class TodoOpenCheckTest { @Test fun testTodoCheck_noJsonFilePresent_checkShouldFail() { - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -103,7 +103,7 @@ class TodoOpenCheckTest { """.trimIndent() tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -141,7 +141,7 @@ class TodoOpenCheckTest { """.trimIndent() tempFile.writeText(testContent) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -185,7 +185,7 @@ class TodoOpenCheckTest { tempFile1.writeText(testContent1) tempFile2.writeText(testContent2) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -239,7 +239,7 @@ class TodoOpenCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -340,7 +340,7 @@ class TodoOpenCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -391,7 +391,7 @@ class TodoOpenCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } diff --git a/scripts/src/javatests/org/oppia/android/scripts/xml/StringLanguageTranslationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/xml/StringLanguageTranslationCheckTest.kt index 00916b400e4..bbe2c2ca818 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/xml/StringLanguageTranslationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/xml/StringLanguageTranslationCheckTest.kt @@ -65,7 +65,7 @@ class StringLanguageTranslationCheckTest { @Test fun testScript_missingPath_throwsException() { - val exception = assertThrows(IllegalArgumentException::class) { runScript(/* With no path. */) } + val exception = assertThrows() { runScript(/* With no path. */) } assertThat(exception) .hasMessageThat() @@ -74,7 +74,7 @@ class StringLanguageTranslationCheckTest { @Test fun testScript_validPath_noStringFiles_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } diff --git a/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceParserTest.kt b/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceParserTest.kt index 0e1edd3fa30..0bbe198f040 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceParserTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceParserTest.kt @@ -70,7 +70,7 @@ class StringResourceParserTest { fun testRetrieveBaseStringFile_noStrings_throwsException() { val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -88,7 +88,7 @@ class StringResourceParserTest { populateNigerianPidginTranslations() val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -103,7 +103,7 @@ class StringResourceParserTest { populateNigerianPidginTranslations() val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -118,7 +118,7 @@ class StringResourceParserTest { populateNigerianPidginTranslations() val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -133,7 +133,7 @@ class StringResourceParserTest { populateNigerianPidginTranslations() val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -148,7 +148,7 @@ class StringResourceParserTest { populateSwahiliTranslations() val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -161,7 +161,7 @@ class StringResourceParserTest { populateTranslations(appResources, "values-fake", mapOf()) val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } assertThat(exception) .hasMessageThat() @@ -180,7 +180,7 @@ class StringResourceParserTest { populateTranslations(utilityResources, "values", mapOf()) val parser = StringResourceParser(tempFolder.root) - val exception = assertThrows(IllegalStateException::class) { parser.retrieveBaseStringFile() } + val exception = assertThrows() { parser.retrieveBaseStringFile() } // An exception is still thrown since resources outside the app directory are ignored. assertThat(exception) @@ -197,7 +197,7 @@ class StringResourceParserTest { writeTranslationsFile(appResources, "values", "") val parser = StringResourceParser(tempFolder.root) - assertThrows(SAXParseException::class) { parser.retrieveBaseStringFile() } + assertThrows() { parser.retrieveBaseStringFile() } } @Test diff --git a/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceValidationCheckTest.kt index e2152950a99..424a0adb8c3 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/xml/StringResourceValidationCheckTest.kt @@ -64,7 +64,7 @@ class StringResourceValidationCheckTest { @Test fun testScript_missingPath_throwsException() { - val exception = assertThrows(IllegalArgumentException::class) { runScript(/* With no path. */) } + val exception = assertThrows() { runScript(/* With no path. */) } assertThat(exception) .hasMessageThat() @@ -73,7 +73,7 @@ class StringResourceValidationCheckTest { @Test fun testScript_validPath_noStringFiles_fails() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } @@ -105,7 +105,7 @@ class StringResourceValidationCheckTest { populateSwahiliTranslations(mapOf("str1" to SW_STRING_ONE_NEWLINE)) populateNigerianPidginTranslations(mapOf("str1" to PCM_STRING_ONE_NEWLINE)) - val exception = assertThrows(Exception::class) { runScript(tempFolder.root.absolutePath) } + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } // This output check also inadvertently verifies that the script doesn't care about missing // strings in translated string files. @@ -133,7 +133,7 @@ class StringResourceValidationCheckTest { populateSwahiliTranslations(mapOf("str1" to SW_STRING_ONE_NEWLINE)) populateNigerianPidginTranslations(mapOf("str1" to PCM_STRING_ONE_NEWLINE)) - val exception = assertThrows(Exception::class) { runScript(tempFolder.root.absolutePath) } + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } // This output check also inadvertently verifies that the script doesn't care about missing // strings in translated string files. @@ -161,7 +161,7 @@ class StringResourceValidationCheckTest { ) populateNigerianPidginTranslations(mapOf("str1" to PCM_STRING_ONE_NEWLINE)) - val exception = assertThrows(Exception::class) { runScript(tempFolder.root.absolutePath) } + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } // This output check also inadvertently verifies that the script doesn't care about missing // strings in translated string files. @@ -189,7 +189,7 @@ class StringResourceValidationCheckTest { mapOf("str1" to PCM_STRING_NO_NEWLINES, "str2" to PCM_STRING_TWO_NEWLINES) ) - val exception = assertThrows(Exception::class) { runScript(tempFolder.root.absolutePath) } + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } // This output check also inadvertently verifies that the script doesn't care about missing // strings in translated string files. @@ -223,7 +223,7 @@ class StringResourceValidationCheckTest { mapOf("str1" to PCM_STRING_NO_NEWLINES, "str2" to PCM_STRING_TWO_NEWLINES) ) - val exception = assertThrows(Exception::class) { runScript(tempFolder.root.absolutePath) } + val exception = assertThrows() { runScript(tempFolder.root.absolutePath) } // This output check also inadvertently verifies that the script doesn't care about missing // strings in translated string files. diff --git a/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt index 2e988cf0663..293cca1e47e 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt @@ -73,7 +73,7 @@ class XmlSyntaxCheckTest { val tempFile = tempFolder.newFile("testfiles/TestFile.xml") tempFile.writeText(invalidXml) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -112,7 +112,7 @@ class XmlSyntaxCheckTest { tempFile1.writeText(invalidXmlForFile1) tempFile2.writeText(invalidXmlForFile2) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } @@ -163,7 +163,7 @@ class XmlSyntaxCheckTest { tempFile2.writeText(invalidXmlForFile2) tempFile3.writeText(invalidXmlForFile3) - val exception = assertThrows(Exception::class) { + val exception = assertThrows() { runScript() } diff --git a/testing/src/main/java/org/oppia/android/testing/AssertionHelpers.kt b/testing/src/main/java/org/oppia/android/testing/AssertionHelpers.kt index e40d985dad7..7927cd7b79b 100644 --- a/testing/src/main/java/org/oppia/android/testing/AssertionHelpers.kt +++ b/testing/src/main/java/org/oppia/android/testing/AssertionHelpers.kt @@ -1,42 +1,37 @@ package org.oppia.android.testing -import org.junit.Assert.fail -import kotlin.reflect.KClass -import kotlin.reflect.full.cast - /* This file contains generic assertion helpers which are meant to be usable in any test. Not for methods which are specific to a certain test or part of the codebase. */ /** * A replacement to JUnit5's assertThrows() that asserts an execution of the supplied operation - * throws an exception of the supplied type + * throws an exception of the indicated type. * * An example of this might be: * - * val exception = assertThrows(IllegalArgumentException::class) { + * ```kotlin + * val exception = assertThrows() { * stringToRatioParser.parseRatioOrThrow("a:b:c") * } - * assertThat(exception) - * .hasMessageThat() - * .contains("Incorrectly formatted ratio: a:b:c") + * assertThat(exception).hasMessageThat().contains("Incorrectly formatted ratio: a:b:c") + * ``` * - * @param type the type of exception to be thrown * @param operation the operation being run * @return the exception being thrown * @throws AssertionError if the specified exception is not thrown */ -fun assertThrows(type: KClass, operation: () -> Unit): T { - try { - operation() - fail("Expected to encounter exception of $type") - } catch (t: Throwable) { - if (type.isInstance(t)) { - return type.cast(t) +inline fun assertThrows(noinline operation: () -> Unit): T { + return when (val result = try { operation() } catch (t: Throwable) { t }) { + is T -> result + is Throwable -> { + throw AssertionError( + "Expected exception of type: ${T::class.java}, not: ${result::class.java}.", result + ) + } + else -> { + throw AssertionError( + "Expected exception of type: ${T::class.java}. No exception was thrown." + ) } - // Unexpected exception; throw it. - throw t } - throw AssertionError( - "Reached an impossible state when verifying that an exception was thrown." - ) } diff --git a/testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt b/testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt index c3d4b258494..b6b3870763a 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt @@ -75,7 +75,7 @@ class FakeAnalyticsEventLoggerTest { @Test fun testFakeEventLogger_logNothing_getMostRecent_returnsFailure() { - assertThrows(NoSuchElementException::class) { fakeAnalyticsEventLogger.getMostRecentEvent() } + assertThrows() { fakeAnalyticsEventLogger.getMostRecentEvent() } } @Test @@ -83,7 +83,7 @@ class FakeAnalyticsEventLoggerTest { analyticsEventLogger.logEvent(eventLog1) fakeAnalyticsEventLogger.clearAllEvents() - val eventException = assertThrows(NoSuchElementException::class) { + val eventException = assertThrows() { fakeAnalyticsEventLogger.getMostRecentEvent() } @@ -141,7 +141,7 @@ class FakeAnalyticsEventLoggerTest { @Test fun testGetOldestEvent_noEventsLogged_throwsException() { - assertThrows(NoSuchElementException::class) { fakeAnalyticsEventLogger.getOldestEvent() } + assertThrows() { fakeAnalyticsEventLogger.getOldestEvent() } } @Test @@ -169,7 +169,7 @@ class FakeAnalyticsEventLoggerTest { analyticsEventLogger.logEvent(eventLog1) fakeAnalyticsEventLogger.clearAllEvents() - assertThrows(NoSuchElementException::class) { fakeAnalyticsEventLogger.getOldestEvent() } + assertThrows() { fakeAnalyticsEventLogger.getOldestEvent() } } @Test @@ -234,7 +234,7 @@ class FakeAnalyticsEventLoggerTest { analyticsEventLogger.logEvent(eventLog2) analyticsEventLogger.logEvent(eventLog1) - assertThrows(IllegalArgumentException::class) { + assertThrows() { fakeAnalyticsEventLogger.getMostRecentEvents(count = -1) } } diff --git a/testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt b/testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt index baa7483b27e..433731da58c 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt @@ -69,7 +69,7 @@ class FakeExceptionLoggerTest { @Test fun testFakeExceptionLogger_logNothing_getMostRecent_returnsFailure() { - val exception = assertThrows(NoSuchElementException::class) { + val exception = assertThrows() { fakeExceptionLogger.getMostRecentException() } @@ -81,7 +81,7 @@ class FakeExceptionLoggerTest { exceptionLogger.logException(IllegalStateException("Test Exception")) fakeExceptionLogger.clearAllExceptions() - val exception = assertThrows(NoSuchElementException::class) { + val exception = assertThrows() { fakeExceptionLogger.getMostRecentException() } diff --git a/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt b/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt index 63afc482661..7f7b55a2d17 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt @@ -78,7 +78,7 @@ class FakePerformanceMetricsEventLoggerTest { @Test fun testFakeMetricsEventLogger_logNothing_getMostRecent_returnsFailure() { - assertThrows(NoSuchElementException::class) { + assertThrows() { fakePerformanceMetricsEventLogger.getMostRecentPerformanceMetricsEvent() } } @@ -88,7 +88,7 @@ class FakePerformanceMetricsEventLoggerTest { performanceMetricsEventLogger.logPerformanceMetric(metricLog1) fakePerformanceMetricsEventLogger.clearAllPerformanceMetricsEvents() - assertThrows(NoSuchElementException::class) { + assertThrows() { fakePerformanceMetricsEventLogger.getMostRecentPerformanceMetricsEvent() } } @@ -148,7 +148,7 @@ class FakePerformanceMetricsEventLoggerTest { @Test fun testGetOldestEvent_noEventsLogged_throwsException() { - assertThrows(NoSuchElementException::class) { + assertThrows() { fakePerformanceMetricsEventLogger.getOldestPerformanceMetricsEvent() } } @@ -178,7 +178,7 @@ class FakePerformanceMetricsEventLoggerTest { performanceMetricsEventLogger.logPerformanceMetric(metricLog1) fakePerformanceMetricsEventLogger.clearAllPerformanceMetricsEvents() - assertThrows(NoSuchElementException::class) { + assertThrows() { fakePerformanceMetricsEventLogger.getOldestPerformanceMetricsEvent() } } @@ -255,7 +255,7 @@ class FakePerformanceMetricsEventLoggerTest { performanceMetricsEventLogger.logPerformanceMetric(metricLog2) performanceMetricsEventLogger.logPerformanceMetric(metricLog1) - assertThrows(IllegalArgumentException::class) { + assertThrows() { fakePerformanceMetricsEventLogger.getMostRecentPerformanceMetricsEvents(count = -1) } } diff --git a/testing/src/test/java/org/oppia/android/testing/data/DataProviderTestMonitorTest.kt b/testing/src/test/java/org/oppia/android/testing/data/DataProviderTestMonitorTest.kt index 9df6e5257d3..aaa3f578c02 100644 --- a/testing/src/test/java/org/oppia/android/testing/data/DataProviderTestMonitorTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/data/DataProviderTestMonitorTest.kt @@ -167,7 +167,7 @@ class DataProviderTestMonitorTest { } val monitor = monitorFactory.createMonitor(dataProvider) - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextSuccessResult() } + val failure = assertThrows() { monitor.waitForNextSuccessResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } @@ -179,7 +179,7 @@ class DataProviderTestMonitorTest { } val monitor = monitorFactory.createMonitor(dataProvider) - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextSuccessResult() } + val failure = assertThrows() { monitor.waitForNextSuccessResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } @@ -221,7 +221,7 @@ class DataProviderTestMonitorTest { monitor.waitForNextResult() // Wait for the first result. asyncDataSubscriptionManager.notifyChangeAsync("test") - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextSuccessResult() } + val failure = assertThrows() { monitor.waitForNextSuccessResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } @@ -251,7 +251,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) // Internal expectation failure since the operation hasn't completed. - assertThrows(AssertionError::class) { monitor.ensureNextResultIsSuccess() } + assertThrows() { monitor.ensureNextResultIsSuccess() } } @Test @@ -275,7 +275,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsSuccess() } + val failure = assertThrows() { monitor.ensureNextResultIsSuccess() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } @@ -288,26 +288,11 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsSuccess() } + val failure = assertThrows() { monitor.ensureNextResultIsSuccess() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } - @Test - fun testEnsureNextResultIsSuccess_failureThenSuccess_notified_throwsException() { - val dataProvider = - createDataProviderWithResultsQueue( - "test", AsyncResult.Failure(Exception("Failure")), AsyncResult.Success("str value") - ) - val monitor = monitorFactory.createMonitor(dataProvider) - monitor.waitForNextResult() // Wait for the first result. - - asyncDataSubscriptionManager.notifyChangeAsync("test") - testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - // Internal expectation failure since the operation hasn't completed. - assertThrows(AssertionError::class) { monitor.ensureNextResultIsSuccess() } - } - @Test fun testEnsureNextResultIsSuccess_failureThenSuccess_notified_wait_returnsLatest() { val dataProvider = @@ -335,7 +320,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsSuccess() } + val failure = assertThrows() { monitor.ensureNextResultIsSuccess() } assertThat(failure).hasMessageThat().contains("Expected next result to be a success") } @@ -365,7 +350,7 @@ class DataProviderTestMonitorTest { } val monitor = monitorFactory.createMonitor(dataProvider) - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextFailingResult() } + val failure = assertThrows() { monitor.waitForNextFailingResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -389,7 +374,7 @@ class DataProviderTestMonitorTest { } val monitor = monitorFactory.createMonitor(dataProvider) - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextFailingResult() } + val failure = assertThrows() { monitor.waitForNextFailingResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -419,7 +404,7 @@ class DataProviderTestMonitorTest { monitor.waitForNextResult() // Wait for the first result. asyncDataSubscriptionManager.notifyChangeAsync("test") - val failure = assertThrows(IllegalStateException::class) { monitor.waitForNextFailingResult() } + val failure = assertThrows() { monitor.waitForNextFailingResult() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -449,7 +434,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) // Internal expectation failure since the operation hasn't completed. - assertThrows(AssertionError::class) { monitor.ensureNextResultIsSuccess() } + assertThrows() { monitor.ensureNextResultIsSuccess() } } @Test @@ -473,7 +458,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsFailing() } + val failure = assertThrows() { monitor.ensureNextResultIsFailing() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -486,7 +471,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsFailing() } + val failure = assertThrows() { monitor.ensureNextResultIsFailing() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -502,7 +487,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") // Internal expectation failure since the operation hasn't completed. - assertThrows(AssertionError::class) { monitor.ensureNextResultIsFailing() } + assertThrows() { monitor.ensureNextResultIsFailing() } } @Test @@ -532,7 +517,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") testCoroutineDispatchers.runCurrent() // Ensure the subscription is updated. - val failure = assertThrows(IllegalStateException::class) { monitor.ensureNextResultIsFailing() } + val failure = assertThrows() { monitor.ensureNextResultIsFailing() } assertThat(failure).hasMessageThat().contains("Expected next result to be a failure") } @@ -563,7 +548,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -574,7 +559,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -585,7 +570,7 @@ class DataProviderTestMonitorTest { val monitor = monitorFactory.createMonitor(dataProvider) // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -599,7 +584,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -615,7 +600,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -630,7 +615,7 @@ class DataProviderTestMonitorTest { asyncDataSubscriptionManager.notifyChangeAsync("test") // Verify that the method wsa actually called despite not being expected to have been. - assertThrows(NeverWantedButInvoked::class) { monitor.verifyProviderIsNotUpdated() } + assertThrows() { monitor.verifyProviderIsNotUpdated() } } @Test @@ -657,7 +642,7 @@ class DataProviderTestMonitorTest { } val failure = - assertThrows(AssertionError::class) { + assertThrows() { monitorFactory.ensureDataProviderExecutes(dataProvider) } @@ -673,7 +658,7 @@ class DataProviderTestMonitorTest { } val failure = - assertThrows(AssertionError::class) { + assertThrows() { monitorFactory.ensureDataProviderExecutes(dataProvider) } @@ -688,7 +673,7 @@ class DataProviderTestMonitorTest { AsyncResult.Failure(Exception("Failure")) } - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextSuccessfulResult(dataProvider) } @@ -727,7 +712,7 @@ class DataProviderTestMonitorTest { ) monitorFactory.waitForNextSuccessfulResult(dataProvider) - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextSuccessfulResult(dataProvider) } @@ -770,7 +755,7 @@ class DataProviderTestMonitorTest { } val failure = - assertThrows(IllegalStateException::class) { + assertThrows() { monitorFactory.waitForNextSuccessfulResult(dataProvider) } @@ -783,7 +768,7 @@ class DataProviderTestMonitorTest { AsyncResult.Failure(Exception("Failure")) } - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextSuccessfulResult(dataProvider) } @@ -822,7 +807,7 @@ class DataProviderTestMonitorTest { ) monitorFactory.waitForNextSuccessfulResult(dataProvider) - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextSuccessfulResult(dataProvider) } @@ -864,7 +849,7 @@ class DataProviderTestMonitorTest { AsyncResult.Pending() } - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextFailureResult(dataProvider) } @@ -888,7 +873,7 @@ class DataProviderTestMonitorTest { AsyncResult.Success("str value") } - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextFailureResult(dataProvider) } @@ -916,7 +901,7 @@ class DataProviderTestMonitorTest { ) monitorFactory.waitForNextFailureResult(dataProvider) - val failure = assertThrows(IllegalStateException::class) { + val failure = assertThrows() { monitorFactory.waitForNextFailureResult(dataProvider) } diff --git a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt index f2f2b2c89f0..e4719190051 100644 --- a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt @@ -105,7 +105,7 @@ class InitializeDefaultLocaleRuleOmissionTest { @Test fun testSuite_withoutRule_doesNotInitializeLocaleHandlerWithDefaultContext() { // Not including the rule should result in a helpful exception being thrown. - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { appLanguageLocaleHandler.getDisplayLocale() } assertThat(exception) diff --git a/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt b/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt index 2e158ee93a1..3af786359ca 100644 --- a/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt @@ -136,7 +136,7 @@ class CoroutineExecutorServiceTest { fun testExecute_nullParameter_throwsException() { val executorService = createExecutorService() - assertThrows(NullPointerException::class) { executorService.execute(/* command= */ null) } + assertThrows() { executorService.execute(/* command= */ null) } } @Test @@ -144,7 +144,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdown() - assertThrows(RejectedExecutionException::class) { executorService.execute(mockRunnable) } + assertThrows() { executorService.execute(mockRunnable) } } @Test @@ -152,7 +152,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdownNow() - assertThrows(RejectedExecutionException::class) { executorService.execute(mockRunnable) } + assertThrows() { executorService.execute(mockRunnable) } } @Test @@ -179,7 +179,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() val nullRunnable: Runnable? = null - assertThrows(NullPointerException::class) { executorService.submit(nullRunnable) } + assertThrows() { executorService.submit(nullRunnable) } } @Test @@ -187,7 +187,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdown() - assertThrows(RejectedExecutionException::class) { executorService.submit(mockRunnable) } + assertThrows() { executorService.submit(mockRunnable) } } @Test @@ -195,7 +195,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdownNow() - assertThrows(RejectedExecutionException::class) { executorService.submit(mockRunnable) } + assertThrows() { executorService.submit(mockRunnable) } } @Test @@ -222,7 +222,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() val nullCallable: Callable? = null - assertThrows(NullPointerException::class) { executorService.submit(nullCallable) } + assertThrows() { executorService.submit(nullCallable) } } @Test @@ -230,7 +230,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdown() - assertThrows(RejectedExecutionException::class) { executorService.submit(mockCallable) } + assertThrows() { executorService.submit(mockCallable) } } @Test @@ -238,7 +238,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdownNow() - assertThrows(RejectedExecutionException::class) { executorService.submit(mockCallable) } + assertThrows() { executorService.submit(mockCallable) } } @Test @@ -271,7 +271,7 @@ class CoroutineExecutorServiceTest { testCoroutineDispatchers.runCurrent() assertThat(callableFuture.isDone).isTrue() - val exception = assertThrows(ExecutionException::class) { callableFuture.get() } + val exception = assertThrows() { callableFuture.get() } assertThat(exception).hasCauseThat().isInstanceOf(Exception::class.java) assertThat(exception).hasCauseThat().hasMessageThat().contains("Task failed") } @@ -420,7 +420,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() val nullRunnable: Runnable? = null - assertThrows(NullPointerException::class) { + assertThrows() { executorService.submit(nullRunnable, /* result= */ "Task") } } @@ -430,7 +430,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdown() - assertThrows(RejectedExecutionException::class) { + assertThrows() { executorService.submit(mockRunnable, /* result= */ "Task") } } @@ -440,7 +440,7 @@ class CoroutineExecutorServiceTest { val executorService = createExecutorService() executorService.shutdownNow() - assertThrows(RejectedExecutionException::class) { + assertThrows() { executorService.submit(mockRunnable, /* result= */ "Task") } } @@ -645,7 +645,7 @@ class CoroutineExecutorServiceTest { // Note that this is not documented in the ExecutorService documentation, it seems necessary // since it doesn't make sense to return false (per the documentation) or block unless a // shutdown request was actually initiated. - assertThrows(IllegalStateException::class) { + assertThrows() { executorService.awaitTermination(/* timeout= */ 1, TimeUnit.SECONDS) } } @@ -746,7 +746,7 @@ class CoroutineExecutorServiceTest { fun testInvokeAll_nullTasks_throwsException() { val executorService = createExecutorService() - assertThrows(NullPointerException::class) { executorService.invokeAll(/* tasks= */ null) } + assertThrows() { executorService.invokeAll(/* tasks= */ null) } } @Test @@ -807,7 +807,7 @@ class CoroutineExecutorServiceTest { val (future1, future2) = deferred.getCompleted() assertThat(future1.isDone).isTrue() assertThat(future2.isDone).isTrue() - assertThrows(ExecutionException::class) { future1.get() } + assertThrows() { future1.get() } assertThat(future2.get()).isEqualTo("Task 2") } @@ -906,7 +906,7 @@ class CoroutineExecutorServiceTest { fun testInvokeAny_nullTasks_throwsException() { val executorService = createExecutorService() - assertThrows(NullPointerException::class) { executorService.invokeAny(/* tasks= */ null) } + assertThrows() { executorService.invokeAny(/* tasks= */ null) } } @Test diff --git a/testing/src/test/java/org/oppia/android/testing/time/FakeOppiaClockTest.kt b/testing/src/test/java/org/oppia/android/testing/time/FakeOppiaClockTest.kt index 5b534916126..aabaee20ebc 100644 --- a/testing/src/test/java/org/oppia/android/testing/time/FakeOppiaClockTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/time/FakeOppiaClockTest.kt @@ -110,7 +110,7 @@ class FakeOppiaClockTest { fun testSetCurrentTimeMs_wallClockMode_throwsException() { fakeOppiaClock.setFakeTimeMode(MODE_WALL_CLOCK_TIME) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fakeOppiaClock.setCurrentTimeMs(0) } assertThat(exception).hasMessageThat().contains("MODE_FIXED_FAKE_TIME") @@ -128,7 +128,7 @@ class FakeOppiaClockTest { fun testSetCurrentTimeMs_uptimeMillisMode_throwsException() { fakeOppiaClock.setFakeTimeMode(MODE_UPTIME_MILLIS) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fakeOppiaClock.setCurrentTimeMs(0) } assertThat(exception).hasMessageThat().contains("MODE_FIXED_FAKE_TIME") @@ -226,7 +226,7 @@ class FakeOppiaClockTest { fun testSetCurrentTimeToSameDateTime_wallClockMode_throwsException() { fakeOppiaClock.setFakeTimeMode(MODE_UPTIME_MILLIS) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fakeOppiaClock.setCurrentTimeToSameDateTime(0) } assertThat(exception).hasMessageThat().contains("MODE_FIXED_FAKE_TIME") @@ -258,7 +258,7 @@ class FakeOppiaClockTest { fun testSetCurrentTimeToSameDateTime_uptimeMillisMode_throwsException() { fakeOppiaClock.setFakeTimeMode(MODE_UPTIME_MILLIS) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { fakeOppiaClock.setCurrentTimeToSameDateTime(0) } assertThat(exception).hasMessageThat().contains("MODE_FIXED_FAKE_TIME") diff --git a/utility/src/test/java/org/oppia/android/util/caching/testing/TestNoOpAssetRepositoryTest.kt b/utility/src/test/java/org/oppia/android/util/caching/testing/TestNoOpAssetRepositoryTest.kt index 2cb1a10f433..ea5346c2490 100644 --- a/utility/src/test/java/org/oppia/android/util/caching/testing/TestNoOpAssetRepositoryTest.kt +++ b/utility/src/test/java/org/oppia/android/util/caching/testing/TestNoOpAssetRepositoryTest.kt @@ -38,7 +38,7 @@ class TestNoOpAssetRepositoryTest { @Test fun testLoadTextFileFromLocalAssets_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadTextFileFromLocalAssets("asset.json") } @@ -57,7 +57,7 @@ class TestNoOpAssetRepositoryTest { assetRepository.primeTextFileFromLocalAssets("asset.json") // Priming doesn't do anything, so the exception is still thrown. - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadTextFileFromLocalAssets("asset.json") } @@ -66,7 +66,7 @@ class TestNoOpAssetRepositoryTest { @Test fun testLoadProtoFromLocalAssets_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadProtoFromLocalAssets("test", TestMessage.getDefaultInstance()) } @@ -107,7 +107,7 @@ class TestNoOpAssetRepositoryTest { @Test fun testLoadRemoteBinaryAsset_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadRemoteBinaryAsset("https://example.com/test.pb") } @@ -117,7 +117,7 @@ class TestNoOpAssetRepositoryTest { @Test fun testLoadImageAssetFromLocalAssets_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadImageAssetFromLocalAssets("https://example.com/test.png") } @@ -137,7 +137,7 @@ class TestNoOpAssetRepositoryTest { assetRepository.primeRemoteBinaryAsset("https://example.com/test.pb") // Priming doesn't do anything, so the exception is still thrown. - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { assetRepository.loadRemoteBinaryAsset("https://example.com/test.pb") } diff --git a/utility/src/test/java/org/oppia/android/util/data/AsyncDataSubscriptionManagerTest.kt b/utility/src/test/java/org/oppia/android/util/data/AsyncDataSubscriptionManagerTest.kt index 8a9c0b627d9..0926b2fd323 100644 --- a/utility/src/test/java/org/oppia/android/util/data/AsyncDataSubscriptionManagerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/data/AsyncDataSubscriptionManagerTest.kt @@ -258,7 +258,7 @@ class AsyncDataSubscriptionManagerTest { @Test fun testAssociateIds_sameId_throwsException() { - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { asyncDataSubscriptionManager.associateIds("same_id", "same_id") } @@ -430,7 +430,7 @@ class AsyncDataSubscriptionManagerTest { asyncDataSubscriptionManager.subscribe("child_id", mockSubscriptionCallback2.toAsyncChange()) asyncDataSubscriptionManager.associateIds("child_id", "parent_id") - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { asyncDataSubscriptionManager.associateIds("parent_id", "child_id") } @@ -446,7 +446,7 @@ class AsyncDataSubscriptionManagerTest { asyncDataSubscriptionManager.associateIds("child_id1", "parent_id") asyncDataSubscriptionManager.associateIds("child_id2", "child_id1") - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { asyncDataSubscriptionManager.associateIds("parent_id", "child_id1") } diff --git a/utility/src/test/java/org/oppia/android/util/data/InMemoryBlockingCacheTest.kt b/utility/src/test/java/org/oppia/android/util/data/InMemoryBlockingCacheTest.kt index e5e2a69b59b..4dc2cc0fc5a 100644 --- a/utility/src/test/java/org/oppia/android/util/data/InMemoryBlockingCacheTest.kt +++ b/utility/src/test/java/org/oppia/android/util/data/InMemoryBlockingCacheTest.kt @@ -207,7 +207,7 @@ class InMemoryBlockingCacheTest { val deferredRead = cache.readIfPresentAsync() val exception = - assertThrows(IllegalStateException::class) { awaitCompletion(deferredRead) } + assertThrows() { awaitCompletion(deferredRead) } assertThat(exception).hasMessageThat() .contains("Expected to read the cache only after it's been created") } @@ -302,7 +302,7 @@ class InMemoryBlockingCacheTest { // The operation should fail since the method expects the cache to be initialized. val exception = - assertThrows(IllegalStateException::class) { awaitCompletion(deferredUpdate) } + assertThrows() { awaitCompletion(deferredUpdate) } assertThat(exception).hasMessageThat() .contains("Expected to update the cache only after it's been created") } @@ -422,7 +422,7 @@ class InMemoryBlockingCacheTest { // Deleting the cache should result in readIfPresent()'s expectations to fail. val exception = - assertThrows(IllegalStateException::class) { awaitCompletion(deferredRead) } + assertThrows() { awaitCompletion(deferredRead) } assertThat(exception).hasMessageThat() .contains("Expected to read the cache only after it's been created") } @@ -456,7 +456,7 @@ class InMemoryBlockingCacheTest { // The operation should fail since the method expects the cache to be initialized. val exception = - assertThrows(IllegalStateException::class) { awaitCompletion(deferredUpdate) } + assertThrows() { awaitCompletion(deferredUpdate) } assertThat(exception).hasMessageThat() .contains("Expected to update the cache only after it's been created") } diff --git a/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt b/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt index c0b45f7e9fd..c009baad4e0 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/AndroidLocaleFactoryTest.kt @@ -51,7 +51,7 @@ class AndroidLocaleFactoryTest { @Test fun testCreateLocale_default_throwsException() { - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(OppiaLocaleContext.getDefaultInstance()) } @@ -513,7 +513,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } @@ -566,7 +566,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } @@ -945,7 +945,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } @@ -998,7 +998,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } @@ -1377,7 +1377,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } @@ -1430,7 +1430,7 @@ class AndroidLocaleFactoryTest { regionDefinition = REGION_INDIA ) - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { androidLocaleFactory.createAndroidLocale(context) } diff --git a/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt b/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt index 8786f31948b..e300a47d6fa 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/DisplayLocaleImplTest.kt @@ -354,7 +354,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getStringInLocale(-1) } } } @@ -397,7 +397,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getStringInLocaleWithWrapping(-1) } } } @@ -440,7 +440,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getStringInLocaleWithoutWrapping(-1) } } } @@ -460,7 +460,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getStringArrayInLocale(-1) } } } @@ -496,7 +496,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getQuantityStringInLocale(-1, 0) } } } @@ -535,7 +535,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getQuantityStringInLocaleWithWrapping(-1, 0) } } } @@ -574,7 +574,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getQuantityStringInLocaleWithoutWrapping(-1, 0) } } } @@ -610,7 +610,7 @@ class DisplayLocaleImplTest { val impl = createDisplayLocaleImpl(US_ENGLISH_CONTEXT) val resources = context.resources - assertThrows(Resources.NotFoundException::class) { + assertThrows() { impl.run { resources.getQuantityTextInLocale(-1, 0) } } } diff --git a/utility/src/test/java/org/oppia/android/util/locale/testing/TestOppiaBidiFormatterTest.kt b/utility/src/test/java/org/oppia/android/util/locale/testing/TestOppiaBidiFormatterTest.kt index d56be1961ae..91eefeac704 100644 --- a/utility/src/test/java/org/oppia/android/util/locale/testing/TestOppiaBidiFormatterTest.kt +++ b/utility/src/test/java/org/oppia/android/util/locale/testing/TestOppiaBidiFormatterTest.kt @@ -92,7 +92,7 @@ class TestOppiaBidiFormatterTest { val wrappedStr = formatter.wrapText("test str") // Try to wrap the string again. - val exception = assertThrows(IllegalStateException::class) { formatter.wrapText(wrappedStr) } + val exception = assertThrows() { formatter.wrapText(wrappedStr) } assertThat(exception).hasMessageThat() .contains("Error: encountered string that's already been wrapped: test str") diff --git a/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerTestBase.kt b/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerTestBase.kt index c19dcfa6d3d..8690cc70ae8 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerTestBase.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerTestBase.kt @@ -56,7 +56,7 @@ abstract class SyncStatusManagerTestBase { fun testInitializeEventLogStore_twice_throwsException() { impl.initializeEventLogStore(logsCacheStore) - val error = assertThrows(IllegalStateException::class) { + val error = assertThrows() { impl.initializeEventLogStore(logsCacheStore) } diff --git a/utility/src/test/java/org/oppia/android/util/math/FractionExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/FractionExtensionsTest.kt index 3913e7b6dda..f44bc197f98 100644 --- a/utility/src/test/java/org/oppia/android/util/math/FractionExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/FractionExtensionsTest.kt @@ -444,7 +444,7 @@ class FractionExtensionsTest { val zeroDenominatorFraction = Fraction.getDefaultInstance() // Converting to simplest form results in a divide by zero in this case. - assertThrows(ArithmeticException::class) { zeroDenominatorFraction.toSimplestForm() } + assertThrows() { zeroDenominatorFraction.toSimplestForm() } } @Test @@ -518,7 +518,7 @@ class FractionExtensionsTest { val zeroDenominatorFraction = Fraction.getDefaultInstance() // Converting to simplest form results in a divide by zero in this case. - assertThrows(ArithmeticException::class) { zeroDenominatorFraction.toProperForm() } + assertThrows() { zeroDenominatorFraction.toProperForm() } } @Test @@ -1062,7 +1062,7 @@ class FractionExtensionsTest { val lhsFraction = ZERO_FRACTION val rhsFraction = ZERO_FRACTION - assertThrows(Exception::class) { lhsFraction / rhsFraction } + assertThrows() { lhsFraction / rhsFraction } } @Test @@ -1070,7 +1070,7 @@ class FractionExtensionsTest { val lhsFraction = ONE_FRACTION val rhsFraction = ZERO_FRACTION - assertThrows(Exception::class) { lhsFraction / rhsFraction } + assertThrows() { lhsFraction / rhsFraction } } @Test @@ -1078,7 +1078,7 @@ class FractionExtensionsTest { val lhsFraction = TWO_FRACTION val rhsFraction = ZERO_FRACTION - assertThrows(Exception::class) { lhsFraction / rhsFraction } + assertThrows() { lhsFraction / rhsFraction } } @Test diff --git a/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt b/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt index 864a429f753..fa00cf23485 100644 --- a/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt @@ -173,7 +173,7 @@ class FractionParserTest { val parseFraction = fractionParser.parseFraction("7 1/2 4/5") assertThat(parseFraction).isEqualTo(null) - val exception = assertThrows(IllegalArgumentException::class) { + val exception = assertThrows() { fractionParser.parseFractionFromString("7 1/2 4/5") } assertThat(exception).hasMessageThat().contains("Incorrectly formatted fraction: 7 1/2 4/5") @@ -184,7 +184,7 @@ class FractionParserTest { val parseFraction = fractionParser.parseFraction("abc") assertThat(parseFraction).isEqualTo(null) - val exception = assertThrows(IllegalArgumentException::class) { + val exception = assertThrows() { fractionParser.parseFractionFromString("abc") } assertThat(exception).hasMessageThat().contains("Incorrectly formatted fraction: abc") diff --git a/utility/src/test/java/org/oppia/android/util/math/PeekableIteratorTest.kt b/utility/src/test/java/org/oppia/android/util/math/PeekableIteratorTest.kt index 0b6cddc7dbe..e342081aab0 100644 --- a/utility/src/test/java/org/oppia/android/util/math/PeekableIteratorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/PeekableIteratorTest.kt @@ -55,7 +55,7 @@ class PeekableIteratorTest { val sequence = sequenceOf() val iterator = sequence.toPeekableIterator() - assertThrows(NoSuchElementException::class) { iterator.next() } + assertThrows() { iterator.next() } } @Test diff --git a/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt index fee8d4e00e7..bfcb4dba53d 100644 --- a/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt @@ -252,7 +252,7 @@ class RealExtensionsTest { fun testIsNegative_default_throwsException() { val defaultReal = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { defaultReal.isNegative() } + val exception = assertThrows() { defaultReal.isNegative() } assertThat(exception).hasMessageThat().contains("Invalid real") } @@ -309,7 +309,7 @@ class RealExtensionsTest { val first = Real.getDefaultInstance() val second = TWO_REAL - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { first.isApproximatelyEqualTo(second) } @@ -321,7 +321,7 @@ class RealExtensionsTest { val first = TWO_REAL val second = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { + val exception = assertThrows() { first.isApproximatelyEqualTo(second) } @@ -659,7 +659,7 @@ class RealExtensionsTest { fun testIsApproximatelyZero_default_throwsException() { val defaultReal = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { defaultReal.isApproximatelyZero() } + val exception = assertThrows() { defaultReal.isApproximatelyZero() } assertThat(exception).hasMessageThat().contains("Invalid real") } @@ -732,7 +732,7 @@ class RealExtensionsTest { fun testToDouble_default_returnsZeroDouble() { val defaultReal = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { defaultReal.toDouble() } + val exception = assertThrows() { defaultReal.toDouble() } assertThat(exception).hasMessageThat().contains("Invalid real") } @@ -783,7 +783,7 @@ class RealExtensionsTest { fun testAsWholeNumber_default_throwsException() { val defaultReal = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { defaultReal.asWholeNumber() } + val exception = assertThrows() { defaultReal.asWholeNumber() } assertThat(exception).hasMessageThat().contains("Invalid real") } @@ -925,7 +925,7 @@ class RealExtensionsTest { fun testUnaryMinus_default_throwsException() { val defaultReal = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { -defaultReal } + val exception = assertThrows() { -defaultReal } assertThat(exception).hasMessageThat().contains("Invalid real") } @@ -1782,7 +1782,7 @@ class RealExtensionsTest { val lhsReal = createIntegerReal(2) val rhsReal = createIntegerReal(0) - assertThrows(ArithmeticException::class) { lhsReal / rhsReal } + assertThrows() { lhsReal / rhsReal } } @Test @@ -1790,7 +1790,7 @@ class RealExtensionsTest { val lhsReal = createIntegerReal(2) val rhsReal = createRationalReal(ZERO_FRACTION) - assertThrows(ArithmeticException::class) { lhsReal / rhsReal } + assertThrows() { lhsReal / rhsReal } } @Test @@ -1808,7 +1808,7 @@ class RealExtensionsTest { val lhsReal = ONE_AND_ONE_HALF_REAL val rhsReal = createIntegerReal(0) - assertThrows(ArithmeticException::class) { lhsReal / rhsReal } + assertThrows() { lhsReal / rhsReal } } @Test @@ -1816,7 +1816,7 @@ class RealExtensionsTest { val lhsReal = ONE_AND_ONE_HALF_REAL val rhsReal = createRationalReal(ZERO_FRACTION) - assertThrows(ArithmeticException::class) { lhsReal / rhsReal } + assertThrows() { lhsReal / rhsReal } } @Test @@ -2188,7 +2188,7 @@ class RealExtensionsTest { fun testSqrt_defaultReal_throwsException() { val real = Real.getDefaultInstance() - val exception = assertThrows(IllegalStateException::class) { sqrt(real) } + val exception = assertThrows() { sqrt(real) } assertThat(exception).hasMessageThat().contains("Invalid real") } From fb59232b23e8c0a7a3c1c840c13b325f0f9fdd11 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 28 Aug 2023 21:35:39 +0000 Subject: [PATCH 02/21] Tidy some things up, and revert fragment test. ProfileAndDeviceIdFragmentTest had been updated to use a newer fragment initialization pattern, but that's no longer needed and seems to be causing what appears to be timing discrepancies between local dev and CI. --- .../ProfileAndDeviceIdFragmentTest.kt | 855 +++++++++--------- .../scripts/docs/KdocValidityCheckTest.kt | 152 ++-- .../regex/RegexPatternValidationCheckTest.kt | 348 ++----- .../scripts/testfile/TestFileCheckTest.kt | 18 +- .../android/scripts/todo/TodoOpenCheckTest.kt | 46 +- .../android/scripts/xml/XmlSyntaxCheckTest.kt | 18 +- testing/BUILD.bazel | 5 +- 7 files changed, 585 insertions(+), 857 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index f1caf58e449..74c37f0e6da 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -9,7 +9,6 @@ import android.view.View import androidx.annotation.IdRes import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.RecyclerView -import androidx.test.core.app.ActivityScenario import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView import androidx.test.espresso.ViewInteraction @@ -24,6 +23,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isEnabled import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText +import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.truth.content.IntentSubject.assertThat import androidx.work.Configuration @@ -62,7 +62,6 @@ import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.atPositi import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.hasItemCount import org.oppia.android.app.shim.ViewBindingShimModule import org.oppia.android.app.testing.activity.TestActivity -import org.oppia.android.app.testing.activity.TestActivity.Companion.createIntent import org.oppia.android.app.translation.testing.ActivityRecreatorTestModule import org.oppia.android.app.utility.OrientationChangeAction.Companion.orientationLandscape import org.oppia.android.data.backends.gae.NetworkConfigProdModule @@ -148,6 +147,12 @@ import javax.inject.Singleton class ProfileAndDeviceIdFragmentTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @get:Rule val oppiaTestRule = OppiaTestRule() + @get:Rule + var activityRule = + ActivityScenarioRule( + TestActivity.createIntent(ApplicationProvider.getApplicationContext()) + ) + @Inject lateinit var profileTestHelper: ProfileTestHelper @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Inject lateinit var context: Context @@ -188,587 +193,559 @@ class ProfileAndDeviceIdFragmentTest { @Test fun testFragment_withOnlyAdminProfile_hasThreeItems() { - runInTestActivityAndAddFragment { - // There should be three items: a header, a profile, and the sync status. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) - } + initializeActivityAndAddFragment() + + // There should be three items: a header, a profile, and the sync status. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) } @Test fun testFragment_withOnlyAdminProfile_hasDeviceIdHeader() { - runInTestActivityAndAddFragment { - onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) - } + initializeActivityAndAddFragment() + + onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) } @Test fun testFragment_hasDeviceId() { - runInTestActivityAndAddFragment { - onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("113e04cc09a3")))) - } + initializeActivityAndAddFragment() + + onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("113e04cc09a3")))) } @Test fun testFragment_deviceId_hasCopyButton() { - runInTestActivityAndAddFragment { - onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) - } + initializeActivityAndAddFragment() + + onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) } @Test fun testFragment_deviceId_clickCopyButton_copiesDeviceIdToClipboard() { - runInTestActivityAndAddFragment { - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() - - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("Oppia installation ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("113e04cc09a3") - } + initializeActivityAndAddFragment() + + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() + + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("Oppia installation ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("113e04cc09a3") } @Test fun testFragment_withOnlyAdminProfile_hasOneProfileListed() { - runInTestActivityAndAddFragment { - onProfileNameAt(position = 1).check(matches(isDisplayed())) - } + initializeActivityAndAddFragment() + + onProfileNameAt(position = 1).check(matches(isDisplayed())) } @Test fun testFragment_profileEntry_hasProfileName() { - runInTestActivityAndAddFragment { - onProfileNameAt(position = 1).check(matches(withText("Admin"))) - } + initializeActivityAndAddFragment() + + onProfileNameAt(position = 1).check(matches(withText("Admin"))) } @Test fun testFragment_profileEntry_hasLearnerId() { - runInTestActivityAndAddFragment { - onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) - } + initializeActivityAndAddFragment() + + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) } @Test fun testFragment_profileEntry_hasCopyButton() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) - } + initializeActivityAndAddFragment() + + onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) } @Test fun testFragment_profileEntry_clickFirstCopyButton_copiesAdminLearnerIdToClipboard() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() - - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("Admin's learner ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("8dcbbd21") - } + initializeActivityAndAddFragment() + + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() + + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("Admin's learner ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("8dcbbd21") } @Test fun testFragment_multipleProfiles_listsAllProfiles() { profileTestHelper.addMoreProfiles(numProfiles = 5) - runInTestActivityAndAddFragment { - // Header + admin + 5 new profiles + sync status = 8 items. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) - } + initializeActivityAndAddFragment() + + // Header + admin + 5 new profiles + sync status = 8 items. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) } @Test fun testFragment_multipleProfiles_adminIsFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - runInTestActivityAndAddFragment { - onProfileNameAt(position = 1).check(matches(withText("Admin"))) - } + initializeActivityAndAddFragment() + + onProfileNameAt(position = 1).check(matches(withText("Admin"))) } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentName() { profileTestHelper.addMoreProfiles(numProfiles = 5) - runInTestActivityAndAddFragment { - // The second entry is not the admin. - onProfileNameAt(position = 2).check(matches(withText("A"))) - } + initializeActivityAndAddFragment() + + // The second entry is not the admin. + onProfileNameAt(position = 2).check(matches(withText("A"))) } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - runInTestActivityAndAddFragment { - // The second profile has a different learner ID. - onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) - onLearnerIdAt(position = 2).check(matches(withText("208663b0"))) - } + initializeActivityAndAddFragment() + + // The second profile has a different learner ID. + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + onLearnerIdAt(position = 2).check(matches(withText("208663b0"))) } @Test fun testFragment_multipleProfiles_copySecondEntry_copiesDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 2).perform(click()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() - val clipData = getCurrentClipData() - assertThat(clipData?.description?.label).isEqualTo("A's learner ID") - assertThat(clipData?.itemCount).isEqualTo(1) - assertThat(clipData?.getItemAt(0)?.text).isEqualTo("208663b0") - } + onLearnerIdCopyButtonAt(position = 2).perform(click()) + testCoroutineDispatchers.runCurrent() + + val clipData = getCurrentClipData() + assertThat(clipData?.description?.label).isEqualTo("A's learner ID") + assertThat(clipData?.itemCount).isEqualTo(1) + assertThat(clipData?.getItemAt(0)?.text).isEqualTo("208663b0") } @Test fun testFragment_initialState_deviceIdCopyButtonHasCopyLabel() { - runInTestActivityAndAddFragment { - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - } + initializeActivityAndAddFragment() + + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) } @Test fun testFragment_adminProfile_initialState_learnerIdCopyButtonHasCopyLabel() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) - } + initializeActivityAndAddFragment() + + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) } @Test fun testFragment_adminProfile_clickDeviceIdCopyButton_deviceIdIsCopiedButNotLearnerId() { - runInTestActivityAndAddFragment { - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) - } + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() + + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_learnerIdIsCopiedButNotDeviceId() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) - } + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() + + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_copyInOtherApp_nothingIsCopied() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - updateClipDataAsThoughFromAnotherApp() + updateClipDataAsThoughFromAnotherApp() - // Changing the clipboard in a different app should reset the labels. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) - } + // Changing the clipboard in a different app should reset the labels. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_rotate_learnerIdStillCopied() { - runInTestActivityAndAddFragment { - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - // The button label should be restored after a rotation. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) - } + // The button label should be restored after a rotation. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) } @Test fun testFragment_multipleProfiles_rotate_profilesStillPresent() { profileTestHelper.addMoreProfiles(numProfiles = 5) + initializeActivityAndAddFragment() - runInTestActivityAndAddFragment { - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) - } + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) } @Test fun testFragment_firstEntry_noAdminEvents_hasZeroAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) + initializeActivityAndAddFragment() - runInTestActivityAndAddFragment { - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - } + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) } @Test fun testFragment_firstEntry_adminEvents_notUploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - } + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) } @Test fun testFragment_firstEntry_adminEvents_uploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - } + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) } @Test fun testFragment_firstEntry_noGenericEvents_hasZeroGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) + initializeActivityAndAddFragment() - runInTestActivityAndAddFragment { - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - } + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) } @Test fun testFragment_firstEntry_genericEvents_notUploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events off of the admin profile. - logTwoAnalyticsEvents(profileId = null) + // Log a couple of events off of the admin profile. + logTwoAnalyticsEvents(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - } + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) } @Test fun testFragment_firstEntry_genericEvents_uploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event, off of the admin profile. - logTwoAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) + // Log a couple of events, upload them, then log one more event, off of the admin profile. + logTwoAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) - } + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) } @Test fun testFragment_firstEntry_mixOfAdminAndGenericEvents_someUploaded_reportsAllEvents() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Log & upload a mix of events with and without the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logThreeAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - - // Event counts should be represented in the correct places. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Log & upload a mix of events with and without the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logThreeAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + + // Event counts should be represented in the correct places. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) } @Test fun testFragment_secondEntry_noLearnerEvents_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) + initializeActivityAndAddFragment() - runInTestActivityAndAddFragment { - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - } + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) } @Test fun testFragment_secondEntry_learnerEvents_notUploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - } + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) } @Test fun testFragment_secondEntry_learnerEvents_uploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) - } + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) } @Test fun testFragment_secondEntry_learnerEvents_hasZeroAdminOrGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events, upload them, then log one more event, for a learner profile. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - - // The admin profile's event counts shouldn't change since the only logged events were for a - // specific learner profile. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events, upload them, then log one more event, for a learner profile. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + + // The admin profile's event counts shouldn't change since the only logged events were for a + // specific learner profile. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) } @Test fun testFragment_secondEntry_adminAndGenericEvents_uploaded_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events generically and for the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - - // No events should be reported for the learner since it didn't have any events uploaded. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events generically and for the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + + // No events should be reported for the learner since it didn't have any events uploaded. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) } @Test fun testFragment_initialState_profileDataHasYetToBeCollected() { - runInTestActivityAndAddFragment { - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) - } + initializeActivityAndAddFragment() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) } @Test fun testFragment_initialState_wait_profileDataHasYetToBeCollected() { - runInTestActivityAndAddFragment { - testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) + initializeActivityAndAddFragment() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) - } + testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) } @Test fun testFragment_eventLogged_waitingForUpload_indicatorTextMentionsWaiting() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. - // Note that the extra event log is a slight hack to force a refresh of the status indicator - // (since network changes are polled when there are other changes to represent rather than - // being actively "pushed" by the system). - logAnalyticsEvent() - connectNetwork() - logAnalyticsEvent() - - // The status indicator is suggesting that events can be uploaded (and there are some - // available to upload), they just haven't been scheduled yet. - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. Note + // that the extra event log is a slight hack to force a refresh of the status indicator (since + // network changes are polled when there are other changes to represent rather than being + // actively "pushed" by the system). + logAnalyticsEvent() + connectNetwork() + logAnalyticsEvent() + + // The status indicator is suggesting that events can be uploaded (and there are some available + // to upload), they just haven't been scheduled yet. + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) } @Test fun testFragment_eventLogged_waitingForUpload_uploadStarted_profileDataIsCurrentlyUploading() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to - // produce the same situation to ensure the label is correct. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to + // produce the same situation to ensure the label is correct. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) - } + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) } @Test fun testFragment_noConnectivity_indicatorTextMentionsDataCannotBeUploaded() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Enqueue an event but don't reconnect to the network. - logAnalyticsEvent() - - // The status indicator is suggesting that internet connectivity needs to resume in order to - // upload events. - onSyncStatusAt(position = 2) - .check( - matches( - withText( - containsString( - "Please connect to a WiFi or Cellular network in order to upload profile data" - ) + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Enqueue an event but don't reconnect to the network. + logAnalyticsEvent() + + // The status indicator is suggesting that internet connectivity needs to resume in order to + // upload events. + onSyncStatusAt(position = 2) + .check( + matches( + withText( + containsString( + "Please connect to a WiFi or Cellular network in order to upload profile data" ) ) ) - } + ) } @Test fun testFragment_eventLogged_waitForUpload_profileDataIsUploaded() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) - } + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) } @Test fun testFragment_eventLogged_uploadError_profileDataHasError() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() - // An upload error can currently only be simulated by directly influencing the sync manager. - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() + // An upload error can currently only be simulated by directly influencing the sync manager. + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check( - matches(withText(containsString("Something went wrong when trying to upload events"))) - ) - } + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Something went wrong when trying to upload events")))) } @Test fun testFragment_eventLogged_uploadError_anotherLogged_wait_profileDataIsUploading() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.reportUploadError() - testCoroutineDispatchers.runCurrent() - - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.reportUploadError() + testCoroutineDispatchers.runCurrent() + + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) } @Test fun testFragment_rotate_profileDataHasYetToBeCollected() { - runInTestActivityAndAddFragment { - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) - } + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) } @Test fun testFragment_eventLogged_waitingForUpload_rotate_profileDataIsCurrentlyUploading() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) - } + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) } @Test fun testFragment_eventLogged_waitForUpload_rotate_profileDataIsUploaded() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) - } + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) } @Test fun testFragment_eventsLogged_uploadError_rotate_profileDataHasError() { - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() - - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() - - onSyncStatusAt(position = 2) - .check( - matches(withText(containsString("Something went wrong when trying to upload events"))) - ) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() + + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Something went wrong when trying to upload events")))) } @Test @@ -776,141 +753,129 @@ class ProfileAndDeviceIdFragmentTest { // Use fake time so that the generated event logs are consistent across runs. fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) profileTestHelper.addMoreProfiles(numProfiles = 2) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - - // Log & upload some events, then enqueue others. - logThreeAnalyticsEvents(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - - onShareIdsAndEventsButtonAt(position = 5).perform(click()) - testCoroutineDispatchers.runCurrent() - - val expectedShareText = - """ - Oppia app installation ID: 113e04cc09a3 - - Profile name: Admin, learner ID: 8dcbbd21 - - Uploading learner events: 3 - - Uploaded learner events: 2 - - Uploading uncategorized events: 1 - - Uploaded uncategorized events: 4 - - Profile name: A, learner ID: 208663b0 - - Uploading learner events: 2 - - Uploaded learner events: 1 - - Profile name: B, learner ID: 92d0c6e2 - - Uploading learner events: 1 - - Uploaded learner events: 2 - Current sync status: Waiting to schedule data uploading worker…. - Event log encoding integrity checks: - - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY - - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 - - Total event string length (unwrapped): 140 - Encoded event logs: - H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ - gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - """.trimIndent() - val intents = getIntents() - assertThat(intents).hasSize(1) - assertThat(intents.single()).hasAction(Intent.ACTION_SEND) - assertThat(intents.single()).hasType("text/plain") - assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) - assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + + // Log & upload some events, then enqueue others. + logThreeAnalyticsEvents(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + + onShareIdsAndEventsButtonAt(position = 5).perform(click()) + testCoroutineDispatchers.runCurrent() + + val expectedShareText = + """ + Oppia app installation ID: 113e04cc09a3 + - Profile name: Admin, learner ID: 8dcbbd21 + - Uploading learner events: 3 + - Uploaded learner events: 2 + - Uploading uncategorized events: 1 + - Uploaded uncategorized events: 4 + - Profile name: A, learner ID: 208663b0 + - Uploading learner events: 2 + - Uploaded learner events: 1 + - Profile name: B, learner ID: 92d0c6e2 + - Uploading learner events: 1 + - Uploaded learner events: 2 + Current sync status: Waiting to schedule data uploading worker…. + Event log encoding integrity checks: + - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY + - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 + - Total event string length (unwrapped): 140 + Encoded event logs: + H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ + gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + """.trimIndent() + val intents = getIntents() + assertThat(intents).hasSize(1) + assertThat(intents.single()).hasAction(Intent.ACTION_SEND) + assertThat(intents.single()).hasType("text/plain") + assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) + assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) } @Test fun testFragment_noEventsPending_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - // The upload button should be disabled when there are no events to upload. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) - } + // The upload button should be disabled when there are no events to upload. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) } @Test fun testFragment_multipleEventsPending_noConnection_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // The button is still disabled since there's no internet connection. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) - } + // The button is still disabled since there's no internet connection. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) } @Test fun testFragment_multipleEventsPending_uploadLogsButtonEnabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - // With events pending & connectivity, the upload button should now be available to press. - onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) - } + // With events pending & connectivity, the upload button should now be available to press. + onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) } @Test fun testFragment_multipleEventsPending_clickUploadLogs_wait_uploadsEventLogs() { profileTestHelper.addMoreProfiles(numProfiles = 1) - runInTestActivityAndAddFragment { - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - fakeAnalyticsEventLogger.clearAllEvents() - - // Click the 'upload logs' button and wait. - onUploadLogsButtonAt(position = 4).perform(click()) - testCoroutineDispatchers.runCurrent() - - // The events should be uploaded. - assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) - } - } + initializeActivityAndAddFragment() + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + fakeAnalyticsEventLogger.clearAllEvents() + + // Click the 'upload logs' button and wait. + onUploadLogsButtonAt(position = 4).perform(click()) + testCoroutineDispatchers.runCurrent() - private fun runInTestActivityAndAddFragment(testBlock: () -> Unit) { - launchActivityAndAddFragment().use { scenario -> - scenario.onActivity { activity -> - activity.setContentView(R.layout.test_activity) + // The events should be uploaded. + assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) + } - activity.supportFragmentManager.beginTransaction() - .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) - .commitNow() - } - connectNetwork() // Start with internet connectivity. - testCoroutineDispatchers.runCurrent() + private fun initializeActivityAndAddFragment() { + activityRule.scenario.onActivity { activity -> + activity.setContentView(R.layout.test_activity) - testBlock() + activity.supportFragmentManager.beginTransaction() + .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) + .commitNow() } + connectNetwork() // Start with internet connectivity. + testCoroutineDispatchers.runCurrent() } - private fun launchActivityAndAddFragment() = - ActivityScenario.launch(createIntent(ApplicationProvider.getApplicationContext())) - private fun scrollTo(position: Int) { onView(withId(R.id.profile_and_device_id_recycler_view)) .perform(actionOnItemAtPosition(position, scrollTo())) diff --git a/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt index 58b99cf4db5..6850c951041 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/docs/KdocValidityCheckTest.kt @@ -46,7 +46,7 @@ class KdocValidityCheckTest { val testContent = """ /** - * Returns the string corresponding to this error's string resources, or null if there + * Returns the string corresponding to this error's string resources, or null if there * is none. */ fun getErrorMessageFromStringRes(context: Context): String? { @@ -260,7 +260,7 @@ class KdocValidityCheckTest { val testContent = """ val testVal = "testContent" - + fun provideContext(application: Application): Context """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFileTest.kt") @@ -281,16 +281,14 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:2 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -352,21 +350,19 @@ class KdocValidityCheckTest { fun testKdoc_class_withoutKdoc_checkShouldFail() { val testContent = """ - class TestClass {} + class TestClass {} """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -382,21 +378,19 @@ class KdocValidityCheckTest { class NestedClass { class NestedLevel2Class {} } - } + } """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:5 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -409,16 +403,14 @@ class KdocValidityCheckTest { /** Test KDoc 1. */ class TestClass { val testVal = "test" - + fun testFunc(){} - } + } """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -426,7 +418,7 @@ class KdocValidityCheckTest { KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:3 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:5 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -442,9 +434,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -452,7 +442,7 @@ class KdocValidityCheckTest { KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:1 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:2 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -468,16 +458,14 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:2 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -495,16 +483,14 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:4 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -522,9 +508,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -533,7 +517,7 @@ class KdocValidityCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:1 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:2 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:3 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -544,15 +528,13 @@ class KdocValidityCheckTest { val testContent = """ const val TABLE_USER_ATTRIBUTE_EMPID = "_id" - + const val TABLE_USER_ATTRIBUTE_DATA = "data" """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -560,7 +542,7 @@ class KdocValidityCheckTest { KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:1 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:3 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -572,21 +554,19 @@ class KdocValidityCheckTest { """ fun getErrorMessageFromStringRes(context: Context): String? { return error?.let(context::getString) - } + } """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -604,16 +584,14 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:3 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -627,14 +605,12 @@ class KdocValidityCheckTest { WELCOME(0), TOPIC_LIST(1), FINAL(2) - } + } """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -644,7 +620,7 @@ class KdocValidityCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:2 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:3 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:4 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -655,22 +631,20 @@ class KdocValidityCheckTest { val testContent = """ interface ChapterSelector { - + fun chapterSelected(chapterIndex: Int, nextStoryIndex: Int, explorationId: String) - + fun chapterUnselected(chapterIndex: Int, nextStoryIndex: Int) - + interface ChildInterface { fun testFunction() } - } + } """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -681,7 +655,7 @@ class KdocValidityCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:5 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:7 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:8 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -695,11 +669,11 @@ class KdocValidityCheckTest { class TestClass { companion object { val pos = 1 - + fun incrementedPosition(position: Int): Int { return position+1 } - + fun decrementedPosition(position: Int): Int { return position-1 } @@ -709,9 +683,7 @@ class KdocValidityCheckTest { val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -720,7 +692,7 @@ class KdocValidityCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:4 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:6 - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:10 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -748,23 +720,21 @@ class KdocValidityCheckTest { val testContent = """ import javax.inject.Qualifier - + @Qualifier annotation class DelayShowAdditionalHintsFromWrongAnswerMillis """.trimIndent() val tempFile = tempFolder.newFile("testfiles/TempFile.kt") tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/TempFile.kt:4 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -775,7 +745,7 @@ class KdocValidityCheckTest { val testContent1 = """ import javax.inject.Qualifier - + @Qualifier annotation class DelayShowAdditionalHintsFromWrongAnswerMillis """.trimIndent() @@ -783,9 +753,9 @@ class KdocValidityCheckTest { """ class TestClass { fun testFunc(){} - + private val testVal = "test" - + val testVal2 = "test2" } """.trimIndent() @@ -800,9 +770,7 @@ class KdocValidityCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -813,7 +781,7 @@ class KdocValidityCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile2.kt:2 - ${retrieveTestFilesDirectoryPath()}/TempFile2.kt:6 - ${retrieveTestFilesDirectoryPath()}/TempFile3.kt:1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -825,9 +793,9 @@ class KdocValidityCheckTest { """ /** test kdoc. */ val testVal1 = "test content" - + val testVal2 = "test content" - + fun getErrorMessageFromStringRes(context: Context): String? { return error?.let(context::getString) } @@ -858,7 +826,7 @@ class KdocValidityCheckTest { """ /** test Kdoc1. */ val testVal = "test content" - + /** test Kdoc2. */ fun getErrorMessageFromStringRes(context: Context): String? { return error?.let(context::getString) @@ -879,9 +847,7 @@ class KdocValidityCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -913,9 +879,7 @@ class KdocValidityCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(KDOC_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -923,10 +887,10 @@ class KdocValidityCheckTest { Redundant exemptions: - app/src/main/java/org/oppia/android/app/splash/SplashActivity.kt Please remove them from scripts/assets/kdoc_validity_exemptions.textproto - + KDoc missing for files: - ${retrieveTestFilesDirectoryPath()}/HomeActivity.kt:1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) diff --git a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt index 39550f0f8ae..c555f4cba76 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -257,9 +257,7 @@ class RegexPatternValidationCheckTest { val tempFile = tempFolder.newFile("testfiles/data/src/main/TestActivity.kt") tempFile.writeText(requiredContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()).isEqualTo( @@ -287,9 +285,7 @@ class RegexPatternValidationCheckTest { tempFolder.newFolder("testfiles", "app", "src", "main", "res", "values", "subdir") tempFolder.newFile("testfiles/app/src/main/res/values/subdir/strings.xml") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()).isEqualTo( @@ -307,16 +303,14 @@ class RegexPatternValidationCheckTest { tempFolder.newFolder("testfiles", "domain", "src", "main", "res", "drawable", "subdir") tempFolder.newFile("testfiles/domain/src/main/res/drawable/subdir/example.png") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()).isEqualTo( """ File name/path violation: $nestedResourceSubdirectoryErrorMessage - domain/src/main/res/drawable/subdir/example.png - + $wikiReferenceNote """.trimIndent() ) @@ -337,9 +331,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -357,9 +349,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -377,9 +367,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -397,9 +385,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -417,9 +403,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/TestFile.kt") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -437,9 +421,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -457,9 +439,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -477,9 +457,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -497,9 +475,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -517,9 +493,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -537,9 +511,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -557,9 +529,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -577,9 +547,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -597,9 +565,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -617,9 +583,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -637,9 +601,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -657,9 +619,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -677,9 +637,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -697,9 +655,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -717,9 +673,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -737,9 +691,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -757,9 +709,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -777,9 +727,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -797,9 +745,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -817,9 +763,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -837,9 +781,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -857,9 +799,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -877,9 +817,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -897,9 +835,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -917,9 +853,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -937,9 +871,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -957,9 +889,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -977,9 +907,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -997,9 +925,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = tempFolder.newFile("testfiles/test_layout.xml") fileContainsSupportLibraryImport.writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1018,9 +944,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1039,9 +963,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1072,9 +994,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/untranslated_strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1093,9 +1013,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/untranslated_strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1114,9 +1032,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1135,9 +1051,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1207,9 +1121,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1250,9 +1162,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.java" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1285,9 +1195,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1317,9 +1225,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1345,9 +1251,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1370,9 +1274,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1400,9 +1302,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/strings.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1443,9 +1343,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1465,9 +1363,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1487,9 +1383,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent + requiredContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1508,9 +1402,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/SomeDialogFragment.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1541,9 +1433,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1571,9 +1461,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1601,9 +1489,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/AndroidManifest.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1622,9 +1508,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1643,9 +1527,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1669,9 +1551,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1692,9 +1572,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1713,9 +1591,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1745,9 +1621,7 @@ class RegexPatternValidationCheckTest { val fileContainsSupportLibraryImport = "test_layout.xml" tempFolder.newFile("testfiles/$fileContainsSupportLibraryImport").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1774,9 +1648,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/test/SomeTest.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1796,9 +1668,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "data/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1817,9 +1687,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/BUILD" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1838,9 +1706,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/BUILD.bazel" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1859,9 +1725,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "domain/src/main/SomeController.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -1881,9 +1745,7 @@ class RegexPatternValidationCheckTest { val prohibitedFile = tempFolder.newFile("testfiles/data/src/main/TestActivity.kt") prohibitedFile.writeText(prohibitedContent + requiredContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()).isEqualTo( @@ -1914,9 +1776,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -1964,9 +1824,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2012,9 +1870,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2059,9 +1915,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2123,9 +1977,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2171,9 +2023,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2218,9 +2068,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_defs.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2263,9 +2111,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/component_colors.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2311,9 +2157,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/layout/test_layout.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2381,9 +2225,7 @@ class RegexPatternValidationCheckTest { tempFolder.newFile("testfiles/$stringFilePath5").writeText(prohibitedContent) tempFolder.newFile("testfiles/$stringFilePath6").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2438,9 +2280,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/values/color_palette.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2460,9 +2300,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/activity/HomeActivity.kt" tempFolder.newFile("testfiles/$stringFilePath") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2492,9 +2330,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/activity/HomeActivityTest.kt" tempFolder.newFile("testfiles/$stringFilePath") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) assertThat(outContent.toString().trim()) @@ -2528,9 +2364,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/SomeInitializer.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2553,9 +2387,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2578,9 +2410,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2603,9 +2433,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) @@ -2702,7 +2530,7 @@ class RegexPatternValidationCheckTest { /** Content here.*/ /** Content here. **/ /** Correct KDoc. */ - + /* * Incorrect block comment. **/ diff --git a/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt index 3c22ca1ac31..1b6ded9633a 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/testfile/TestFileCheckTest.kt @@ -52,15 +52,13 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile1Test.kt") tempFolder.newFile("testfiles/ProdFile2.kt") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TEST_FILE_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ File ${retrieveTestFilesDirectoryPath()}/ProdFile2.kt $errorMessage - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -73,16 +71,14 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile2.kt") tempFolder.newFile("testfiles/ProdFile3.kt") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TEST_FILE_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ File ${retrieveTestFilesDirectoryPath()}/ProdFile2.kt does not have a corresponding test file. File ${retrieveTestFilesDirectoryPath()}/ProdFile3.kt does not have a corresponding test file. - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -95,16 +91,14 @@ class TestFileCheckTest { tempFolder.newFile("testfiles/ProdFile3.kt") tempFolder.newFile("testfiles/ProdFile2.kt") - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TEST_FILE_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ File ${retrieveTestFilesDirectoryPath()}/ProdFile2.kt does not have a corresponding test file. File ${retrieveTestFilesDirectoryPath()}/ProdFile3.kt does not have a corresponding test file. - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) diff --git a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt index 68b162340ac..6df3902ba9a 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt @@ -43,9 +43,7 @@ class TodoOpenCheckTest { @Test fun testTodoCheck_noJsonFilePresent_checkShouldFail() { - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains( "${retrieveTestFilesDirectoryPath()}/open_issues.json: No such file exists" @@ -103,9 +101,7 @@ class TodoOpenCheckTest { """.trimIndent() tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -116,7 +112,7 @@ class TodoOpenCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:3 - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:4 - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:5 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -141,9 +137,7 @@ class TodoOpenCheckTest { """.trimIndent() tempFile.writeText(testContent) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -152,7 +146,7 @@ class TodoOpenCheckTest { - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:1 - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:2 - ${retrieveTestFilesDirectoryPath()}/TempFile.txt:5 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -185,9 +179,7 @@ class TodoOpenCheckTest { tempFile1.writeText(testContent1) tempFile2.writeText(testContent2) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -195,11 +187,11 @@ class TodoOpenCheckTest { TODOs not in correct format: - ${retrieveTestFilesDirectoryPath()}/TempFile1.kt:2 - ${retrieveTestFilesDirectoryPath()}/TempFile2.kt:1 - + TODOs not corresponding to open issues on GitHub: - ${retrieveTestFilesDirectoryPath()}/TempFile1.kt:1 - ${retrieveTestFilesDirectoryPath()}/TempFile2.kt:3 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -239,9 +231,7 @@ class TodoOpenCheckTest { tempFile2.writeText(testContent2) tempFile3.writeText(testContent3) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -250,11 +240,11 @@ class TodoOpenCheckTest { - ${retrieveTestFilesDirectoryPath()}/Activity.kt:2 - ${retrieveTestFilesDirectoryPath()}/Fragment.kt:1 - ${retrieveTestFilesDirectoryPath()}/Presenter.kt:2 - + TODOs not corresponding to open issues on GitHub: - ${retrieveTestFilesDirectoryPath()}/Fragment.kt:3 - ${retrieveTestFilesDirectoryPath()}/Presenter.kt:1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -340,9 +330,7 @@ class TodoOpenCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -391,9 +379,7 @@ class TodoOpenCheckTest { }.build() exemptions.writeTo(exemptionFile.outputStream()) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(TODO_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -401,13 +387,13 @@ class TodoOpenCheckTest { Redundant exemptions (there are no TODOs corresponding to these lines): - TempFile1.kt:2 Please remove them from scripts/assets/todo_exemptions.textproto - + TODOs not in correct format: - ${retrieveTestFilesDirectoryPath()}/TempFile2.kt:1 - + TODOs not corresponding to open issues on GitHub: - ${retrieveTestFilesDirectoryPath()}/TempFile1.kt:3 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) diff --git a/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt index 293cca1e47e..bc78d44296e 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/xml/XmlSyntaxCheckTest.kt @@ -73,15 +73,13 @@ class XmlSyntaxCheckTest { val tempFile = tempFolder.newFile("testfiles/TestFile.xml") tempFile.writeText(invalidXml) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(XML_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ ${retrieveTestFilesDirectoryPath()}/TestFile.xml:6:8: $syntaxFailureMessage1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -112,16 +110,14 @@ class XmlSyntaxCheckTest { tempFile1.writeText(invalidXmlForFile1) tempFile2.writeText(invalidXmlForFile2) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(XML_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = """ ${retrieveTestFilesDirectoryPath()}/TestFile1.xml:4:4: $syntaxFailureMessage2 ${retrieveTestFilesDirectoryPath()}/TestFile2.xml:6:8: $syntaxFailureMessage1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) @@ -163,9 +159,7 @@ class XmlSyntaxCheckTest { tempFile2.writeText(invalidXmlForFile2) tempFile3.writeText(invalidXmlForFile3) - val exception = assertThrows() { - runScript() - } + val exception = assertThrows() { runScript() } assertThat(exception).hasMessageThat().contains(XML_SYNTAX_CHECK_FAILED_OUTPUT_INDICATOR) val failureMessage = @@ -173,7 +167,7 @@ class XmlSyntaxCheckTest { ${retrieveTestFilesDirectoryPath()}/TestFile1.xml:4:4: $syntaxFailureMessage2 ${retrieveTestFilesDirectoryPath()}/TestFile2.xml:6:8: $syntaxFailureMessage1 ${retrieveTestFilesDirectoryPath()}/TestFile3.xml:6:8: $syntaxFailureMessage1 - + $wikiReferenceNote """.trimIndent() assertThat(outContent.toString().trim()).isEqualTo(failureMessage) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 9bed8754f08..5c6cf0abf63 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -153,10 +153,7 @@ kt_android_library( testonly = True, srcs = ["src/main/java/org/oppia/android/testing/AssertionHelpers.kt"], visibility = ["//visibility:public"], - deps = [ - "//third_party:junit_junit", - "//third_party:org_jetbrains_kotlin_kotlin-reflect", - ], + deps = ["//third_party:junit_junit"], ) filegroup( From 2551d4b908fea3f867fc2c94bdd472c468351fda Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 11 Sep 2023 23:39:38 +0000 Subject: [PATCH 03/21] Fix test behavior inconsistency in test. The issue ultimately arose from test parameters being initialized after they're needed in the launched UI. This type of change was tried earlier in the branch, but reverted since it didn't seem necessary. It is, however, necessary when there are environment differences (e.g. local vs. CI) or when running certain tests individually. Due to the difficulty in finding this issue, ActivityScenarioRule has been added as a prohibited pattern in the static regex checks (along with ActivityTestRule since that's deprecated and discouraged, anyway). --- .../ProfileAndDeviceIdFragmentTest.kt | 825 +++++++++--------- .../file_content_validation_checks.textproto | 87 ++ .../regex/RegexPatternValidationCheckTest.kt | 51 ++ 3 files changed, 567 insertions(+), 396 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index 74c37f0e6da..b7e883989f8 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -9,6 +9,7 @@ import android.view.View import androidx.annotation.IdRes import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.RecyclerView +import androidx.test.core.app.ActivityScenario import androidx.test.core.app.ApplicationProvider import androidx.test.espresso.Espresso.onView import androidx.test.espresso.ViewInteraction @@ -23,7 +24,6 @@ import androidx.test.espresso.matcher.ViewMatchers.isEnabled import androidx.test.espresso.matcher.ViewMatchers.isRoot import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText -import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.truth.content.IntentSubject.assertThat import androidx.work.Configuration @@ -147,11 +147,6 @@ import javax.inject.Singleton class ProfileAndDeviceIdFragmentTest { @get:Rule val initializeDefaultLocaleRule = InitializeDefaultLocaleRule() @get:Rule val oppiaTestRule = OppiaTestRule() - @get:Rule - var activityRule = - ActivityScenarioRule( - TestActivity.createIntent(ApplicationProvider.getApplicationContext()) - ) @Inject lateinit var profileTestHelper: ProfileTestHelper @Inject lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @@ -193,39 +188,39 @@ class ProfileAndDeviceIdFragmentTest { @Test fun testFragment_withOnlyAdminProfile_hasThreeItems() { - initializeActivityAndAddFragment() - - // There should be three items: a header, a profile, and the sync status. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) + runWithLaunchedActivityAndAddedFragment { + // There should be three items: a header, a profile, and the sync status. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 4)) + } } @Test fun testFragment_withOnlyAdminProfile_hasDeviceIdHeader() { - initializeActivityAndAddFragment() - - onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) + runWithLaunchedActivityAndAddedFragment { + onDeviceIdLabelAt(position = 0).check(matches(isDisplayed())) + } } @Test fun testFragment_hasDeviceId() { - initializeActivityAndAddFragment() - - onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("113e04cc09a3")))) + runWithLaunchedActivityAndAddedFragment { + onDeviceIdLabelAt(position = 0).check(matches(withText(containsString("113e04cc09a3")))) + } } @Test fun testFragment_deviceId_hasCopyButton() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) + runWithLaunchedActivityAndAddedFragment { + onDeviceIdCopyButtonAt(position = 0).check(matches(isDisplayed())) + } } @Test fun testFragment_deviceId_clickCopyButton_copiesDeviceIdToClipboard() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() + } val clipData = getCurrentClipData() assertThat(clipData?.description?.label).isEqualTo("Oppia installation ID") @@ -235,38 +230,38 @@ class ProfileAndDeviceIdFragmentTest { @Test fun testFragment_withOnlyAdminProfile_hasOneProfileListed() { - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(isDisplayed())) + runWithLaunchedActivityAndAddedFragment { + onProfileNameAt(position = 1).check(matches(isDisplayed())) + } } @Test fun testFragment_profileEntry_hasProfileName() { - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(withText("Admin"))) + runWithLaunchedActivityAndAddedFragment { + onProfileNameAt(position = 1).check(matches(withText("Admin"))) + } } @Test fun testFragment_profileEntry_hasLearnerId() { - initializeActivityAndAddFragment() - - onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + runWithLaunchedActivityAndAddedFragment { + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + } } @Test fun testFragment_profileEntry_hasCopyButton() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).check(matches(isDisplayed())) + } } @Test fun testFragment_profileEntry_clickFirstCopyButton_copiesAdminLearnerIdToClipboard() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() + } val clipData = getCurrentClipData() assertThat(clipData?.description?.label).isEqualTo("Admin's learner ID") @@ -278,50 +273,50 @@ class ProfileAndDeviceIdFragmentTest { fun testFragment_multipleProfiles_listsAllProfiles() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // Header + admin + 5 new profiles + sync status = 8 items. - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + runWithLaunchedActivityAndAddedFragment { + // Header + admin + 5 new profiles + sync status = 8 items. + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + } } @Test fun testFragment_multipleProfiles_adminIsFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - onProfileNameAt(position = 1).check(matches(withText("Admin"))) + runWithLaunchedActivityAndAddedFragment { + onProfileNameAt(position = 1).check(matches(withText("Admin"))) + } } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentName() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // The second entry is not the admin. - onProfileNameAt(position = 2).check(matches(withText("A"))) + runWithLaunchedActivityAndAddedFragment { + // The second entry is not the admin. + onProfileNameAt(position = 2).check(matches(withText("A"))) + } } @Test fun testFragment_multipleProfiles_secondEntryHasDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - // The second profile has a different learner ID. - onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) - onLearnerIdAt(position = 2).check(matches(withText("208663b0"))) + runWithLaunchedActivityAndAddedFragment { + // The second profile has a different learner ID. + onLearnerIdAt(position = 1).check(matches(withText("8dcbbd21"))) + onLearnerIdAt(position = 2).check(matches(withText("208663b0"))) + } } @Test fun testFragment_multipleProfiles_copySecondEntry_copiesDifferentLearnerIdThanFirst() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 2).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 2).perform(click()) + testCoroutineDispatchers.runCurrent() + } val clipData = getCurrentClipData() assertThat(clipData?.description?.label).isEqualTo("A's learner ID") @@ -331,421 +326,449 @@ class ProfileAndDeviceIdFragmentTest { @Test fun testFragment_initialState_deviceIdCopyButtonHasCopyLabel() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + runWithLaunchedActivityAndAddedFragment { + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_initialState_learnerIdCopyButtonHasCopyLabel() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickDeviceIdCopyButton_deviceIdIsCopiedButNotLearnerId() { - initializeActivityAndAddFragment() - - onDeviceIdCopyButtonAt(position = 0).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onDeviceIdCopyButtonAt(position = 0).perform(click()) + testCoroutineDispatchers.runCurrent() - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copied"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_learnerIdIsCopiedButNotDeviceId() { - initializeActivityAndAddFragment() - - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_copyInOtherApp_nothingIsCopied() { - initializeActivityAndAddFragment() - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - updateClipDataAsThoughFromAnotherApp() + updateClipDataAsThoughFromAnotherApp() - // Changing the clipboard in a different app should reset the labels. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + // Changing the clipboard in a different app should reset the labels. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copy"))) + } } @Test fun testFragment_adminProfile_clickLearnerIdCopyButton_rotate_learnerIdStillCopied() { - initializeActivityAndAddFragment() - onLearnerIdCopyButtonAt(position = 1).perform(click()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onLearnerIdCopyButtonAt(position = 1).perform(click()) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - // The button label should be restored after a rotation. - onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) - onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + // The button label should be restored after a rotation. + onDeviceIdCopyButtonAt(position = 0).check(matches(withText("Copy"))) + onLearnerIdCopyButtonAt(position = 1).check(matches(withText("Copied"))) + } } @Test fun testFragment_multipleProfiles_rotate_profilesStillPresent() { profileTestHelper.addMoreProfiles(numProfiles = 5) - initializeActivityAndAddFragment() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + onView(withId(R.id.profile_and_device_id_recycler_view)).check(hasItemCount(count = 9)) + } } @Test fun testFragment_firstEntry_noAdminEvents_hasZeroAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + runWithLaunchedActivityAndAddedFragment { + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_adminEvents_notUploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_adminEvents_uploaded_hasSomeAdminEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + } } @Test fun testFragment_firstEntry_noGenericEvents_hasZeroGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + runWithLaunchedActivityAndAddedFragment { + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_genericEvents_notUploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events off of the admin profile. - logTwoAnalyticsEvents(profileId = null) + // Log a couple of events off of the admin profile. + logTwoAnalyticsEvents(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_firstEntry_genericEvents_uploaded_hasSomeGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event, off of the admin profile. - logTwoAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) + // Log a couple of events, upload them, then log one more event, off of the admin profile. + logTwoAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("2"))) + } } @Test fun testFragment_firstEntry_mixOfAdminAndGenericEvents_someUploaded_reportsAllEvents() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log & upload a mix of events with and without the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logThreeAnalyticsEvents(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - - // Event counts should be represented in the correct places. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Log & upload a mix of events with and without the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logThreeAnalyticsEvents(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + + // Event counts should be represented in the correct places. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("1"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("1"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("3"))) + } } @Test fun testFragment_secondEntry_noLearnerEvents_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + runWithLaunchedActivityAndAddedFragment { + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_learnerEvents_notUploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - // Two are awaiting upload, but neither have been uploaded yet. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + // Two are awaiting upload, but neither have been uploaded yet. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_learnerEvents_uploaded_hasSomeLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Log a couple of events, upload them, then log one more event. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + // Log a couple of events, upload them, then log one more event. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // Two should be uploaded, and one waiting upload. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + // Two should be uploaded, and one waiting upload. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("1"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("2"))) + } } @Test fun testFragment_secondEntry_learnerEvents_hasZeroAdminOrGenericEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events, upload them, then log one more event, for a learner profile. - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - - // The admin profile's event counts shouldn't change since the only logged events were for a - // specific learner profile. - onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) - onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) - onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events, upload them, then log one more event, for a learner profile. + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + + // The admin profile's event counts shouldn't change since the only logged events were for a + // specific learner profile. + onAwaitingUploadLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 1).check(matches(withText("0"))) + onAwaitingUploadUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + onUploadedUncategorizedEventsCountAt(position = 1).check(matches(withText("0"))) + } } @Test fun testFragment_secondEntry_adminAndGenericEvents_uploaded_hasZeroLearnerEventsReported() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log a couple of events generically and for the admin profile. - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = null) - - // No events should be reported for the learner since it didn't have any events uploaded. - onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) - onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Log a couple of events generically and for the admin profile. + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = null) + + // No events should be reported for the learner since it didn't have any events uploaded. + onAwaitingUploadLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + onUploadedLearnerEventsCountAt(position = 2).check(matches(withText("0"))) + } } @Test fun testFragment_initialState_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + runWithLaunchedActivityAndAddedFragment { + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_initialState_wait_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() - - testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) + runWithLaunchedActivityAndAddedFragment { + testCoroutineDispatchers.advanceTimeBy(delayTimeMillis = TimeUnit.SECONDS.toMillis(1)) - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_indicatorTextMentionsWaiting() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. Note - // that the extra event log is a slight hack to force a refresh of the status indicator (since - // network changes are polled when there are other changes to represent rather than being - // actively "pushed" by the system). - logAnalyticsEvent() - connectNetwork() - logAnalyticsEvent() - - // The status indicator is suggesting that events can be uploaded (and there are some available - // to upload), they just haven't been scheduled yet. - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Enqueue the event, but don't actually begin uploading it, then reconnect to the network. + // Note that the extra event log is a slight hack to force a refresh of the status indicator + // (since network changes are polled when there are other changes to represent rather than + // being actively "pushed" by the system). + logAnalyticsEvent() + connectNetwork() + logAnalyticsEvent() + + // The status indicator is suggesting that events can be uploaded (and there are some + // available to upload), they just haven't been scheduled yet. + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Waiting to schedule data uploading worker…")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_uploadStarted_profileDataIsCurrentlyUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to - // produce the same situation to ensure the label is correct. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + // Unfortunately, it's tricky to pause the actual upload worker so this is a hacky way to + // produce the same situation to ensure the label is correct. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) + } } @Test fun testFragment_noConnectivity_indicatorTextMentionsDataCannotBeUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Enqueue an event but don't reconnect to the network. - logAnalyticsEvent() - - // The status indicator is suggesting that internet connectivity needs to resume in order to - // upload events. - onSyncStatusAt(position = 2) - .check( - matches( - withText( - containsString( - "Please connect to a WiFi or Cellular network in order to upload profile data" + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Enqueue an event but don't reconnect to the network. + logAnalyticsEvent() + + // The status indicator is suggesting that internet connectivity needs to resume in order to + // upload events. + onSyncStatusAt(position = 2) + .check( + matches( + withText( + containsString( + "Please connect to a WiFi or Cellular network in order to upload profile data" + ) ) ) ) - ) + } } @Test fun testFragment_eventLogged_waitForUpload_profileDataIsUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_eventLogged_uploadError_profileDataHasError() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() - // An upload error can currently only be simulated by directly influencing the sync manager. - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() + // An upload error can currently only be simulated by directly influencing the sync manager. + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Something went wrong when trying to upload events")))) + onSyncStatusAt(position = 2) + .check( + matches(withText(containsString("Something went wrong when trying to upload events"))) + ) + } } @Test fun testFragment_eventLogged_uploadError_anotherLogged_wait_profileDataIsUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.reportUploadError() - testCoroutineDispatchers.runCurrent() - - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.reportUploadError() + testCoroutineDispatchers.runCurrent() + + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() + + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_rotate_profileDataHasYetToBeCollected() { - initializeActivityAndAddFragment() - - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("No data has been collected yet to upload")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("No data has been collected yet to upload")))) + } } @Test fun testFragment_eventLogged_waitingForUpload_rotate_profileDataIsCurrentlyUploading() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) - testCoroutineDispatchers.runCurrent() + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.DATA_UPLOADING) + testCoroutineDispatchers.runCurrent() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Profile data is currently uploading")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("Profile data is currently uploading")))) + } } @Test fun testFragment_eventLogged_waitForUpload_rotate_profileDataIsUploaded() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - connectNetwork() - flushEventWorkerQueue() + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + connectNetwork() + flushEventWorkerQueue() - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("All profile data has been uploaded")))) + onSyncStatusAt(position = 2) + .check(matches(withText(containsString("All profile data has been uploaded")))) + } } @Test fun testFragment_eventsLogged_uploadError_rotate_profileDataHasError() { - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent() - syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) - testCoroutineDispatchers.runCurrent() - - onView(isRoot()).perform(orientationLandscape()) - testCoroutineDispatchers.runCurrent() - - onSyncStatusAt(position = 2) - .check(matches(withText(containsString("Something went wrong when trying to upload events")))) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent() + syncStatusManager.forceSyncStatus(SyncStatus.UPLOAD_ERROR) + testCoroutineDispatchers.runCurrent() + + onView(isRoot()).perform(orientationLandscape()) + testCoroutineDispatchers.runCurrent() + + onSyncStatusAt(position = 2) + .check( + matches(withText(containsString("Something went wrong when trying to upload events"))) + ) + } } @Test @@ -753,127 +776,137 @@ class ProfileAndDeviceIdFragmentTest { // Use fake time so that the generated event logs are consistent across runs. fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) profileTestHelper.addMoreProfiles(numProfiles = 2) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - - // Log & upload some events, then enqueue others. - logThreeAnalyticsEvents(profileId = null) - logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) - connectOnlyToFlushWorkerQueue() - logAnalyticsEvent(profileId = null) - logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) - logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - - onShareIdsAndEventsButtonAt(position = 5).perform(click()) - testCoroutineDispatchers.runCurrent() - - val expectedShareText = - """ - Oppia app installation ID: 113e04cc09a3 - - Profile name: Admin, learner ID: 8dcbbd21 - - Uploading learner events: 3 - - Uploaded learner events: 2 - - Uploading uncategorized events: 1 - - Uploaded uncategorized events: 4 - - Profile name: A, learner ID: 208663b0 - - Uploading learner events: 2 - - Uploaded learner events: 1 - - Profile name: B, learner ID: 92d0c6e2 - - Uploading learner events: 1 - - Uploaded learner events: 2 - Current sync status: Waiting to schedule data uploading worker…. - Event log encoding integrity checks: - - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY - - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 - - Total event string length (unwrapped): 140 - Encoded event logs: - H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ - gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - """.trimIndent() - val intents = getIntents() - assertThat(intents).hasSize(1) - assertThat(intents.single()).hasAction(Intent.ACTION_SEND) - assertThat(intents.single()).hasType("text/plain") - assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) - assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + + // Log & upload some events, then enqueue others. + logThreeAnalyticsEvents(profileId = null) + logTwoAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_1) + connectOnlyToFlushWorkerQueue() + logAnalyticsEvent(profileId = null) + logThreeAnalyticsEvents(profileId = ADMIN_PROFILE_ID) + logTwoAnalyticsEvents(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_1) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + + onShareIdsAndEventsButtonAt(position = 5).perform(click()) + testCoroutineDispatchers.runCurrent() + + val expectedShareText = + """ + Oppia app installation ID: 113e04cc09a3 + - Profile name: Admin, learner ID: 8dcbbd21 + - Uploading learner events: 3 + - Uploaded learner events: 2 + - Uploading uncategorized events: 1 + - Uploaded uncategorized events: 4 + - Profile name: A, learner ID: 208663b0 + - Uploading learner events: 2 + - Uploaded learner events: 1 + - Profile name: B, learner ID: 92d0c6e2 + - Uploading learner events: 1 + - Uploaded learner events: 2 + Current sync status: Waiting to schedule data uploading worker…. + Event log encoding integrity checks: + - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY + - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 + - Total event string length (unwrapped): 140 + Encoded event logs: + H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ + gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA + """.trimIndent() + val intents = getIntents() + assertThat(intents).hasSize(1) + assertThat(intents.single()).hasAction(Intent.ACTION_SEND) + assertThat(intents.single()).hasType("text/plain") + assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) + assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) + } } @Test fun testFragment_noEventsPending_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - // The upload button should be disabled when there are no events to upload. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + // The upload button should be disabled when there are no events to upload. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + } } @Test fun testFragment_multipleEventsPending_noConnection_uploadLogsButtonDisabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - // The button is still disabled since there's no internet connection. - onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + // The button is still disabled since there's no internet connection. + onUploadLogsButtonAt(position = 4).check(matches(not(isEnabled()))) + } } @Test fun testFragment_multipleEventsPending_uploadLogsButtonEnabled() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - // With events pending & connectivity, the upload button should now be available to press. - onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) + // With events pending & connectivity, the upload button should now be available to press. + onUploadLogsButtonAt(position = 4).check(matches(isEnabled())) + } } @Test fun testFragment_multipleEventsPending_clickUploadLogs_wait_uploadsEventLogs() { profileTestHelper.addMoreProfiles(numProfiles = 1) - initializeActivityAndAddFragment() - disconnectNetwork() // Ensure events are cached. - logAnalyticsEvent(profileId = null) - logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) - logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) - connectNetwork() - logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. - fakeAnalyticsEventLogger.clearAllEvents() - - // Click the 'upload logs' button and wait. - onUploadLogsButtonAt(position = 4).perform(click()) - testCoroutineDispatchers.runCurrent() - - // The events should be uploaded. - assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) + runWithLaunchedActivityAndAddedFragment { + disconnectNetwork() // Ensure events are cached. + logAnalyticsEvent(profileId = null) + logAnalyticsEvent(profileId = ADMIN_PROFILE_ID) + logAnalyticsEvent(profileId = LEARNER_PROFILE_ID_0) + connectNetwork() + logAnalyticsEvent(profileId = null) // Log an event to trigger tracking the network change. + fakeAnalyticsEventLogger.clearAllEvents() + + // Click the 'upload logs' button and wait. + onUploadLogsButtonAt(position = 4).perform(click()) + testCoroutineDispatchers.runCurrent() + + // The events should be uploaded. + assertThat(fakeAnalyticsEventLogger.getEventListCount()).isEqualTo(3) + } } - private fun initializeActivityAndAddFragment() { - activityRule.scenario.onActivity { activity -> - activity.setContentView(R.layout.test_activity) - - activity.supportFragmentManager.beginTransaction() - .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) - .commitNow() + private fun runWithLaunchedActivityAndAddedFragment( + testBlock: ActivityScenario.() -> Unit + ) { + ActivityScenario.launch(TestActivity.createIntent(context)).use { scenario -> + scenario.onActivity { activity -> + activity.setContentView(R.layout.test_activity) + + activity.supportFragmentManager.beginTransaction() + .add(R.id.test_fragment_placeholder, ProfileAndDeviceIdFragment()) + .commitNow() + } + connectNetwork() // Start with internet connectivity. + testCoroutineDispatchers.runCurrent() + scenario.testBlock() } - connectNetwork() // Start with internet connectivity. - testCoroutineDispatchers.runCurrent() } private fun scrollTo(position: Int) { diff --git a/scripts/assets/file_content_validation_checks.textproto b/scripts/assets/file_content_validation_checks.textproto index 677e7ebcb9e..817a9a5e7ee 100644 --- a/scripts/assets/file_content_validation_checks.textproto +++ b/scripts/assets/file_content_validation_checks.textproto @@ -498,3 +498,90 @@ file_content_checks { failure_message: "Badly formatted KDoc. Single-line KDocs should end with punctuation." exempted_file_name: "scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt" } +file_content_checks { + file_path_regex: ".+?Test\\.kt" + prohibited_content_regex: "androidx.test.rule.ActivityTestRule" + failure_message: "ActivityTestRule is deprecated since it operates test activities in sometimes unsafe situations. Use ActivityScenario, instead." + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/customview/LessonThumbnailImageViewTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/faq/FaqListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/AddProfileActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/AdminAuthActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/AdminPinActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/topic/info/TopicInfoFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt" + exempted_file_name: "scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt" +} +file_content_checks { + file_path_regex: ".+?Test\\.kt" + prohibited_content_regex: "androidx.test.ext.junit.rules.ActivityScenarioRule" + failure_message: "ActivityScenarioRule can result in order dependence when static state leaks across tests (such as static module variables), and can make staging much more difficult for platform parameters. Use ActivityScenario directly, instead." + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivityTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/AppCompatCheckBoxBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/CircularProgressIndicatorAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/DrawableBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/ImageViewBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/MarginBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerMarginBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerPaddingBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/TextViewBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/databinding/ViewBindingAdaptersTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesFragmentTest.kt" + exempted_file_name: "app/src/sharedTest/java/org/oppia/android/app/utility/RatioExtensionsTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/parser/FractionParsingUiErrorTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/translation/ActivityLanguageLocaleHandlerTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/utility/datetime/DateTimeUtilTest.kt" + exempted_file_name: "app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt" + exempted_file_name: "domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/ApplicationLifecycleObserverTest.kt" + exempted_file_name: "scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt" + exempted_file_name: "testing/src/test/java/org/oppia/android/testing/espresso/TextInputActionTest.kt" +} diff --git a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt index c555f4cba76..707a2cf7e2a 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -209,6 +209,13 @@ class RegexPatternValidationCheckTest { " should immediately follow the at-clause without any additional linking with brackets." private val badSingleLineKdocShouldEndWithPunctuation = "Badly formatted KDoc. Single-line KDocs should end with punctuation." + private val activityTestRuleShouldNotBeUsed = + "ActivityTestRule is deprecated since it operates test activities in sometimes unsafe" + + " situations. Use ActivityScenario, instead." + private val activityScenarioRuleShouldNotBeUsed = + "ActivityScenarioRule can result in order dependence when static state leaks across tests" + + " (such as static module variables), and can make staging much more difficult for platform" + + " parameters. Use ActivityScenario directly, instead." private val wikiReferenceNote = "Refer to https://github.com/oppia/oppia-android/wiki/Static-Analysis-Checks" + "#regexpatternvalidation-check for more details on how to fix this." @@ -2649,6 +2656,50 @@ class RegexPatternValidationCheckTest { ) } + @Test + fun testFileContent_referencesActivityTestRule_fileContentIsNotCorrect() { + val prohibitedContent = + """ + import androidx.test.rule.ActivityTestRule + """.trimIndent() + tempFolder.newFolder("testfiles", "app", "src", "test", "java", "org", "oppia", "android") + val stringFilePath = "app/src/test/java/org/oppia/android/PresenterTest.kt" + tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) + + val exception = assertThrows() { runScript() } + + assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) + assertThat(outContent.toString().trim()) + .isEqualTo( + """ + $stringFilePath:1: $activityTestRuleShouldNotBeUsed + $wikiReferenceNote + """.trimIndent() + ) + } + + @Test + fun testFileContent_referencesActivityScenarioRule_fileContentIsNotCorrect() { + val prohibitedContent = + """ + import androidx.test.ext.junit.rules.ActivityScenarioRule + """.trimIndent() + tempFolder.newFolder("testfiles", "app", "src", "test", "java", "org", "oppia", "android") + val stringFilePath = "app/src/test/java/org/oppia/android/PresenterTest.kt" + tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) + + val exception = assertThrows() { runScript() } + + assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) + assertThat(outContent.toString().trim()) + .isEqualTo( + """ + $stringFilePath:1: $activityScenarioRuleShouldNotBeUsed + $wikiReferenceNote + """.trimIndent() + ) + } + /** Runs the regex_pattern_validation_check. */ private fun runScript() { main(File(tempFolder.root, "testfiles").absolutePath) From 7488b9f8d0dd90bddc471679949a735221d6e667 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 13 Sep 2023 23:59:47 +0000 Subject: [PATCH 04/21] Fix broken ProfileAndDeviceIdFragmentTest test. The test was suffering from some proto encoding inconsistencies that seem to occur between some development machines vs. on CI. The fix improves the test's robustness by extracting the raw encoded string, verifying that the other outputs in the intent message correctly correspond to that string, and that the string (as a parsed proto) contains the correct values. As a result, the test no longer depends on a hardcoded encoding value to be present for verification. This does result in a bit more logic than is generally good to have in a test (and it lengthened the test code quite a bit), but it seems necessary in this particular case. --- .../learneranalytics/BUILD.bazel | 1 + .../ProfileAndDeviceIdFragmentTest.kt | 104 ++++++++++++++++-- scripts/assets/todo_open_exemptions.textproto | 48 ++++---- .../testing/logging/EventLogSubject.kt | 7 ++ 4 files changed, 125 insertions(+), 35 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel index f98a384b911..da61bfc0e69 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/BUILD.bazel @@ -51,6 +51,7 @@ app_test( "//app/src/main/java/org/oppia/android/app/translation/testing:test_module", "//testing", "//testing/src/main/java/org/oppia/android/testing/junit:initialize_default_locale_rule", + "//testing/src/main/java/org/oppia/android/testing/logging:event_log_subject", "//testing/src/main/java/org/oppia/android/testing/logging:sync_status_test_module", "//testing/src/main/java/org/oppia/android/testing/platformparameter:test_module", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index b7e883989f8..ae4e10ff244 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -56,6 +56,7 @@ import org.oppia.android.app.application.ApplicationStartupListenerModule import org.oppia.android.app.application.testing.TestingBuildFlavorModule import org.oppia.android.app.devoptions.DeveloperOptionsModule import org.oppia.android.app.devoptions.DeveloperOptionsStarterModule +import org.oppia.android.app.model.OppiaEventLogs import org.oppia.android.app.model.ProfileId import org.oppia.android.app.player.state.itemviewmodel.SplitScreenInteractionModule import org.oppia.android.app.recyclerview.RecyclerViewMatcher.Companion.atPositionOnView @@ -103,6 +104,9 @@ import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule +import org.oppia.android.testing.logging.EventLogSubject +import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat +import org.oppia.android.testing.logging.EventLogSubject.LearnerDetailsContextSubject import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.logging.TestSyncStatusManager import org.oppia.android.testing.platformparameter.TestPlatformParameterModule @@ -117,6 +121,7 @@ import org.oppia.android.util.caching.AssetModule import org.oppia.android.util.caching.testing.CachingTestModule import org.oppia.android.util.gcsresource.GcsResourceModule import org.oppia.android.util.locale.LocaleProdModule +import org.oppia.android.util.locale.OppiaLocale import org.oppia.android.util.logging.EventLoggingConfigurationModule import org.oppia.android.util.logging.LoggerModule import org.oppia.android.util.logging.SyncStatusManager.SyncStatus @@ -130,7 +135,10 @@ import org.oppia.android.util.parser.image.GlideImageLoaderModule import org.oppia.android.util.parser.image.ImageParsingModule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode +import java.security.MessageDigest +import java.util.Base64 import java.util.concurrent.TimeUnit +import java.util.zip.GZIPInputStream import javax.inject.Inject import javax.inject.Singleton @@ -158,6 +166,7 @@ class ProfileAndDeviceIdFragmentTest { @Inject lateinit var syncStatusManager: TestSyncStatusManager @Inject lateinit var learnerAnalyticsLogger: LearnerAnalyticsLogger @Inject lateinit var fakeAnalyticsEventLogger: FakeAnalyticsEventLogger + @Inject lateinit var machineLocale: OppiaLocale.MachineLocale private val clipboardManager by lazy { context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager @@ -795,7 +804,7 @@ class ProfileAndDeviceIdFragmentTest { onShareIdsAndEventsButtonAt(position = 5).perform(click()) testCoroutineDispatchers.runCurrent() - val expectedShareText = + val expectedShareTextPattern = """ Oppia app installation ID: 113e04cc09a3 - Profile name: Admin, learner ID: 8dcbbd21 @@ -811,20 +820,49 @@ class ProfileAndDeviceIdFragmentTest { - Uploaded learner events: 2 Current sync status: Waiting to schedule data uploading worker…. Event log encoding integrity checks: - - First 40 chars of encoded string: H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pY - - Last 40 chars of encoded string: BzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - - SHA-1 hash (unwrapped event string): 1ee817dd58dcb25c9af4fbfc3c89c86b730f6680 - - Total event string length (unwrapped): 140 - Encoded event logs: - H4sIAAAAAAAA/+PSlGBUUj3FqMTFX5JaXBKfk5pYlJdaFJ+ZIgQRyMwrLknMyQEKcBkSrVSLwYjBisGJ - gU5ajEnVwsTBSDdNTELEBzGNlJIepORoISdAydHERJ4m4sMLAFFY60EUAwAA - """.trimIndent() + - First 40 chars of encoded string: ([\p{Alnum}/\\+=]+) + - Last 40 chars of encoded string: ([\p{Alnum}/\\+=]+) + - SHA-1 hash \(unwrapped event string\): (\p{XDigit}+) + - Total event string length \(unwrapped\): (\p{Digit}+) + Encoded event logs:([\p{Alnum}/+=\p{Space}]+) + """.trimIndent().toRegex() val intents = getIntents() + val extraText = intents.singleOrNull()?.getStringExtra(Intent.EXTRA_TEXT) assertThat(intents).hasSize(1) assertThat(intents.single()).hasAction(Intent.ACTION_SEND) assertThat(intents.single()).hasType("text/plain") assertThat(intents.single()).extras().containsKey(Intent.EXTRA_TEXT) - assertThat(intents.single()).extras().string(Intent.EXTRA_TEXT).isEqualTo(expectedShareText) + assertThat(extraText).matches(expectedShareTextPattern.toPattern()) + val (encodingPrefix, encodingSuffix, shaHash, encodingLength, rawEncodedLogs) = + extraText?.let { expectedShareTextPattern.matchEntire(it) }?.destructured!! + val unwrappedEncodedLogs = rawEncodedLogs.trim().replace(" ", "").replace("\n", "") + // Verify that the correct _values_ are being outputted, even if the specific values might + // differ slightly (depending on the running platform). + assertThat(encodingPrefix).isEqualTo(unwrappedEncodedLogs.take(40)) + assertThat(encodingSuffix).isEqualTo(unwrappedEncodedLogs.takeLast(40)) + assertThat(shaHash).isEqualTo(unwrappedEncodedLogs.computeSha1Hash()) + assertThat(encodingLength.toInt()).isEqualTo(unwrappedEncodedLogs.length) + // Verify the encoded events themselves are correct by decoding them and analyzing the loaded + // proto (since the string can vary somewhat). + val eventLogs = decodeEventLogString(unwrappedEncodedLogs) + assertThat(eventLogs.eventLogsToUploadCount).isEqualTo(7) + assertThat(eventLogs.uploadedEventLogsCount).isEqualTo(9) + assertThat(eventLogs.eventLogsToUploadList[0]).hasCommonPropsWithNoProfileId() + assertThat(eventLogs.eventLogsToUploadList[1]).hasCommonPropsWithProfile(ADMIN_PROFILE_ID) + assertThat(eventLogs.eventLogsToUploadList[2]).hasCommonPropsWithProfile(ADMIN_PROFILE_ID) + assertThat(eventLogs.eventLogsToUploadList[3]).hasCommonPropsWithProfile(ADMIN_PROFILE_ID) + assertThat(eventLogs.eventLogsToUploadList[4]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_0) + assertThat(eventLogs.eventLogsToUploadList[5]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_0) + assertThat(eventLogs.eventLogsToUploadList[6]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_1) + assertThat(eventLogs.uploadedEventLogsList[0]).hasCommonPropsWithNoProfileId() + assertThat(eventLogs.uploadedEventLogsList[1]).hasCommonPropsWithNoProfileId() + assertThat(eventLogs.uploadedEventLogsList[2]).hasCommonPropsWithNoProfileId() + assertThat(eventLogs.uploadedEventLogsList[3]).hasCommonPropsWithProfile(ADMIN_PROFILE_ID) + assertThat(eventLogs.uploadedEventLogsList[4]).hasCommonPropsWithProfile(ADMIN_PROFILE_ID) + assertThat(eventLogs.uploadedEventLogsList[5]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_0) + assertThat(eventLogs.uploadedEventLogsList[6]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_1) + assertThat(eventLogs.uploadedEventLogsList[7]).hasCommonPropsWithProfile(LEARNER_PROFILE_ID_1) + assertThat(eventLogs.uploadedEventLogsList[8]).hasCommonPropsWithNoProfileId() } } @@ -976,7 +1014,7 @@ class ProfileAndDeviceIdFragmentTest { private fun logAnalyticsEvent(profileId: ProfileId? = null) { learnerAnalyticsLogger.logAppInForeground( - installationId = "test_install_id", profileId, learnerId = "test_learner_id" + installationId = TEST_INSTALLATION_ID, profileId, learnerId = TEST_LEARNER_ID ) testCoroutineDispatchers.runCurrent() } @@ -1017,6 +1055,48 @@ class ProfileAndDeviceIdFragmentTest { disconnectNetwork() } + private fun String.computeSha1Hash(): String { + return machineLocale.run { + MessageDigest.getInstance("SHA-1") + .digest(this@computeSha1Hash.toByteArray()) + .joinToString("") { "%02x".formatForMachines(it) } + } + } + + private fun decodeEventLogString(encodedEventLogs: String): OppiaEventLogs { + return GZIPInputStream(Base64.getDecoder().decode(encodedEventLogs).inputStream()).use { inps -> + OppiaEventLogs.newBuilder().mergeFrom(inps).build() + } + } + + private fun EventLogSubject.hasCommonProperties() { + hasNoLanguageInformation() + hasTimestampThat().isEqualTo(0) + isEssentialPriority() + hasAppInForegroundContextThat().hasDefaultIds() + } + + private fun EventLogSubject.hasCommonPropsWithNoProfileId() { + hasCommonProperties() + hasNoProfileId() + } + + private fun EventLogSubject.hasCommonPropsWithProfile(profileId: ProfileId) { + hasCommonProperties() + hasProfileIdThat().isEqualTo(profileId) + } + + private fun EventLogSubject.hasNoLanguageInformation() { + hasAppLanguageSelectionThat().isEqualToDefaultInstance() + hasWrittenTranslationLanguageSelectionThat().isEqualToDefaultInstance() + hasAudioTranslationLanguageSelectionThat().isEqualToDefaultInstance() + } + + private fun LearnerDetailsContextSubject.hasDefaultIds() { + hasLearnerIdThat().isEqualTo(TEST_LEARNER_ID) + hasInstallationIdThat().isEqualTo(TEST_INSTALLATION_ID) + } + private fun setUpTestApplicationComponent() { ApplicationProvider.getApplicationContext().inject(this) } @@ -1091,6 +1171,8 @@ class ProfileAndDeviceIdFragmentTest { private companion object { private const val DEFAULT_APPLICATION_ID = 123456789L + private const val TEST_LEARNER_ID = "test_learner_id" + private const val TEST_INSTALLATION_ID = "test_install_id" private val ADMIN_PROFILE_ID = createProfileId(internalProfileId = 0) private val LEARNER_PROFILE_ID_0 = createProfileId(internalProfileId = 1) diff --git a/scripts/assets/todo_open_exemptions.textproto b/scripts/assets/todo_open_exemptions.textproto index 0fa81fd297d..51af8ca27ee 100644 --- a/scripts/assets/todo_open_exemptions.textproto +++ b/scripts/assets/todo_open_exemptions.textproto @@ -1,37 +1,37 @@ todo_open_exemption { exempted_file_path: "scripts/src/javatests/org/oppia/android/scripts/todo/TodoOpenCheckTest.kt" - line_number: 67 - line_number: 68 + line_number: 65 + line_number: 66 + line_number: 72 line_number: 74 - line_number: 76 + line_number: 96 + line_number: 97 line_number: 98 line_number: 99 line_number: 100 - line_number: 101 - line_number: 102 + line_number: 132 + line_number: 133 line_number: 136 - line_number: 137 - line_number: 140 - line_number: 173 + line_number: 167 + line_number: 168 + line_number: 169 line_number: 174 - line_number: 175 - line_number: 180 - line_number: 182 - line_number: 221 + line_number: 176 + line_number: 213 + line_number: 214 + line_number: 215 + line_number: 220 line_number: 222 - line_number: 223 line_number: 228 - line_number: 230 - line_number: 236 - line_number: 275 - line_number: 279 - line_number: 317 - line_number: 318 - line_number: 322 - line_number: 371 - line_number: 372 - line_number: 373 - line_number: 377 + line_number: 265 + line_number: 269 + line_number: 307 + line_number: 308 + line_number: 312 + line_number: 359 + line_number: 360 + line_number: 361 + line_number: 365 } todo_open_exemption { exempted_file_path: "scripts/src/javatests/org/oppia/android/scripts/todo/TodoCollectorTest.kt" diff --git a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt index cbd7163ce19..fd8b539e06c 100644 --- a/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt +++ b/testing/src/main/java/org/oppia/android/testing/logging/EventLogSubject.kt @@ -96,6 +96,13 @@ class EventLogSubject private constructor( assertThat(actual.priority).isEqualTo(EventLog.Priority.OPTIONAL) } + /** + * Verifies that the [EventLog] under test has no profile ID defined per [EventLog.getProfileId]. + */ + fun hasNoProfileId() { + assertThat(actual.hasProfileId()).isFalse() + } + /** * Returns an [LiteProtoSubject] to verify the under-test [EventLog]'s [EventLog.getProfileId] * field. From 5671673175891d0491280b901d3f8b53802d3e7d Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 26 Oct 2023 18:40:57 +0000 Subject: [PATCH 05/21] Post-merge fix. --- .../android/scripts/regex/RegexPatternValidationCheckTest.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt index a862d2f5114..a3eb9c825d9 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -2209,9 +2209,7 @@ class RegexPatternValidationCheckTest { val stringFilePath = "app/src/main/res/drawable/test_layout.xml" tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent) - val exception = assertThrows(Exception::class) { - runScript() - } + val exception = assertThrows() { runScript() } // Verify that all patterns are properly detected & prohibited. assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR) From 000bba3f18c8ef86c4124e6d9546f5a5f966fb27 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 18 Jan 2024 23:27:19 +0000 Subject: [PATCH 06/21] Add ScriptBackgroundCoroutineDispatcher. This is a script-specific dispatcher which will allow for better asynchronous support in upcoming PRs (especially for command execution). This change serves to prepare for those changes. --- .../scripts/build/TransformAndroidManifest.kt | 43 ++++++---- .../scripts/ci/ComputeAffectedTests.kt | 18 ++-- .../oppia/android/scripts/common/BUILD.bazel | 13 +++ .../android/scripts/common/BazelClient.kt | 2 +- .../scripts/common/CommandExecutorImpl.kt | 4 + .../oppia/android/scripts/common/GitClient.kt | 5 +- .../ScriptBackgroundCoroutineDispatcher.kt | 86 +++++++++++++++++++ .../license/MavenDependenciesListCheck.kt | 8 +- .../license/MavenDependenciesRetriever.kt | 2 +- .../maven/GenerateMavenDependenciesList.kt | 83 +++++++++--------- .../build/TransformAndroidManifestTest.kt | 16 ++-- .../scripts/ci/ComputeAffectedTestsTest.kt | 16 ++-- .../oppia/android/scripts/common/BUILD.bazel | 11 +++ .../android/scripts/common/BazelClientTest.kt | 66 +++++++------- .../scripts/common/CommandExecutorImplTest.kt | 32 ++++--- .../android/scripts/common/GitClientTest.kt | 42 ++++----- ...ScriptBackgroundCoroutineDispatcherTest.kt | 79 +++++++++++++++++ .../license/MavenDependenciesListCheckTest.kt | 54 ++++++++---- .../license/MavenDependenciesRetrieverTest.kt | 13 +-- .../GenerateMavenDependenciesListTest.kt | 29 +++++-- .../scripts/testing/TestGitRepositoryTest.kt | 22 +++-- wiki/Updating-Maven-Dependencies.md | 32 +++---- 22 files changed, 477 insertions(+), 199 deletions(-) create mode 100644 scripts/src/java/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcher.kt create mode 100644 scripts/src/javatests/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcherTest.kt diff --git a/scripts/src/java/org/oppia/android/scripts/build/TransformAndroidManifest.kt b/scripts/src/java/org/oppia/android/scripts/build/TransformAndroidManifest.kt index 4fde91e42eb..96095ee2925 100644 --- a/scripts/src/java/org/oppia/android/scripts/build/TransformAndroidManifest.kt +++ b/scripts/src/java/org/oppia/android/scripts/build/TransformAndroidManifest.kt @@ -1,6 +1,8 @@ package org.oppia.android.scripts.build +import org.oppia.android.scripts.common.CommandExecutorImpl import org.oppia.android.scripts.common.GitClient +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher import org.w3c.dom.Document import org.w3c.dom.NodeList import java.io.File @@ -62,21 +64,24 @@ fun main(args: Array) { check(args.size >= 9) { USAGE_STRING } val repoRoot = File(args[0]).also { if (!it.exists()) error("File doesn't exist: ${args[0]}") } - TransformAndroidManifest( - repoRoot = repoRoot, - sourceManifestFile = File(args[1]).also { - if (!it.exists()) { - error("File doesn't exist: ${args[1]}") - } - }, - outputManifestFile = File(args[2]), - buildFlavor = args[3], - majorVersion = args[4].toIntOrNull() ?: error(USAGE_STRING), - minorVersion = args[5].toIntOrNull() ?: error(USAGE_STRING), - versionCode = args[6].toIntOrNull() ?: error(USAGE_STRING), - relativelyQualifiedApplicationClass = args[7], - baseDevelopBranchReference = args[8] - ).generateAndOutputNewManifest() + ScriptBackgroundCoroutineDispatcher().use { scriptBgDispatcher -> + TransformAndroidManifest( + repoRoot = repoRoot, + sourceManifestFile = File(args[1]).also { + if (!it.exists()) { + error("File doesn't exist: ${args[1]}") + } + }, + outputManifestFile = File(args[2]), + buildFlavor = args[3], + majorVersion = args[4].toIntOrNull() ?: error(USAGE_STRING), + minorVersion = args[5].toIntOrNull() ?: error(USAGE_STRING), + versionCode = args[6].toIntOrNull() ?: error(USAGE_STRING), + relativelyQualifiedApplicationClass = args[7], + baseDevelopBranchReference = args[8], + scriptBgDispatcher + ).generateAndOutputNewManifest() + } } private class TransformAndroidManifest( @@ -88,11 +93,11 @@ private class TransformAndroidManifest( private val minorVersion: Int, private val versionCode: Int, private val relativelyQualifiedApplicationClass: String, - private val baseDevelopBranchReference: String + private val baseDevelopBranchReference: String, + private val scriptBgDispatcher: ScriptBackgroundCoroutineDispatcher ) { - private val gitClient by lazy { - GitClient(repoRoot, baseDevelopBranchReference) - } + private val commandExecutor by lazy { CommandExecutorImpl(scriptBgDispatcher) } + private val gitClient by lazy { GitClient(repoRoot, baseDevelopBranchReference, commandExecutor) } private val documentBuilderFactory by lazy { DocumentBuilderFactory.newInstance() } private val transformerFactory by lazy { TransformerFactory.newInstance() } diff --git a/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt b/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt index f7cc482c72a..53742b4081f 100644 --- a/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt +++ b/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt @@ -7,6 +7,9 @@ import org.oppia.android.scripts.proto.AffectedTestsBucket import java.io.File import java.util.Locale import kotlin.system.exitProcess +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher +import org.oppia.android.scripts.common.CommandExecutor +import org.oppia.android.scripts.common.CommandExecutorImpl private const val COMPUTE_ALL_TESTS_PREFIX = "compute_all_tests=" private const val MAX_TEST_COUNT_PER_LARGE_SHARD = 50 @@ -57,9 +60,10 @@ fun main(args: Array) { " '$computeAllTestsValue'" ) } - ComputeAffectedTests().compute( - pathToRoot, pathToOutputFile, baseDevelopBranchReference, computeAllTestsSetting - ) + ScriptBackgroundCoroutineDispatcher().use { scriptBgDispatcher -> + ComputeAffectedTests(scriptBgDispatcher) + .compute(pathToRoot, pathToOutputFile, baseDevelopBranchReference, computeAllTestsSetting) + } } // Needed since the codebase isn't yet using Kotlin 1.5, so this function isn't available. @@ -73,9 +77,11 @@ private fun String.toBooleanStrictOrNull(): Boolean? { /** Utility used to compute affected test targets. */ class ComputeAffectedTests( + private val scriptBgDispatcher: ScriptBackgroundCoroutineDispatcher, val maxTestCountPerLargeShard: Int = MAX_TEST_COUNT_PER_LARGE_SHARD, val maxTestCountPerMediumShard: Int = MAX_TEST_COUNT_PER_MEDIUM_SHARD, - val maxTestCountPerSmallShard: Int = MAX_TEST_COUNT_PER_SMALL_SHARD + val maxTestCountPerSmallShard: Int = MAX_TEST_COUNT_PER_SMALL_SHARD, + val commandExecutor: CommandExecutor = CommandExecutorImpl(scriptBgDispatcher) ) { private companion object { private const val GENERIC_TEST_BUCKET_NAME = "generic" @@ -105,8 +111,8 @@ class ComputeAffectedTests( println("Running from directory root: $rootDirectory") - val gitClient = GitClient(rootDirectory, baseDevelopBranchReference) - val bazelClient = BazelClient(rootDirectory) + val gitClient = GitClient(rootDirectory, baseDevelopBranchReference, commandExecutor) + val bazelClient = BazelClient(rootDirectory, commandExecutor) println("Current branch: ${gitClient.currentBranch}") println("Most recent common commit: ${gitClient.branchMergeBase}") diff --git a/scripts/src/java/org/oppia/android/scripts/common/BUILD.bazel b/scripts/src/java/org/oppia/android/scripts/common/BUILD.bazel index 3a94254e9fc..6b26dd4f49f 100644 --- a/scripts/src/java/org/oppia/android/scripts/common/BUILD.bazel +++ b/scripts/src/java/org/oppia/android/scripts/common/BUILD.bazel @@ -36,6 +36,10 @@ kt_jvm_library( "CommandResult.kt", ], visibility = ["//scripts:oppia_script_library_visibility"], + deps = [ + ":script_background_coroutine_dispatcher", + "//third_party:org_jetbrains_kotlinx_kotlinx-coroutines-core", + ], ) kt_jvm_library( @@ -57,3 +61,12 @@ kt_jvm_library( "//third_party:org_jetbrains_kotlin_kotlin-stdlib-jdk8_jar", ], ) + +kt_jvm_library( + name = "script_background_coroutine_dispatcher", + srcs = ["ScriptBackgroundCoroutineDispatcher.kt"], + visibility = ["//scripts:oppia_script_library_visibility"], + deps = [ + "//third_party:org_jetbrains_kotlinx_kotlinx-coroutines-core", + ], +) diff --git a/scripts/src/java/org/oppia/android/scripts/common/BazelClient.kt b/scripts/src/java/org/oppia/android/scripts/common/BazelClient.kt index b6071d86b76..7d5806a5869 100644 --- a/scripts/src/java/org/oppia/android/scripts/common/BazelClient.kt +++ b/scripts/src/java/org/oppia/android/scripts/common/BazelClient.kt @@ -10,7 +10,7 @@ import java.util.Locale */ class BazelClient( private val rootDirectory: File, - private val commandExecutor: CommandExecutor = CommandExecutorImpl() + private val commandExecutor: CommandExecutor ) { /** Returns all Bazel test targets in the workspace. */ fun retrieveAllTestTargets(): List { diff --git a/scripts/src/java/org/oppia/android/scripts/common/CommandExecutorImpl.kt b/scripts/src/java/org/oppia/android/scripts/common/CommandExecutorImpl.kt index 44817344a8f..35c56d0988f 100644 --- a/scripts/src/java/org/oppia/android/scripts/common/CommandExecutorImpl.kt +++ b/scripts/src/java/org/oppia/android/scripts/common/CommandExecutorImpl.kt @@ -2,6 +2,9 @@ package org.oppia.android.scripts.common import java.io.File import java.util.concurrent.TimeUnit +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.async +import kotlinx.coroutines.runBlocking /** * The default amount of time that should be waited before considering a process as 'hung', in @@ -11,6 +14,7 @@ const val WAIT_PROCESS_TIMEOUT_MS = 60_000L /** Default implementation of [CommandExecutor]. */ class CommandExecutorImpl( + private val scriptBgDispatcher: ScriptBackgroundCoroutineDispatcher, private val processTimeout: Long = WAIT_PROCESS_TIMEOUT_MS, private val processTimeoutUnit: TimeUnit = TimeUnit.MILLISECONDS ) : CommandExecutor { diff --git a/scripts/src/java/org/oppia/android/scripts/common/GitClient.kt b/scripts/src/java/org/oppia/android/scripts/common/GitClient.kt index 797d345bbf2..dfda3889b8f 100644 --- a/scripts/src/java/org/oppia/android/scripts/common/GitClient.kt +++ b/scripts/src/java/org/oppia/android/scripts/common/GitClient.kt @@ -9,10 +9,9 @@ import java.io.File */ class GitClient( private val workingDirectory: File, - private val baseDevelopBranchReference: String + private val baseDevelopBranchReference: String, + private val commandExecutor: CommandExecutor ) { - private val commandExecutor by lazy { CommandExecutorImpl() } - /** The commit hash of the HEAD of the local Git repository. */ val currentCommit: String by lazy { retrieveCurrentCommit() } diff --git a/scripts/src/java/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcher.kt b/scripts/src/java/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcher.kt new file mode 100644 index 00000000000..52bb21c0a0f --- /dev/null +++ b/scripts/src/java/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcher.kt @@ -0,0 +1,86 @@ +package org.oppia.android.scripts.common + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Runnable +import kotlinx.coroutines.asCoroutineDispatcher +import java.io.Closeable +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import kotlin.coroutines.CoroutineContext + +/** + * A [CoroutineDispatcher] that's [Closeable] and particularly tailored to be easily used in scripts + * that need to perform parallel tasks for expensive IO. It's highly recommended to exclusively use + * this dispatcher over any others, and to ensure that [close] is called at the end of the script to + * avoid any potential threads hanging (causing the script to not actually close). + * + * Note that the dispatcher attempts to finish any ongoing tasks when [close] is called, but it will + * reject new tasks from being scheduled and it will force terminate if any pending tasks at the + * time of closing don't end within the configured [closeTimeout] provided. + * + * A simple example for using this dispatcher: + * ```kotlin + * ScriptBackgroundCoroutineDispatcher().use { scriptBgDispatcher -> + * val deferred = CoroutineScope(scriptBgDispatcher).async { + * // Expensive task... + * } + * // IMPORTANT: The operation must be observed before use{} ends, otherwise the dispatcher will + * // close and terminate any pending tasks. + * runBlocking { deferred.await() } + * } + * ``` + * + * A more complex example for I/O operations: + * ```kotlin + * ScriptBackgroundCoroutineDispatcher().use { scriptBgDispatcher -> + * val deferred = CoroutineScope(scriptBgDispatcher).async { + * withContext(Dispatchers.IO) { + * // Perform I/O using Kotlin's highly parallelized I/O dispatcher, but wait for the result + * // using the background script dispatcher (since execution could continue if other I/O + * // operations need to be kicked off, or if other work can be done alongside the I/O). + * } + * } + * // IMPORTANT: The operation must be observed before use{} ends, otherwise the dispatcher will + * // close and terminate any pending tasks. + * runBlocking { deferred.await() } + * } + * ``` + * + * @property closeTimeout the amount of time, in [closeTimeoutUnit] units, that should be waited + * when [close]ing this dispatcher before force-ending ongoing tasks + * @property closeTimeoutUnit the unit of time used for [closeTimeout] + */ +class ScriptBackgroundCoroutineDispatcher( + private val closeTimeout: Long = 5, + private val closeTimeoutUnit: TimeUnit = TimeUnit.SECONDS +) : CoroutineDispatcher(), Closeable { + private val threadPool by lazy { Executors.newCachedThreadPool() } + private val coroutineDispatcher by lazy { threadPool.asCoroutineDispatcher() } + + override fun dispatch(context: CoroutineContext, block: Runnable) { + coroutineDispatcher.dispatch(context, block) + } + + override fun close() { + threadPool.tryShutdownFully(timeout = closeTimeout, unit = closeTimeoutUnit) + coroutineDispatcher.close() + } + + private companion object { + private fun ExecutorService.tryShutdownFully(timeout: Long, unit: TimeUnit) { + // Try to fully shutdown the executor service per https://stackoverflow.com/a/33690603 and + // https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ExecutorService.html. + shutdown() + try { + if (!awaitTermination(timeout, unit)) { + shutdownNow() + check(awaitTermination(timeout, unit)) { "ExecutorService didn't fully shutdown: $this." } + } + } catch (e: InterruptedException) { + shutdownNow() + Thread.currentThread().interrupt() + } + } + } +} diff --git a/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesListCheck.kt b/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesListCheck.kt index 1632c3c9068..d8f178c7b21 100644 --- a/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesListCheck.kt +++ b/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesListCheck.kt @@ -3,6 +3,7 @@ package org.oppia.android.scripts.license import com.google.protobuf.TextFormat import org.oppia.android.scripts.common.CommandExecutor import org.oppia.android.scripts.common.CommandExecutorImpl +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher import org.oppia.android.scripts.proto.MavenDependency /** @@ -24,7 +25,9 @@ import org.oppia.android.scripts.proto.MavenDependency * third_party/maven_install.json scripts/assets/maven_dependencies.pb */ fun main(args: Array) { - MavenDependenciesListCheck(LicenseFetcherImpl()).main(args) + ScriptBackgroundCoroutineDispatcher().use { scriptBgDispatcher -> + MavenDependenciesListCheck(LicenseFetcherImpl(), scriptBgDispatcher).main(args) + } } /** @@ -33,7 +36,8 @@ fun main(args: Array) { */ class MavenDependenciesListCheck( private val licenseFetcher: LicenseFetcher, - private val commandExecutor: CommandExecutor = CommandExecutorImpl() + scriptBgDispatcher: ScriptBackgroundCoroutineDispatcher, + private val commandExecutor: CommandExecutor = CommandExecutorImpl(scriptBgDispatcher) ) { /** diff --git a/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesRetriever.kt b/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesRetriever.kt index 3b67d51a751..4eeec0be8df 100644 --- a/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesRetriever.kt +++ b/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesRetriever.kt @@ -24,7 +24,7 @@ private const val MAVEN_PREFIX = "@maven//:" class MavenDependenciesRetriever( private val rootPath: String, private val licenseFetcher: LicenseFetcher, - private val commandExecutor: CommandExecutor = CommandExecutorImpl() + private val commandExecutor: CommandExecutor ) { private val bazelClient by lazy { diff --git a/scripts/src/java/org/oppia/android/scripts/maven/GenerateMavenDependenciesList.kt b/scripts/src/java/org/oppia/android/scripts/maven/GenerateMavenDependenciesList.kt index 8829a55a475..36b28f3228c 100644 --- a/scripts/src/java/org/oppia/android/scripts/maven/GenerateMavenDependenciesList.kt +++ b/scripts/src/java/org/oppia/android/scripts/maven/GenerateMavenDependenciesList.kt @@ -2,6 +2,7 @@ package org.oppia.android.scripts.maven import org.oppia.android.scripts.common.CommandExecutor import org.oppia.android.scripts.common.CommandExecutorImpl +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher import org.oppia.android.scripts.license.LicenseFetcher import org.oppia.android.scripts.license.LicenseFetcherImpl import org.oppia.android.scripts.license.MavenDependenciesRetriever @@ -27,13 +28,16 @@ import org.oppia.android.scripts.proto.MavenDependencyList * scripts/assets/maven_dependencies.pb */ fun main(args: Array) { - GenerateMavenDependenciesList(LicenseFetcherImpl()).main(args) + ScriptBackgroundCoroutineDispatcher().use { scriptBgDispatcher -> + GenerateMavenDependenciesList(LicenseFetcherImpl(), scriptBgDispatcher).main(args) + } } /** Wrapper class to pass dependencies to be utilized by the the main method. */ class GenerateMavenDependenciesList( private val licenseFetcher: LicenseFetcher, - private val commandExecutor: CommandExecutor = CommandExecutorImpl() + scriptBgDispatcher: ScriptBackgroundCoroutineDispatcher, + private val commandExecutor: CommandExecutor = CommandExecutorImpl(scriptBgDispatcher) ) { /** * Compiles a list of third-party maven dependencies along with their license links on @@ -48,45 +52,46 @@ class GenerateMavenDependenciesList( val pathToMavenDependenciesTextProto = "$pathToRoot/${args[2]}" val pathToMavenDependenciesPb = args[3] - val MavenDependenciesRetriever = MavenDependenciesRetriever(pathToRoot, licenseFetcher) + val mavenDependenciesRetriever = + MavenDependenciesRetriever(pathToRoot, licenseFetcher, commandExecutor) val bazelQueryDepsList = - MavenDependenciesRetriever.retrieveThirdPartyMavenDependenciesList() - val mavenInstallDepsList = MavenDependenciesRetriever.getDependencyListFromMavenInstall( + mavenDependenciesRetriever.retrieveThirdPartyMavenDependenciesList() + val mavenInstallDepsList = mavenDependenciesRetriever.getDependencyListFromMavenInstall( pathToMavenInstallJson, bazelQueryDepsList ) val dependenciesListFromPom = - MavenDependenciesRetriever + mavenDependenciesRetriever .retrieveDependencyListFromPom(mavenInstallDepsList) .mavenDependencyList val dependenciesListFromTextProto = - MavenDependenciesRetriever.retrieveMavenDependencyList(pathToMavenDependenciesPb) + mavenDependenciesRetriever.retrieveMavenDependencyList(pathToMavenDependenciesPb) - val updatedDependenciesList = MavenDependenciesRetriever.addChangesFromTextProto( + val updatedDependenciesList = mavenDependenciesRetriever.addChangesFromTextProto( dependenciesListFromPom, dependenciesListFromTextProto ) val manuallyUpdatedLicenses = - MavenDependenciesRetriever.retrieveManuallyUpdatedLicensesSet(updatedDependenciesList) + mavenDependenciesRetriever.retrieveManuallyUpdatedLicensesSet(updatedDependenciesList) - val finalDependenciesList = MavenDependenciesRetriever.updateMavenDependenciesList( + val finalDependenciesList = mavenDependenciesRetriever.updateMavenDependenciesList( updatedDependenciesList, manuallyUpdatedLicenses ) - MavenDependenciesRetriever.writeTextProto( + mavenDependenciesRetriever.writeTextProto( pathToMavenDependenciesTextProto, MavenDependencyList.newBuilder().addAllMavenDependency(finalDependenciesList).build() ) val licensesToBeFixed = - MavenDependenciesRetriever.getAllBrokenLicenses(finalDependenciesList) + mavenDependenciesRetriever.getAllBrokenLicenses(finalDependenciesList) if (licensesToBeFixed.isNotEmpty()) { - val licenseToDependencyMap = MavenDependenciesRetriever + val licenseToDependencyMap = mavenDependenciesRetriever .findFirstDependenciesWithBrokenLicenses( finalDependenciesList, licensesToBeFixed @@ -95,34 +100,34 @@ class GenerateMavenDependenciesList( """ Some licenses do not have their 'original_link' verified. To verify a license link, click on the original link of the license and check if the link points to any valid license or - not. If the link does not point to a valid license (e.g - https://fabric.io/terms), set + not. If the link does not point to a valid license (e.g. - https://fabric.io/terms), set the 'is_original_link_invalid' field of the license to 'true'. - - e.g - + + e.g. - license { license_name: "Terms of Service for Firebase Services" original_link: "https://fabric.io/terms" is_original_link_invalid: true } - - If the link does point to a valid license then choose the most appropriate category for + + If the link does point to a valid license then choose the most appropriate category for the link: - + 1. scrapable_link: If the license text is plain text and the URL mentioned can be scraped - directly from the original_link of the license. e.g - + directly from the original_link of the license. e.g. - https://www.apache.org/licenses/LICENSE-2.0.txt - - 2. extracted_copy_link: If the license text is plain text but it can not be scraped - directly from the original_link of the license. e.g - + + 2. extracted_copy_link: If the license text is plain text but it can not be scraped + directly from the original_link of the license. e.g. - https://www.opensource.org/licenses/bsd-license - + 3. direct_link_only: If the license text is not plain text, it's best to display only the - link of the license. e.g - https://developer.android.com/studio/terms.html - + link of the license. e.g. - https://developer.android.com/studio/terms.html + After identifying the category of the license, modify the license to include one of the - above mentioned 'url'. - - e.g - + above mentioned 'url'. + + e.g. - license { license_name: "The Apache Software License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -130,9 +135,9 @@ class GenerateMavenDependenciesList( url: "https://www.apache.org/licenses/LICENSE-2.0.txt" } } - - Please verify the license link(s) for the following license(s) manually in - maven_dependencies.textproto. Note that only first dependency that contains the license + + Please verify the license link(s) for the following license(s) manually in + maven_dependencies.textproto. Note that only first dependency that contains the license needs to be updated and also re-run the script to update the license details at all places. """.trimIndent() ) @@ -150,21 +155,21 @@ class GenerateMavenDependenciesList( } val dependenciesWithoutAnyLinks = - MavenDependenciesRetriever.getDependenciesThatNeedIntervention(finalDependenciesList) + mavenDependenciesRetriever.getDependenciesThatNeedIntervention(finalDependenciesList) if (dependenciesWithoutAnyLinks.isNotEmpty()) { println( """ - Please remove all the invalid links (if any) from maven_dependencies.textproto for the + Please remove all the invalid links (if any) from maven_dependencies.textproto for the below mentioned dependencies and provide the valid license links manually. - e.g - - + e.g. - + maven_dependency { artifact_name: "com.google.guava:failureaccess:1.0.1" artifact_version: "1.0.1" } - + ***** changes to ***** - + maven_dependency { artifact_name: "com.google.guava:failureaccess:1.0.1" artifact_version: "1.0.1" @@ -175,7 +180,7 @@ class GenerateMavenDependenciesList( } } } - + Dependencies with invalid or no license links: """.trimIndent() + "\n" ) diff --git a/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt b/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt index 5d197b04615..d614ef5a1db 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/build/TransformAndroidManifestTest.kt @@ -1,11 +1,13 @@ package org.oppia.android.scripts.build import com.google.common.truth.Truth.assertThat +import org.junit.After import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder import org.oppia.android.scripts.common.CommandExecutorImpl +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher import org.oppia.android.scripts.testing.TestGitRepository import org.oppia.android.testing.assertThrows import java.io.File @@ -54,16 +56,20 @@ class TransformAndroidManifestTest { private val VERSION_CODE = "23" private val APPLICATION_RELATIVE_QUALIFIED_CLASS = ".example.CustomApplication" - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() - private val commandExecutor by lazy { CommandExecutorImpl() } + private val scriptBgDispatcher by lazy { ScriptBackgroundCoroutineDispatcher() } + private val commandExecutor by lazy { CommandExecutorImpl(scriptBgDispatcher) } private lateinit var testGitRepository: TestGitRepository @Before fun setUp() { - testGitRepository = TestGitRepository(tempFolder, CommandExecutorImpl()) + testGitRepository = TestGitRepository(tempFolder, commandExecutor) + } + + @After + fun tearDown() { + scriptBgDispatcher.close() } @Test diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt index 5bbdc432d62..ae177def7d6 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt @@ -6,6 +6,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder +import org.oppia.android.scripts.common.CommandExecutor import org.oppia.android.scripts.common.CommandExecutorImpl import org.oppia.android.scripts.common.ProtoStringEncoder.Companion.mergeFromCompressedBase64 import org.oppia.android.scripts.proto.AffectedTestsBucket @@ -16,6 +17,7 @@ import java.io.ByteArrayOutputStream import java.io.File import java.io.OutputStream import java.io.PrintStream +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher /** * Tests for the compute_affected_tests utility. @@ -28,20 +30,21 @@ import java.io.PrintStream // Function name: test names are conventionally named with underscores. @Suppress("SameParameterValue", "FunctionName") class ComputeAffectedTestsTest { - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() + private val scriptBgDispatcher by lazy { ScriptBackgroundCoroutineDispatcher() } + + private lateinit var commandExecutor: CommandExecutor private lateinit var testBazelWorkspace: TestBazelWorkspace private lateinit var testGitRepository: TestGitRepository - private lateinit var pendingOutputStream: ByteArrayOutputStream private lateinit var originalStandardOutputStream: OutputStream @Before fun setUp() { + commandExecutor = CommandExecutorImpl(scriptBgDispatcher) testBazelWorkspace = TestBazelWorkspace(tempFolder) - testGitRepository = TestGitRepository(tempFolder, CommandExecutorImpl()) + testGitRepository = TestGitRepository(tempFolder, commandExecutor) // Redirect script output for testing purposes. pendingOutputStream = ByteArrayOutputStream() @@ -58,6 +61,8 @@ class ComputeAffectedTestsTest { // and to help manually verify the expect git state at the end of each test. println("git status (at end of test):") println(testGitRepository.status(checkForGitRepository = false)) + + scriptBgDispatcher.close() } @Test @@ -722,6 +727,7 @@ class ComputeAffectedTestsTest { // Note that main() can't be used since the shard counts need to be overwritten. Dagger would // be a nicer means to do this, but it's not set up currently for scripts. ComputeAffectedTests( + scriptBgDispatcher, maxTestCountPerLargeShard = maxTestCountPerLargeShard, maxTestCountPerMediumShard = maxTestCountPerMediumShard, maxTestCountPerSmallShard = maxTestCountPerSmallShard diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel index bceb5cfe864..bb2009d98bd 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/common/BUILD.bazel @@ -61,3 +61,14 @@ kt_jvm_test( "//third_party:org_jetbrains_kotlin_kotlin-test-junit", ], ) + +kt_jvm_test( + name = "ScriptBackgroundCoroutineDispatcherTest", + srcs = ["ScriptBackgroundCoroutineDispatcherTest.kt"], + deps = [ + "//scripts/src/java/org/oppia/android/scripts/common:script_background_coroutine_dispatcher", + "//testing:assertion_helpers", + "//third_party:org_jetbrains_kotlin_kotlin-test-junit", + "//third_party:org_mockito_mockito-core", + ], +) diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt index 07aa4d4134c..57b2f26964a 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt @@ -1,6 +1,7 @@ package org.oppia.android.scripts.common import com.google.common.truth.Truth.assertThat +import org.junit.After import org.junit.Before import org.junit.Rule import org.junit.Test @@ -25,19 +26,20 @@ import java.util.concurrent.TimeUnit // Function name: test names are conventionally named with underscores. @Suppress("SameParameterValue", "FunctionName") class BazelClientTest { - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() + @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() - @Rule - @JvmField - val mockitoRule: MockitoRule = MockitoJUnit.rule() - - private val commandExecutor by lazy { initiazeCommandExecutorWithLongProcessWaitTime() } + private val scriptBgDispatcher by lazy { ScriptBackgroundCoroutineDispatcher() } + private val commandExecutor by lazy { CommandExecutorImpl(scriptBgDispatcher) } + private val longCommandExecutor by lazy { initializeCommandExecutorWithLongProcessWaitTime() } private lateinit var testBazelWorkspace: TestBazelWorkspace - @Mock - lateinit var mockCommandExecutor: CommandExecutor + @Mock lateinit var mockCommandExecutor: CommandExecutor + + @After + fun tearDown() { + scriptBgDispatcher.close() + } @Before fun setUp() { @@ -46,7 +48,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_emptyFolder_fails() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) val exception = assertThrows() { bazelClient.retrieveAllTestTargets() @@ -59,7 +61,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_emptyWorkspace_fails() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() val exception = assertThrows() { @@ -73,7 +75,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_workspaceWithTest_returnsTestTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("ExampleTest") @@ -84,7 +86,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_workspaceWithMultipleTests_returnsTestTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest") @@ -106,7 +108,7 @@ class BazelClientTest { @Test fun testRetrieveBazelTargets_forFileNotInBuildGraph_returnsEmptyList() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() tempFolder.newFile("filenotingraph") @@ -117,7 +119,7 @@ class BazelClientTest { @Test fun testRetrieveBazelTargets_forTestFile_returnsBazelTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") @@ -128,7 +130,7 @@ class BazelClientTest { @Test fun testRetrieveBazelTargets_forMultipleMixedFiles_returnsBazelTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest", withGeneratedDependency = true) @@ -157,7 +159,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forTargetWithNoTestDependency_returnsNoTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary("SomeDependency") testBazelWorkspace.createTest("FirstTest") @@ -170,7 +172,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forTestFileTarget_returnsTestTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") @@ -181,7 +183,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forDependentFileTarget_returnsTestTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest", withGeneratedDependency = true) @@ -192,7 +194,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forMixedFileTargets_returnsRelatedTestTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary("ExtraDep") testBazelWorkspace.createTest("FirstTest", withExtraDependency = "//:ExtraDep_lib") @@ -227,7 +229,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forNoFiles_returnsEmptyList() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() val testTargets = bazelClient.retrieveTransitiveTestTargets(listOf()) @@ -238,7 +240,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forBuildFile_returnsAllTestsInThatBuildFile() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest") @@ -253,7 +255,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forMultipleBuildFiles_returnsAllRelatedTests() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest", subpackage = "two") @@ -269,7 +271,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forBzlFile_returnsRelatedTests() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() // Generate tests. testBazelWorkspace.createTest("FirstTest") @@ -298,7 +300,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forWorkspace_returnsAllTests() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest", subpackage = "two") @@ -341,7 +343,7 @@ class BazelClientTest { artifactName = "com.android.support:support-annotations:28.0.0", buildFile = thirdPartyBuild ) - val bazelClient = BazelClient(tempFolder.root, commandExecutor) + val bazelClient = BazelClient(tempFolder.root, longCommandExecutor) val thirdPartyDependenciesList = bazelClient.retrieveThirdPartyMavenDepsListForBinary("//:test_oppia") @@ -350,7 +352,7 @@ class BazelClientTest { } @Test - fun testRetrieveMavenDepsList_binaryDependsOnArtifactNotViaThirdParty_doesNotreturnArtifact() { + fun testRetrieveMavenDepsList_binaryDependsOnArtifactNotViaThirdParty_doesNotReturnArtifact() { testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.setUpWorkspaceForRulesJvmExternal( listOf("com.android.support:support-annotations:28.0.0") @@ -371,7 +373,7 @@ class BazelClientTest { artifactName = "com.android.support:support-annotations:28.0.0", buildFile = testBazelWorkspace.rootBuildFile ) - val bazelClient = BazelClient(tempFolder.root, commandExecutor) + val bazelClient = BazelClient(tempFolder.root, longCommandExecutor) val thirdPartyDependenciesList = bazelClient.retrieveThirdPartyMavenDepsListForBinary("//:test_oppia") @@ -463,8 +465,10 @@ class BazelClientTest { return secondNewFile } - private fun initiazeCommandExecutorWithLongProcessWaitTime(): CommandExecutorImpl { - return CommandExecutorImpl(processTimeout = 5, processTimeoutUnit = TimeUnit.MINUTES) + private fun initializeCommandExecutorWithLongProcessWaitTime(): CommandExecutorImpl { + return CommandExecutorImpl( + scriptBgDispatcher, processTimeout = 5, processTimeoutUnit = TimeUnit.MINUTES + ) } private fun updateBuildFileToUseCustomJvmTestRule(bazelFile: File, buildFile: File) { diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt index 78dc945dff6..140c27bfe1d 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/CommandExecutorImplTest.kt @@ -1,6 +1,7 @@ package org.oppia.android.scripts.common import com.google.common.truth.Truth.assertThat +import org.junit.After import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder @@ -19,13 +20,18 @@ import java.util.concurrent.TimeUnit // Function name: test names are conventionally named with underscores. @Suppress("FunctionName") class CommandExecutorImplTest { - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() + + private val scriptBgDispatcher by lazy { ScriptBackgroundCoroutineDispatcher() } + + @After + fun tearDown() { + scriptBgDispatcher.close() + } @Test fun testExecute_echo_oneArgument_succeedsWithOutput() { - val commandExecutor = CommandExecutorImpl() + val commandExecutor = CommandExecutorImpl(scriptBgDispatcher) val result = commandExecutor.executeCommand(tempFolder.root, "echo", "value") @@ -35,7 +41,7 @@ class CommandExecutorImplTest { @Test fun testExecute_echo_invalidDirectory_throwsException() { - val commandExecutor = CommandExecutorImpl() + val commandExecutor = CommandExecutorImpl(scriptBgDispatcher) val exception = assertThrows() { commandExecutor.executeCommand(File("invaliddirectory"), "echo", "value") @@ -47,7 +53,7 @@ class CommandExecutorImplTest { @Test fun testExecute_echo_largeOutput_insufficientTimeout_throwsException() { val commandExecutor = CommandExecutorImpl( - processTimeout = 0L, processTimeoutUnit = TimeUnit.MILLISECONDS + scriptBgDispatcher, processTimeout = 0L, processTimeoutUnit = TimeUnit.MILLISECONDS ) // Produce a large output so that echo takes a bit longer to reduce the likelihood of this test @@ -63,7 +69,7 @@ class CommandExecutorImplTest { @Test fun testExecute_nonexistentCommand_throwsException() { - val commandExecutor = CommandExecutorImpl() + val commandExecutor = CommandExecutorImpl(scriptBgDispatcher) val exception = assertThrows() { commandExecutor.executeCommand(tempFolder.root, "commanddoesnotexist") @@ -74,7 +80,7 @@ class CommandExecutorImplTest { @Test fun testExecute_echo_multipleArguments_succeedsWithOutput() { - val commandExecutor = CommandExecutorImpl() + val commandExecutor = CommandExecutorImpl(scriptBgDispatcher) val result = commandExecutor.executeCommand(tempFolder.root, "echo", "first", "second", "third") @@ -84,7 +90,7 @@ class CommandExecutorImplTest { @Test fun testExecute_echo_multipleArguments_resultHasCorrectCommand() { - val commandExecutor = CommandExecutorImpl() + val commandExecutor = CommandExecutorImpl(scriptBgDispatcher) val result = commandExecutor.executeCommand(tempFolder.root, "echo", "first", "second", "third") @@ -93,7 +99,7 @@ class CommandExecutorImplTest { @Test fun testExecute_defaultErrorOutput_rmdir_failed_failsWithCombinedOutput() { - val commandExecutor = CommandExecutorImpl() + val commandExecutor = CommandExecutorImpl(scriptBgDispatcher) val result = commandExecutor.executeCommand(tempFolder.root, "rmdir", "filethatdoesnotexist") @@ -105,7 +111,7 @@ class CommandExecutorImplTest { @Test fun testExecute_splitErrorOutput_rmdir_failed_failsWithErrorOutput() { - val commandExecutor = CommandExecutorImpl() + val commandExecutor = CommandExecutorImpl(scriptBgDispatcher) val result = commandExecutor.executeCommand( @@ -121,7 +127,7 @@ class CommandExecutorImplTest { @Test fun testExecute_removeDirectoryInLocalDirectory_succeeds() { val newFolder = tempFolder.newFolder("newfolder") - val commandExecutor = CommandExecutorImpl() + val commandExecutor = CommandExecutorImpl(scriptBgDispatcher) val result = commandExecutor.executeCommand(tempFolder.root, "rmdir", "./newfolder") @@ -135,7 +141,7 @@ class CommandExecutorImplTest { fun testExecute_removeUnknownDirectoryInOtherDirectory_fails() { val newFolder = tempFolder.newFolder("newfolder") val alternateRoot = tempFolder.newFolder("alternateroot") - val commandExecutor = CommandExecutorImpl() + val commandExecutor = CommandExecutorImpl(scriptBgDispatcher) val result = commandExecutor.executeCommand(alternateRoot, "rmdir", "./newfolder") diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt index 5cbda509373..51efeeadd0a 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt @@ -20,12 +20,11 @@ import java.lang.IllegalStateException // Function name: test names are conventionally named with underscores. @Suppress("FunctionName") class GitClientTest { - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() private lateinit var testGitRepository: TestGitRepository - private val commandExecutor by lazy { CommandExecutorImpl() } + private val scriptBgDispatcher by lazy { ScriptBackgroundCoroutineDispatcher() } + private val commandExecutor by lazy { CommandExecutorImpl(scriptBgDispatcher) } @Before fun setUp() { @@ -38,11 +37,12 @@ class GitClientTest { // and to help manually verify the expect git state at the end of each test. println("git status (at end of test):") println(testGitRepository.status(checkForGitRepository = false)) + scriptBgDispatcher.close() } @Test fun testCurrentCommit_forNonRepository_throwsException() { - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val exception = assertThrows() { gitClient.currentCommit } @@ -55,7 +55,7 @@ class GitClientTest { initializeRepoWithDevelopBranch() val developHash = getMostRecentCommitOnCurrentBranch() - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val currentCommit = gitClient.currentCommit assertThat(currentCommit).isEqualTo(developHash) @@ -69,7 +69,7 @@ class GitClientTest { testGitRepository.commit(message = "Test empty commit", allowEmpty = true) val featureBranchHash = getMostRecentCommitOnCurrentBranch() - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val currentCommit = gitClient.currentCommit assertThat(currentCommit).isNotEqualTo(developHash) @@ -78,7 +78,7 @@ class GitClientTest { @Test fun testCurrentBranch_forNonRepository_throwsException() { - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val exception = assertThrows() { gitClient.currentBranch } @@ -90,7 +90,7 @@ class GitClientTest { fun testCurrentBranch_forValidRepository_returnsCorrectBranch() { initializeRepoWithDevelopBranch() - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val currentBranch = gitClient.currentBranch assertThat(currentBranch).isEqualTo("develop") @@ -101,7 +101,7 @@ class GitClientTest { initializeRepoWithDevelopBranch() testGitRepository.checkoutNewBranch("introduce-feature") - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val currentBranch = gitClient.currentBranch assertThat(currentBranch).isEqualTo("introduce-feature") @@ -112,7 +112,7 @@ class GitClientTest { initializeRepoWithDevelopBranch() val developHash = getMostRecentCommitOnCurrentBranch() - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val mergeBase = gitClient.branchMergeBase assertThat(mergeBase).isEqualTo(developHash) @@ -124,7 +124,7 @@ class GitClientTest { val developHash = getMostRecentCommitOnCurrentBranch() testGitRepository.checkoutNewBranch("introduce-feature") - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val mergeBase = gitClient.branchMergeBase assertThat(mergeBase).isEqualTo(developHash) @@ -137,7 +137,7 @@ class GitClientTest { testGitRepository.checkoutNewBranch("introduce-feature") commitNewFile("example_file") - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val mergeBase = gitClient.branchMergeBase // The merge base is the latest common hash between this & the develop branch. @@ -149,7 +149,7 @@ class GitClientTest { initializeRepoWithDevelopBranch() testGitRepository.checkoutNewBranch("introduce-feature") - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val changedFiles = gitClient.changedFiles assertThat(changedFiles).isEmpty() @@ -161,7 +161,7 @@ class GitClientTest { testGitRepository.checkoutNewBranch("introduce-feature") createNewFile("example_file") - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val changedFiles = gitClient.changedFiles assertThat(changedFiles).containsExactly("example_file") @@ -173,7 +173,7 @@ class GitClientTest { testGitRepository.checkoutNewBranch("introduce-feature") stageNewFile("example_file") - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val changedFiles = gitClient.changedFiles assertThat(changedFiles).containsExactly("example_file") @@ -185,7 +185,7 @@ class GitClientTest { testGitRepository.checkoutNewBranch("introduce-feature") commitNewFile("example_file") - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val changedFiles = gitClient.changedFiles assertThat(changedFiles).containsExactly("example_file") @@ -197,7 +197,7 @@ class GitClientTest { commitNewFile("develop_file") testGitRepository.checkoutNewBranch("introduce-feature") - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val changedFiles = gitClient.changedFiles // Committed files to the develop branch are not included since they aren't part of the feature @@ -212,7 +212,7 @@ class GitClientTest { commitNewFile("example_file") modifyFile("example_file") - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val changedFiles = gitClient.changedFiles assertThat(changedFiles).containsExactly("example_file") @@ -225,7 +225,7 @@ class GitClientTest { testGitRepository.checkoutNewBranch("introduce-feature") deleteFile("develop_file") - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val changedFiles = gitClient.changedFiles assertThat(changedFiles).containsExactly("develop_file") @@ -244,7 +244,7 @@ class GitClientTest { modifyFile("develop_branch_file_changed_not_staged") deleteFile("develop_branch_file_removed") - val gitClient = GitClient(tempFolder.root, "develop") + val gitClient = GitClient(tempFolder.root, "develop", commandExecutor) val changedFiles = gitClient.changedFiles assertThat(changedFiles).containsExactly( diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcherTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcherTest.kt new file mode 100644 index 00000000000..68329ac15fa --- /dev/null +++ b/scripts/src/javatests/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcherTest.kt @@ -0,0 +1,79 @@ +package org.oppia.android.scripts.common + +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.async +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.delay +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.withContext +import org.junit.Rule +import org.junit.Test +import org.mockito.Mock +import org.mockito.Mockito.verify +import org.mockito.Mockito.verifyNoMoreInteractions +import org.mockito.junit.MockitoJUnit +import org.mockito.junit.MockitoRule +import org.oppia.android.testing.assertThrows +import java.util.concurrent.TimeUnit + +/** Tests for [ScriptBackgroundCoroutineDispatcher]. */ +// FunctionName: test names are conventionally named with underscores. +@Suppress("FunctionName") +class ScriptBackgroundCoroutineDispatcherTest { + @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() + + @Mock lateinit var mockRunnable: Runnable + + @Test + fun testDispatchTask_taskIsRun() { + val dispatcher = ScriptBackgroundCoroutineDispatcher() + + runBlocking { withContext(dispatcher) { mockRunnable.run() } } + + verify(mockRunnable).run() + } + + @Test + fun testClose_noExceptionThrown() { + val dispatcher = ScriptBackgroundCoroutineDispatcher() + + dispatcher.close() + + // The verification is that no exception is thrown (otherwise the test should fail). + } + + @Test + fun testDispatch_afterClosing_throwsException() { + val dispatcher = ScriptBackgroundCoroutineDispatcher() + dispatcher.close() + + // The task should fail to schedule since the dispatcher has been closed. + assertThrows() { + runBlocking { withContext(dispatcher) { mockRunnable.run() } } + } + } + + @Test + fun testClose_pendingTaskLongerThanCloseTimeout_taskIsNotRun() { + val dispatcher = + ScriptBackgroundCoroutineDispatcher( + closeTimeout = 50L, closeTimeoutUnit = TimeUnit.MILLISECONDS + ) + val taskStartedChannel = Channel() + // Schedule a task but make sure that the attempt to close the dispatcher happens exactly + // between the task starting and ending (to verify close timeout flows). + @Suppress("DeferredResultUnused") + CoroutineScope(dispatcher).async { + taskStartedChannel.send(true) + delay(1_000L) + mockRunnable.run() + } + runBlocking { taskStartedChannel.receive() } + + dispatcher.close() + + // The task should not have run since it was cancelled, but no exception will be thrown. + verifyNoMoreInteractions(mockRunnable) + } +} diff --git a/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt index 5fdc807e3db..6ecefd7ddce 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesListCheckTest.kt @@ -10,6 +10,7 @@ import org.mockito.kotlin.doReturn import org.mockito.kotlin.eq import org.mockito.kotlin.mock import org.oppia.android.scripts.common.CommandExecutorImpl +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher import org.oppia.android.scripts.proto.DirectLinkOnly import org.oppia.android.scripts.proto.ExtractedCopyLink import org.oppia.android.scripts.proto.License @@ -79,16 +80,16 @@ class MavenDependenciesListCheckTest { private val UNAVAILABLE_OR_INVALID_LICENSE_LINKS_FAILURE = "License links are invalid or not available for some dependencies" + @field:[Rule JvmField] val tempFolder = TemporaryFolder() + private val outContent: ByteArrayOutputStream = ByteArrayOutputStream() private val originalOut: PrintStream = System.out + private val scriptBgDispatcher by lazy { ScriptBackgroundCoroutineDispatcher() } private val mockLicenseFetcher by lazy { initializeLicenseFetcher() } private val commandExecutor by lazy { initializeCommandExecutorWithLongProcessWaitTime() } - private lateinit var testBazelWorkspace: TestBazelWorkspace - @Rule - @JvmField - var tempFolder = TemporaryFolder() + private lateinit var testBazelWorkspace: TestBazelWorkspace @Before fun setUp() { @@ -101,6 +102,7 @@ class MavenDependenciesListCheckTest { @After fun restoreStreams() { System.setOut(originalOut) + scriptBgDispatcher.close() } @Test @@ -113,6 +115,7 @@ class MavenDependenciesListCheckTest { val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -135,14 +138,14 @@ class MavenDependenciesListCheckTest { license_name: "The Apache License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" } - + artifact_name: "com.google.firebase:firebase-analytics:17.5.0" artifact_version: "17.5.0" license { license_name: "Android Software Development Kit License" original_link: "https://developer.android.com/studio/terms.html" } - + Refer to https://github.com/oppia/oppia-android/wiki/Updating-Maven-Dependencies for more details. """.trimIndent() + "\n" ) @@ -189,6 +192,7 @@ class MavenDependenciesListCheckTest { val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -211,7 +215,7 @@ class MavenDependenciesListCheckTest { license_name: "Android Software Development Kit License" original_link: "https://developer.android.com/studio/terms.html" } - + Refer to https://github.com/oppia/oppia-android/wiki/Updating-Maven-Dependencies for more details. """.trimIndent() + "\n" ) @@ -253,6 +257,7 @@ class MavenDependenciesListCheckTest { val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -275,14 +280,14 @@ class MavenDependenciesListCheckTest { license_name: "The Apache License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" } - + artifact_name: "$FIREBASE_ANALYTICS_DEP" artifact_version: "$FIREBASE_ANALYTICS_VERSION" license { license_name: "Android Software Development Kit License" original_link: "https://developer.android.com/studio/terms.html" } - + Refer to https://github.com/oppia/oppia-android/wiki/Updating-Maven-Dependencies for more details. """.trimIndent() + "\n" ) @@ -329,6 +334,7 @@ class MavenDependenciesListCheckTest { val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -408,6 +414,7 @@ class MavenDependenciesListCheckTest { val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -430,7 +437,7 @@ class MavenDependenciesListCheckTest { license_name: "The Apache License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" } - + artifact_name: "$FIREBASE_ANALYTICS_DEP" artifact_version: "$FIREBASE_ANALYTICS_VERSION" license { @@ -484,6 +491,7 @@ class MavenDependenciesListCheckTest { val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -508,14 +516,14 @@ class MavenDependenciesListCheckTest { } Missing dependencies that need to be added: - + artifact_name: "$FIREBASE_ANALYTICS_DEP" artifact_version: "$FIREBASE_ANALYTICS_VERSION" license { license_name: "Android Software Development Kit License" original_link: "https://developer.android.com/studio/terms.html" } - + Refer to https://github.com/oppia/oppia-android/wiki/Updating-Maven-Dependencies for more details. """.trimIndent() + "\n" ) @@ -562,6 +570,7 @@ class MavenDependenciesListCheckTest { val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -586,14 +595,14 @@ class MavenDependenciesListCheckTest { } Missing dependencies that need to be added: - + artifact_name: "$FIREBASE_ANALYTICS_UPGRADED_DEP" artifact_version: "$FIREBASE_ANALYTICS_UPGRADED_VERSION" license { license_name: "Android Software Development Kit License" original_link: "https://developer.android.com/studio/terms.html" } - + Refer to https://github.com/oppia/oppia-android/wiki/Updating-Maven-Dependencies for more details. """.trimIndent() + "\n" ) @@ -640,6 +649,7 @@ class MavenDependenciesListCheckTest { val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -651,7 +661,7 @@ class MavenDependenciesListCheckTest { } assertThat(exception).hasMessageThat().contains(MISSING_AND_REDUNDANT_DEPENDENCIES_FAILURE) assertThat(outContent.toString()).isEqualTo( - """ + """ Errors were encountered. Please run script GenerateMavenDependenciesList.kt to fix. Redundant dependencies that need to be removed: @@ -664,14 +674,14 @@ class MavenDependenciesListCheckTest { } Missing dependencies that need to be added: - + artifact_name: "$FIREBASE_ANALYTICS_DEP" artifact_version: "$FIREBASE_ANALYTICS_VERSION" license { license_name: "Android Software Development Kit License" original_link: "https://developer.android.com/studio/terms.html" } - + Refer to https://github.com/oppia/oppia-android/wiki/Updating-Maven-Dependencies for more details. """.trimIndent() + "\n" ) @@ -720,6 +730,7 @@ class MavenDependenciesListCheckTest { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -773,6 +784,7 @@ class MavenDependenciesListCheckTest { val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -822,6 +834,7 @@ class MavenDependenciesListCheckTest { val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -877,6 +890,7 @@ class MavenDependenciesListCheckTest { val exception = assertThrows() { MavenDependenciesListCheck( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -1018,13 +1032,15 @@ class MavenDependenciesListCheckTest { } ] } - } + } """.trimIndent() ) } private fun initializeCommandExecutorWithLongProcessWaitTime(): CommandExecutorImpl { - return CommandExecutorImpl(processTimeout = 5, processTimeoutUnit = TimeUnit.MINUTES) + return CommandExecutorImpl( + scriptBgDispatcher, processTimeout = 5, processTimeoutUnit = TimeUnit.MINUTES + ) } /** Returns a mock for the [LicenseFetcher]. */ diff --git a/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesRetrieverTest.kt b/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesRetrieverTest.kt index 5dd8baec8b3..311bfe5f446 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesRetrieverTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/license/MavenDependenciesRetrieverTest.kt @@ -11,6 +11,7 @@ import org.mockito.kotlin.doReturn import org.mockito.kotlin.eq import org.mockito.kotlin.mock import org.oppia.android.scripts.common.CommandExecutorImpl +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher import org.oppia.android.scripts.maven.model.MavenListDependency import org.oppia.android.scripts.proto.DirectLinkOnly import org.oppia.android.scripts.proto.ExtractedCopyLink @@ -81,12 +82,11 @@ class MavenDependenciesRetrieverTest { private val mavenDependenciesRetriever by lazy { initializeMavenDependenciesRetriever() } + private val scriptBgDispatcher by lazy { ScriptBackgroundCoroutineDispatcher() } private lateinit var testBazelWorkspace: TestBazelWorkspace - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() @Before fun setUp() { @@ -99,6 +99,7 @@ class MavenDependenciesRetrieverTest { @After fun restoreStreams() { System.setOut(originalOut) + scriptBgDispatcher.close() } @Test @@ -1220,13 +1221,15 @@ class MavenDependenciesRetrieverTest { } ] } - } + } """.trimIndent() ) } private fun initializeCommandExecutorWithLongProcessWaitTime(): CommandExecutorImpl { - return CommandExecutorImpl(processTimeout = 5, processTimeoutUnit = TimeUnit.MINUTES) + return CommandExecutorImpl( + scriptBgDispatcher, processTimeout = 5, processTimeoutUnit = TimeUnit.MINUTES + ) } /** Returns a mock for the [LicenseFetcher]. */ diff --git a/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt b/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt index 4507d76a5dc..96e3a92ad64 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/maven/GenerateMavenDependenciesListTest.kt @@ -11,6 +11,7 @@ import org.mockito.kotlin.doReturn import org.mockito.kotlin.eq import org.mockito.kotlin.mock import org.oppia.android.scripts.common.CommandExecutorImpl +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher import org.oppia.android.scripts.license.LicenseFetcher import org.oppia.android.scripts.proto.DirectLinkOnly import org.oppia.android.scripts.proto.ExtractedCopyLink @@ -64,17 +65,16 @@ class GenerateMavenDependenciesListTest { private val SCRIPT_PASSED_MESSAGE = "Script executed succesfully: maven_dependencies.textproto updated successfully." + @field:[Rule JvmField] val tempFolder = TemporaryFolder() + private val outContent: ByteArrayOutputStream = ByteArrayOutputStream() private val originalOut: PrintStream = System.out + private val scriptBgDispatcher by lazy { ScriptBackgroundCoroutineDispatcher() } private val mockLicenseFetcher by lazy { initializeLicenseFetcher() } private val commandExecutor by lazy { initializeCommandExecutorWithLongProcessWaitTime() } private lateinit var testBazelWorkspace: TestBazelWorkspace - @Rule - @JvmField - var tempFolder = TemporaryFolder() - @Before fun setUp() { tempFolder.newFolder("scripts", "assets") @@ -86,6 +86,7 @@ class GenerateMavenDependenciesListTest { @After fun restoreStreams() { System.setOut(originalOut) + scriptBgDispatcher.close() } @Test @@ -99,6 +100,7 @@ class GenerateMavenDependenciesListTest { val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -183,6 +185,7 @@ class GenerateMavenDependenciesListTest { val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -207,6 +210,7 @@ class GenerateMavenDependenciesListTest { val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -249,6 +253,7 @@ class GenerateMavenDependenciesListTest { val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -316,6 +321,7 @@ class GenerateMavenDependenciesListTest { val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -358,6 +364,7 @@ class GenerateMavenDependenciesListTest { val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -426,6 +433,7 @@ class GenerateMavenDependenciesListTest { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -519,6 +527,7 @@ class GenerateMavenDependenciesListTest { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -617,6 +626,7 @@ class GenerateMavenDependenciesListTest { val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -680,6 +690,7 @@ class GenerateMavenDependenciesListTest { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -793,6 +804,7 @@ class GenerateMavenDependenciesListTest { val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -918,6 +930,7 @@ class GenerateMavenDependenciesListTest { val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -1031,6 +1044,7 @@ class GenerateMavenDependenciesListTest { val exception = assertThrows() { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -1150,6 +1164,7 @@ class GenerateMavenDependenciesListTest { GenerateMavenDependenciesList( mockLicenseFetcher, + scriptBgDispatcher, commandExecutor ).main( arrayOf( @@ -1394,13 +1409,15 @@ class GenerateMavenDependenciesListTest { } ] } - } + } """.trimIndent() ) } private fun initializeCommandExecutorWithLongProcessWaitTime(): CommandExecutorImpl { - return CommandExecutorImpl(processTimeout = 5, processTimeoutUnit = TimeUnit.MINUTES) + return CommandExecutorImpl( + scriptBgDispatcher, processTimeout = 5, processTimeoutUnit = TimeUnit.MINUTES + ) } /** Returns a mock for the [LicenseFetcher]. */ diff --git a/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt b/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt index 453f17da044..0782a6c5512 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/testing/TestGitRepositoryTest.kt @@ -1,12 +1,14 @@ package org.oppia.android.scripts.testing import com.google.common.truth.Truth.assertThat +import org.junit.After import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder import org.oppia.android.scripts.common.CommandExecutor import org.oppia.android.scripts.common.CommandExecutorImpl import org.oppia.android.scripts.common.CommandResult +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher import org.oppia.android.testing.assertThrows import java.io.File import java.util.UUID @@ -31,11 +33,15 @@ import java.util.UUID // Function name: test names are conventionally named with underscores. @Suppress("FunctionName") class TestGitRepositoryTest { - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() - private val commandExecutorInterceptor by lazy { CommandExecutorInterceptor() } + private val scriptBgDispatcher by lazy { ScriptBackgroundCoroutineDispatcher() } + private val commandExecutorInterceptor by lazy { CommandExecutorInterceptor(scriptBgDispatcher) } + + @After + fun tearDown() { + scriptBgDispatcher.close() + } @Test fun testCreateTestUtility_doesNotImmediatelyCreateAnyFiles() { @@ -52,7 +58,7 @@ class TestGitRepositoryTest { testGitRepository.init() - assertThat(tempFolder.root.list().toList()).containsExactly(".git") + assertThat(tempFolder.root.list()?.toList()).containsExactly(".git") } @Test @@ -494,9 +500,11 @@ class TestGitRepositoryTest { return file } - private class CommandExecutorInterceptor : CommandExecutor { + private class CommandExecutorInterceptor( + scriptBgDispatcher: ScriptBackgroundCoroutineDispatcher + ) : CommandExecutor { private val commandResults = mutableListOf() - private val realCommandExecutor by lazy { CommandExecutorImpl() } + private val realCommandExecutor by lazy { CommandExecutorImpl(scriptBgDispatcher) } override fun executeCommand( workingDir: File, diff --git a/wiki/Updating-Maven-Dependencies.md b/wiki/Updating-Maven-Dependencies.md index 6e0653f844b..353de7a5d7c 100644 --- a/wiki/Updating-Maven-Dependencies.md +++ b/wiki/Updating-Maven-Dependencies.md @@ -18,7 +18,7 @@ cd ~/opensource/oppia-android The above command ensures that the terminal points to the root directory `oppia-android` repository. Note that if you have configured a different path to the `oppia-android` repository then you should modify the above command accordingly ( `cd ~/` ). #### Running `GenerateMavenDependenciesList.kt` script -After the terminal points to the Oppia-android repository, run the bazel run command to execute the Kotlin script. +After the terminal points to the Oppia-android repository, run the bazel run command to execute the Kotlin script. ``` bazel run //scripts:generate_maven_dependencies_list -- $(pwd) third_party/maven_install.json scripts/assets/maven_dependencies.textproto scripts/assets/maven_dependencies.pb ``` @@ -26,19 +26,19 @@ bazel run //scripts:generate_maven_dependencies_list -- $(pwd) third_party/maven ## Handling Exception: `Too few arguments passed` If after running the script the exception message says: **Too few arguments passed**, then please ensure that you copied the command correctly from [here](https://github.com/oppia/oppia-android/wiki/Updating-Maven-Dependencies#running-generatemavendependencieslistkt-script). The script accepts 4 parameters to be passed to run successfully: -1. **_path_to_directory_root_**: directory path to the root of the Oppia Android repository, e.g - `home//opensource/oppia-android` -2. **_path_to_maven_install_json_**: relative path to the maven_install.json file, e.g - `third_party/maven_install.json` -3. **_path_to_maven_dependencies_textproto_**: relative path to the maven_dependencies.textproto, e.g - `scripts/assets/maven_dependencies.textproto` -4. **_path_to_maven_dependencies_pb_**: relative path to the maven_dependencies.pb file, e.g - `scripts/assets/maven_dependencies.pb` +1. **_path_to_directory_root_**: directory path to the root of the Oppia Android repository, e.g. - `home//opensource/oppia-android` +2. **_path_to_maven_install_json_**: relative path to the maven_install.json file, e.g. - `third_party/maven_install.json` +3. **_path_to_maven_dependencies_textproto_**: relative path to the maven_dependencies.textproto, e.g. - `scripts/assets/maven_dependencies.textproto` +4. **_path_to_maven_dependencies_pb_**: relative path to the maven_dependencies.pb file, e.g. - `scripts/assets/maven_dependencies.pb` ## Handling Exception: `Licenses details are not completed` The script can take about a minute to execute, and if the script fails with the exception: `Licenses details are not completed`, you will need to do some manual work in `maven_dependencies.textproto`. -The script would call out specific dependencies that need to be updated manually, e.g - +The script would call out specific dependencies that need to be updated manually, e.g. - ``` -Please verify the license link(s) for the following license(s) manually in -maven_dependencies.textproto, note that only the first dependency that contains the license +Please verify the license link(s) for the following license(s) manually in +maven_dependencies.textproto, note that only the first dependency that contains the license needs to be updated and also re-run the script to update the license details at all places: license_name: Android Software Development Kit License @@ -67,14 +67,14 @@ maven_dependency { ### Categorizing the license link If the link does point to a valid license then choose the most appropriate category for the link: -1. scrapable_link: If the license text is plain text and the URL mentioned can be scraped directly from the original_link of the license. - e.g - https://www.apache.org/licenses/LICENSE-2.0.txt +1. scrapable_link: If the license text is plain text and the URL mentioned can be scraped directly from the original_link of the license. + e.g. - https://www.apache.org/licenses/LICENSE-2.0.txt 2. extracted_copy_link: If the license text is plain text but can not be scraped directly from the original_link of the license. - e.g - https://opensource.org/license/bsd-3-clause + e.g. - https://opensource.org/license/bsd-3-clause 3. direct_link_only: If the license text is not plain text, it's best to display only the link of the license. - e.g - https://developer.android.com/studio/terms.html + e.g. - https://developer.android.com/studio/terms.html -After identifying the category of the license, modify the license to include one of the above-mentioned 'url'. e.g - +After identifying the category of the license, modify the license to include one of the above-mentioned 'url'. e.g. - ``` license { license_name: "The Apache Software License, Version 2.0" @@ -86,7 +86,7 @@ license { ``` Also, if the license falls in the `extracted_copy_link` category, then go to [Oppia-android-licenses](https://github.com/oppia/oppia-android-licenses) and find if there exists a copy of the license already in the repository. If there exists a copy of the license, perform the following steps to get the link for the license that can be scraped easily. -1. Click on the appropriate license file. +1. Click on the appropriate license file. 2. Now click on the raw button positioned in the left of the edit and delete button. 3. Copy the URL from the browser and mention it at the appropriate place. @@ -95,7 +95,7 @@ If the license does not exist in the Oppia-android-licenses repository, then coo -After modifying `maven_dependencies.textproto` for all the called out licenses in the console output, re-run the script and see if any other error occurs. +After modifying `maven_dependencies.textproto` for all the called out licenses in the console output, re-run the script and see if any other error occurs. ## Handling Exception: `License links are invalid or not available for some dependencies` @@ -122,7 +122,7 @@ maven_dependency { To fix the error, consider the above example. For the first maven_dependency: "io.fabric.sdk.android:fabric:1.4.7", the original_link is invalid, and hence we need to find a valid link for this dependency. Please coordinate with the Oppia Android team and find a valid link for this dependency. Once you have a valid link for this license then categorize it as mentioned [here](https://github.com/oppia/oppia-android/wiki/Updating-Maven-Dependencies#categorizing-the-license-link). -For the second maven_dependency: "com.google.guava:failureaccess:1.0.1", you need to find a license by coordinating with the Oppia Android team and then specify it under the artifact_version field of the dependency. e.g - +For the second maven_dependency: "com.google.guava:failureaccess:1.0.1", you need to find a license by coordinating with the Oppia Android team and then specify it under the artifact_version field of the dependency. e.g. - ``` maven_dependency { From 79878cd134857d2581b7c42f20fafd6060c0d316 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 19 Jan 2024 21:27:12 +0000 Subject: [PATCH 07/21] Some more robustness fixes. The main change here is ensuring that Bazel 4.0.0 is used & bzlmod disabled in newer versions of Bazel when running operations in a test Bazel environment. This commit also introduces some more timing tweaks on CommandExecutor for some tests, though these only affect very specific tests (as many script tests directly call a script's main() function and thus don't overwrite its executor behavior). This commit attempted to introduce "--batch" mode to runs, but the isolation didn't actually seem to improve stability and, instead, substantially slowed down some of the tests. --- .../scripts/ci/ComputeAffectedTests.kt | 11 +++-- .../scripts/testing/TestBazelWorkspace.kt | 29 +++++++++--- .../org/oppia/android/scripts/ci/BUILD.bazel | 2 +- .../scripts/ci/ComputeAffectedTestsTest.kt | 15 ++++--- .../android/scripts/common/BazelClientTest.kt | 44 ++++++++----------- .../oppia/android/scripts/license/BUILD.bazel | 1 + .../oppia/android/scripts/maven/BUILD.bazel | 1 + 7 files changed, 63 insertions(+), 40 deletions(-) diff --git a/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt b/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt index f7cc482c72a..5437874f191 100644 --- a/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt +++ b/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt @@ -1,6 +1,8 @@ package org.oppia.android.scripts.ci import org.oppia.android.scripts.common.BazelClient +import org.oppia.android.scripts.common.CommandExecutor +import org.oppia.android.scripts.common.CommandExecutorImpl import org.oppia.android.scripts.common.GitClient import org.oppia.android.scripts.common.ProtoStringEncoder.Companion.toCompressedBase64 import org.oppia.android.scripts.proto.AffectedTestsBucket @@ -73,9 +75,10 @@ private fun String.toBooleanStrictOrNull(): Boolean? { /** Utility used to compute affected test targets. */ class ComputeAffectedTests( - val maxTestCountPerLargeShard: Int = MAX_TEST_COUNT_PER_LARGE_SHARD, - val maxTestCountPerMediumShard: Int = MAX_TEST_COUNT_PER_MEDIUM_SHARD, - val maxTestCountPerSmallShard: Int = MAX_TEST_COUNT_PER_SMALL_SHARD + private val maxTestCountPerLargeShard: Int = MAX_TEST_COUNT_PER_LARGE_SHARD, + private val maxTestCountPerMediumShard: Int = MAX_TEST_COUNT_PER_MEDIUM_SHARD, + private val maxTestCountPerSmallShard: Int = MAX_TEST_COUNT_PER_SMALL_SHARD, + private val commandExecutor: CommandExecutor = CommandExecutorImpl() ) { private companion object { private const val GENERIC_TEST_BUCKET_NAME = "generic" @@ -106,7 +109,7 @@ class ComputeAffectedTests( println("Running from directory root: $rootDirectory") val gitClient = GitClient(rootDirectory, baseDevelopBranchReference) - val bazelClient = BazelClient(rootDirectory) + val bazelClient = BazelClient(rootDirectory, commandExecutor) println("Current branch: ${gitClient.currentBranch}") println("Most recent common commit: ${gitClient.branchMergeBase}") diff --git a/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt b/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt index 68487b6062b..f1230c0f63d 100644 --- a/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt +++ b/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt @@ -4,6 +4,9 @@ import com.google.common.truth.Truth.assertThat import org.junit.rules.TemporaryFolder import java.io.File +/** The version of Bazel to use in tests that set up Bazel workspaces. */ +const val BAZEL_VERSION = "4.0.0" + /** * Test utility for generating various test & library targets in the specified [TemporaryFolder]. * This is meant to be used to arrange the local test filesystem for use with a real Bazel @@ -23,6 +26,13 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { */ val rootBuildFile: File by lazy { temporaryRootFolder.newFile("BUILD.bazel") } + private val bazelVersionFile by lazy { + temporaryRootFolder.newFile(".bazelversion").also { it.writeText(BAZEL_VERSION) } + } + private val bazelRcFile by lazy { + temporaryRootFolder.newFile(".bazelrc").also { it.writeText("--noenable_bzlmod") } + } + private val testFileMap = mutableMapOf() private val libraryFileMap = mutableMapOf() private val testDependencyNameMap = mutableMapOf() @@ -33,9 +43,11 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { /** Initializes the local Bazel workspace by introducing a new, empty WORKSPACE file. */ fun initEmptyWorkspace() { - // Sanity check, but in reality this is just initializing workspaceFile to ensure that it + // Sanity checks, but in reality this is just initializing workspaceFile to ensure that it // exists. assertThat(workspaceFile.exists()).isTrue() + assertThat(bazelVersionFile.exists()).isTrue() + assertThat(bazelRcFile.exists()).isTrue() } /** @@ -61,6 +73,8 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { withExtraDependency: String? = null, subpackage: String? = null ): Iterable { + initEmptyWorkspace() // Ensure the workspace is at least initialized. + check(testName !in testFileMap) { "Test '$testName' already set up" } val prereqFiles = ensureWorkspaceIsConfiguredForKotlin() val (dependencyTargetName, libPrereqFiles) = if (withGeneratedDependency) { @@ -109,6 +123,8 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { withExtraDependency: String? = null, subpackage: String? = null ): Iterable { + initEmptyWorkspace() // Ensure the workspace is at least initialized. + check(testName !in testFileMap) { "Test '$testName' already exists" } val testFile = if (subpackage != null) { if (!File(temporaryRootFolder.root, subpackage.replace(".", "/")).exists()) { @@ -137,6 +153,8 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { * iterable of files that were changed as part of generating this library */ fun createLibrary(dependencyName: String): Pair> { + initEmptyWorkspace() // Ensure the workspace is at least initialized. + val libTargetName = "${dependencyName}_lib" check("//:$libTargetName" !in libraryFileMap) { "Library '$dependencyName' already exists" } val prereqFiles = ensureWorkspaceIsConfiguredForKotlin() @@ -187,6 +205,7 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { /** Appends rules_jvm_external configuration to the WORKSPACE file if not done already. */ fun setUpWorkspaceForRulesJvmExternal(depsList: List) { if (!isConfiguredForRulesJvmExternal) { + initEmptyWorkspace() workspaceFile.appendText("artifactsList = [") for (dep in depsList) { workspaceFile.appendText("\"$dep\",\n") @@ -198,23 +217,23 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { RULES_JVM_EXTERNAL_TAG = "4.0" RULES_JVM_EXTERNAL_SHA = "31701ad93dbfe544d597dbe62c9a1fdd76d81d8a9150c2bf1ecf928ecdf97169" - + http_archive( name = "rules_jvm_external", strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, sha256 = RULES_JVM_EXTERNAL_SHA, url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, ) - + load("@rules_jvm_external//:defs.bzl", "maven_install") - + maven_install( artifacts = artifactsList, repositories = [ "https://maven.google.com", "https://repo1.maven.org/maven2", ], - ) + ) """.trimIndent() + "\n" ) diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel index 3160447f15f..fcdb77f2f1d 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/BUILD.bazel @@ -8,7 +8,7 @@ kt_jvm_test( name = "ComputeAffectedTestsTest", size = "large", srcs = ["ComputeAffectedTestsTest.kt"], - shard_count = 8, + shard_count = 24, deps = [ "//scripts/src/java/org/oppia/android/scripts/ci:compute_affected_tests_lib", "//scripts/src/java/org/oppia/android/scripts/common:proto_string_encoder", diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt index 5bbdc432d62..2bf59212f66 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt @@ -16,6 +16,7 @@ import java.io.ByteArrayOutputStream import java.io.File import java.io.OutputStream import java.io.PrintStream +import java.util.concurrent.TimeUnit /** * Tests for the compute_affected_tests utility. @@ -28,13 +29,12 @@ import java.io.PrintStream // Function name: test names are conventionally named with underscores. @Suppress("SameParameterValue", "FunctionName") class ComputeAffectedTestsTest { - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() + + private val commandExecutor by lazy { initiazeCommandExecutorWithLongProcessWaitTime() } private lateinit var testBazelWorkspace: TestBazelWorkspace private lateinit var testGitRepository: TestGitRepository - private lateinit var pendingOutputStream: ByteArrayOutputStream private lateinit var originalStandardOutputStream: OutputStream @@ -724,7 +724,8 @@ class ComputeAffectedTestsTest { ComputeAffectedTests( maxTestCountPerLargeShard = maxTestCountPerLargeShard, maxTestCountPerMediumShard = maxTestCountPerMediumShard, - maxTestCountPerSmallShard = maxTestCountPerSmallShard + maxTestCountPerSmallShard = maxTestCountPerSmallShard, + commandExecutor = commandExecutor ).compute( pathToRoot = tempFolder.root.absolutePath, pathToOutputFile = outputLog.absolutePath, @@ -862,4 +863,8 @@ class ComputeAffectedTestsTest { testGitRepository.stageFileForCommit(libFile) testGitRepository.commit(message = "Modified library $name") } + + private fun initiazeCommandExecutorWithLongProcessWaitTime(): CommandExecutorImpl { + return CommandExecutorImpl(processTimeout = 5, processTimeoutUnit = TimeUnit.MINUTES) + } } diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt index 07aa4d4134c..2109155025f 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/BazelClientTest.kt @@ -25,20 +25,14 @@ import java.util.concurrent.TimeUnit // Function name: test names are conventionally named with underscores. @Suppress("SameParameterValue", "FunctionName") class BazelClientTest { - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() + @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() - @Rule - @JvmField - val mockitoRule: MockitoRule = MockitoJUnit.rule() + @Mock lateinit var mockCommandExecutor: CommandExecutor private val commandExecutor by lazy { initiazeCommandExecutorWithLongProcessWaitTime() } private lateinit var testBazelWorkspace: TestBazelWorkspace - @Mock - lateinit var mockCommandExecutor: CommandExecutor - @Before fun setUp() { testBazelWorkspace = TestBazelWorkspace(tempFolder) @@ -46,7 +40,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_emptyFolder_fails() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) val exception = assertThrows() { bazelClient.retrieveAllTestTargets() @@ -59,7 +53,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_emptyWorkspace_fails() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() val exception = assertThrows() { @@ -73,7 +67,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_workspaceWithTest_returnsTestTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("ExampleTest") @@ -84,7 +78,7 @@ class BazelClientTest { @Test fun testRetrieveTestTargets_workspaceWithMultipleTests_returnsTestTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest") @@ -106,7 +100,7 @@ class BazelClientTest { @Test fun testRetrieveBazelTargets_forFileNotInBuildGraph_returnsEmptyList() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() tempFolder.newFile("filenotingraph") @@ -117,7 +111,7 @@ class BazelClientTest { @Test fun testRetrieveBazelTargets_forTestFile_returnsBazelTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") @@ -128,7 +122,7 @@ class BazelClientTest { @Test fun testRetrieveBazelTargets_forMultipleMixedFiles_returnsBazelTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest", withGeneratedDependency = true) @@ -157,7 +151,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forTargetWithNoTestDependency_returnsNoTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary("SomeDependency") testBazelWorkspace.createTest("FirstTest") @@ -170,7 +164,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forTestFileTarget_returnsTestTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") @@ -181,7 +175,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forDependentFileTarget_returnsTestTarget() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest", withGeneratedDependency = true) @@ -192,7 +186,7 @@ class BazelClientTest { @Test fun testRetrieveRelatedTestTargets_forMixedFileTargets_returnsRelatedTestTargets() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary("ExtraDep") testBazelWorkspace.createTest("FirstTest", withExtraDependency = "//:ExtraDep_lib") @@ -227,7 +221,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forNoFiles_returnsEmptyList() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() val testTargets = bazelClient.retrieveTransitiveTestTargets(listOf()) @@ -238,7 +232,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forBuildFile_returnsAllTestsInThatBuildFile() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest") @@ -253,7 +247,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forMultipleBuildFiles_returnsAllRelatedTests() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest", subpackage = "two") @@ -269,7 +263,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forBzlFile_returnsRelatedTests() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() // Generate tests. testBazelWorkspace.createTest("FirstTest") @@ -298,7 +292,7 @@ class BazelClientTest { @Test fun testRetrieveTransitiveTestTargets_forWorkspace_returnsAllTests() { - val bazelClient = BazelClient(tempFolder.root) + val bazelClient = BazelClient(tempFolder.root, commandExecutor) testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest("FirstTest") testBazelWorkspace.createTest("SecondTest", subpackage = "two") diff --git a/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel index 707ec3e8081..e4499086079 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel @@ -18,6 +18,7 @@ kt_jvm_test( kt_jvm_test( name = "MavenDependenciesListCheckTest", size = "large", + shard_count = 4, srcs = ["MavenDependenciesListCheckTest.kt"], deps = [ "//scripts/src/java/org/oppia/android/scripts/license:maven_dependencies_list_check_lib", diff --git a/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel index a46ee7ad500..da5af646bc2 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel @@ -8,6 +8,7 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_test") kt_jvm_test( name = "GenerateMavenDependenciesListTest", size = "large", + shard_count = 4, srcs = ["GenerateMavenDependenciesListTest.kt"], deps = [ "//scripts/src/java/org/oppia/android/scripts/common:command_executor", From 0b55bd47439ac9b55e942916c838a0919cd60706 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 19 Jan 2024 21:55:36 +0000 Subject: [PATCH 08/21] Post-merge fixes. Plus, actually makes use of the new script background dispatcher in CommandExecutorImpl to make the new wiring make more sense (though its real utility will come in a follow-up PR). --- .../oppia/android/scripts/ci/ComputeAffectedTests.kt | 4 +--- .../android/scripts/common/CommandExecutorImpl.kt | 10 +++++++--- .../scripts/license/MavenDependenciesRetriever.kt | 1 - .../android/scripts/ci/ComputeAffectedTestsTest.kt | 2 +- .../org/oppia/android/scripts/license/BUILD.bazel | 2 +- .../org/oppia/android/scripts/maven/BUILD.bazel | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt b/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt index 07d960cb4bd..ec82cb18e8b 100644 --- a/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt +++ b/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt @@ -5,13 +5,11 @@ import org.oppia.android.scripts.common.CommandExecutor import org.oppia.android.scripts.common.CommandExecutorImpl import org.oppia.android.scripts.common.GitClient import org.oppia.android.scripts.common.ProtoStringEncoder.Companion.toCompressedBase64 +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher import org.oppia.android.scripts.proto.AffectedTestsBucket import java.io.File import java.util.Locale import kotlin.system.exitProcess -import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher -import org.oppia.android.scripts.common.CommandExecutor -import org.oppia.android.scripts.common.CommandExecutorImpl private const val COMPUTE_ALL_TESTS_PREFIX = "compute_all_tests=" private const val MAX_TEST_COUNT_PER_LARGE_SHARD = 50 diff --git a/scripts/src/java/org/oppia/android/scripts/common/CommandExecutorImpl.kt b/scripts/src/java/org/oppia/android/scripts/common/CommandExecutorImpl.kt index 35c56d0988f..8431c534496 100644 --- a/scripts/src/java/org/oppia/android/scripts/common/CommandExecutorImpl.kt +++ b/scripts/src/java/org/oppia/android/scripts/common/CommandExecutorImpl.kt @@ -1,10 +1,10 @@ package org.oppia.android.scripts.common -import java.io.File -import java.util.concurrent.TimeUnit import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking +import java.io.File +import java.util.concurrent.TimeUnit /** * The default amount of time that should be waited before considering a process as 'hung', in @@ -33,7 +33,11 @@ class CommandExecutorImpl( .directory(workingDir) .redirectErrorStream(includeErrorOutput) .start() - val finished = process.waitFor(processTimeout, processTimeoutUnit) + val finished = runBlocking { + CoroutineScope(scriptBgDispatcher).async { + process.waitFor(processTimeout, processTimeoutUnit) + }.await() + } check(finished) { "Process did not finish within the expected timeout" } return CommandResult( process.exitValue(), diff --git a/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesRetriever.kt b/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesRetriever.kt index 4eeec0be8df..e37c188bac5 100644 --- a/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesRetriever.kt +++ b/scripts/src/java/org/oppia/android/scripts/license/MavenDependenciesRetriever.kt @@ -5,7 +5,6 @@ import com.squareup.moshi.Moshi import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory import org.oppia.android.scripts.common.BazelClient import org.oppia.android.scripts.common.CommandExecutor -import org.oppia.android.scripts.common.CommandExecutorImpl import org.oppia.android.scripts.maven.model.MavenListDependency import org.oppia.android.scripts.maven.model.MavenListDependencyTree import org.oppia.android.scripts.proto.License diff --git a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt index e7b9832d114..4d8542e1e5b 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/ci/ComputeAffectedTestsTest.kt @@ -9,6 +9,7 @@ import org.junit.rules.TemporaryFolder import org.oppia.android.scripts.common.CommandExecutor import org.oppia.android.scripts.common.CommandExecutorImpl import org.oppia.android.scripts.common.ProtoStringEncoder.Companion.mergeFromCompressedBase64 +import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher import org.oppia.android.scripts.proto.AffectedTestsBucket import org.oppia.android.scripts.testing.TestBazelWorkspace import org.oppia.android.scripts.testing.TestGitRepository @@ -17,7 +18,6 @@ import java.io.ByteArrayOutputStream import java.io.File import java.io.OutputStream import java.io.PrintStream -import org.oppia.android.scripts.common.ScriptBackgroundCoroutineDispatcher import java.util.concurrent.TimeUnit /** diff --git a/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel index e4499086079..ab6b739a3b8 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel @@ -18,8 +18,8 @@ kt_jvm_test( kt_jvm_test( name = "MavenDependenciesListCheckTest", size = "large", - shard_count = 4, srcs = ["MavenDependenciesListCheckTest.kt"], + shard_count = 4, deps = [ "//scripts/src/java/org/oppia/android/scripts/license:maven_dependencies_list_check_lib", "//scripts/src/java/org/oppia/android/scripts/testing:test_bazel_workspace", diff --git a/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel index da5af646bc2..68b0d6fad28 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel @@ -8,8 +8,8 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_test") kt_jvm_test( name = "GenerateMavenDependenciesListTest", size = "large", - shard_count = 4, srcs = ["GenerateMavenDependenciesListTest.kt"], + shard_count = 4, deps = [ "//scripts/src/java/org/oppia/android/scripts/common:command_executor", "//scripts/src/java/org/oppia/android/scripts/maven:generate_maven_dependencies_list_lib", From bd97611f1d54f956bede86fa0379da726c9e3542 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Sat, 20 Jan 2024 01:39:52 +0000 Subject: [PATCH 09/21] Fix BUILD file lint issue. --- .../src/javatests/org/oppia/android/scripts/license/BUILD.bazel | 2 +- .../src/javatests/org/oppia/android/scripts/maven/BUILD.bazel | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel index e4499086079..ab6b739a3b8 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/license/BUILD.bazel @@ -18,8 +18,8 @@ kt_jvm_test( kt_jvm_test( name = "MavenDependenciesListCheckTest", size = "large", - shard_count = 4, srcs = ["MavenDependenciesListCheckTest.kt"], + shard_count = 4, deps = [ "//scripts/src/java/org/oppia/android/scripts/license:maven_dependencies_list_check_lib", "//scripts/src/java/org/oppia/android/scripts/testing:test_bazel_workspace", diff --git a/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel b/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel index da5af646bc2..68b0d6fad28 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel +++ b/scripts/src/javatests/org/oppia/android/scripts/maven/BUILD.bazel @@ -8,8 +8,8 @@ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_test") kt_jvm_test( name = "GenerateMavenDependenciesListTest", size = "large", - shard_count = 4, srcs = ["GenerateMavenDependenciesListTest.kt"], + shard_count = 4, deps = [ "//scripts/src/java/org/oppia/android/scripts/common:command_executor", "//scripts/src/java/org/oppia/android/scripts/maven:generate_maven_dependencies_list_lib", From 1a666a9ceb1c2f8809a26e564f793a6299053ce5 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Tue, 6 Feb 2024 23:43:51 +0000 Subject: [PATCH 10/21] Post-merge fixes. --- .../android/testing/FakeFirestoreEventLoggerTest.kt | 10 +++++----- .../firebase/DebugFirestoreEventLoggerImplTest.kt | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt b/testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt index 41ce667b82f..b04b5d13890 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt @@ -78,7 +78,7 @@ class FakeFirestoreEventLoggerTest { @Test fun testfakeEventLogger_logNothing_getMostRecent_returnsFailure() { - assertThrows(NoSuchElementException::class) { fakeEventLogger.getMostRecentEvent() } + assertThrows() { fakeEventLogger.getMostRecentEvent() } } @Test @@ -86,7 +86,7 @@ class FakeFirestoreEventLoggerTest { eventLogger.uploadEvent(eventLog1) fakeEventLogger.clearAllEvents() - val eventException = assertThrows(NoSuchElementException::class) { + val eventException = assertThrows() { fakeEventLogger.getMostRecentEvent() } @@ -144,7 +144,7 @@ class FakeFirestoreEventLoggerTest { @Test fun testGetOldestEvent_noEventsLogged_throwsException() { - assertThrows(NoSuchElementException::class) { fakeEventLogger.getOldestEvent() } + assertThrows() { fakeEventLogger.getOldestEvent() } } @Test @@ -172,7 +172,7 @@ class FakeFirestoreEventLoggerTest { eventLogger.uploadEvent(eventLog1) fakeEventLogger.clearAllEvents() - assertThrows(NoSuchElementException::class) { fakeEventLogger.getOldestEvent() } + assertThrows() { fakeEventLogger.getOldestEvent() } } @Test @@ -237,7 +237,7 @@ class FakeFirestoreEventLoggerTest { eventLogger.uploadEvent(eventLog2) eventLogger.uploadEvent(eventLog1) - assertThrows(IllegalArgumentException::class) { + assertThrows() { fakeEventLogger.getMostRecentEvents(count = -1) } } diff --git a/utility/src/test/java/org/oppia/android/util/logging/firebase/DebugFirestoreEventLoggerImplTest.kt b/utility/src/test/java/org/oppia/android/util/logging/firebase/DebugFirestoreEventLoggerImplTest.kt index 011eb532a09..32d83a0d91c 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/firebase/DebugFirestoreEventLoggerImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/firebase/DebugFirestoreEventLoggerImplTest.kt @@ -79,7 +79,7 @@ class DebugFirestoreEventLoggerImplTest { @Test fun testDebugFirestoreEventLogger_logNothing_getMostRecent_returnsFailure() { - assertThrows(NoSuchElementException::class) { debugFirestoreLoggerImpl.getMostRecentEvent() } + assertThrows() { debugFirestoreLoggerImpl.getMostRecentEvent() } } @Test @@ -87,7 +87,7 @@ class DebugFirestoreEventLoggerImplTest { eventLogger.uploadEvent(eventLog1) debugFirestoreLoggerImpl.clearAllEvents() - val eventException = assertThrows(NoSuchElementException::class) { + val eventException = assertThrows() { debugFirestoreLoggerImpl.getMostRecentEvent() } From a2ee5d31d47ed2392847bf0298d22c41bd829dde Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 7 Feb 2024 21:50:42 +0000 Subject: [PATCH 11/21] Add smoke tests for instr. binaries & tests. --- instrumentation/BUILD.bazel | 7 +++++++ instrumentation/oppia_instrumentation_test.bzl | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/instrumentation/BUILD.bazel b/instrumentation/BUILD.bazel index 03c56337516..eeb4f436d50 100644 --- a/instrumentation/BUILD.bazel +++ b/instrumentation/BUILD.bazel @@ -8,6 +8,8 @@ Note that: exports_files(["src/javatests/AndroidManifest.xml"]) +load("@bazel_skylib//rules:build_test.bzl", "build_test") + # Used for end-to-end tests android_binary( name = "oppia_test", @@ -29,3 +31,8 @@ android_binary( "//instrumentation/src/java/org/oppia/android/instrumentation/application:oppia_test_application", ], ) + +build_test( + name = "oppia_test_binary_smoke_test", + targets = [":oppia_test"], +) diff --git a/instrumentation/oppia_instrumentation_test.bzl b/instrumentation/oppia_instrumentation_test.bzl index 63d8413cd2c..7196865c93c 100644 --- a/instrumentation/oppia_instrumentation_test.bzl +++ b/instrumentation/oppia_instrumentation_test.bzl @@ -3,6 +3,7 @@ Instrumentation macros to define up end-to-end tests. """ load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") +load("@bazel_skylib//rules:build_test.bzl", "build_test") def oppia_instrumentation_test( name, @@ -39,3 +40,8 @@ def oppia_instrumentation_test( test_app = ":%sBinary" % name, tags = ["manual"], ) + + build_test( + name = "%s_smoke_test" % name, + targets = [name, "%sBinary" % name], + ) From d5b90128f7bb1eb5f1dc5e6de02b3b01d2c02751 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 7 Feb 2024 21:53:36 +0000 Subject: [PATCH 12/21] Some minor refactoring for readability. --- instrumentation/oppia_instrumentation_test.bzl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/instrumentation/oppia_instrumentation_test.bzl b/instrumentation/oppia_instrumentation_test.bzl index 7196865c93c..8a3f74b64ce 100644 --- a/instrumentation/oppia_instrumentation_test.bzl +++ b/instrumentation/oppia_instrumentation_test.bzl @@ -17,31 +17,34 @@ def oppia_instrumentation_test( srcs: list of str. List of test files corresponding to this test suite. deps: list of str. The list of dependencies needed to build and run the test. """ + test_lib_name = "%s_lib" % name + test_binary_name = "%sBinary" % name + kt_android_library( - name = "%s_lib" % name, + name = test_lib_name, testonly = True, srcs = srcs, deps = deps, ) native.android_binary( - name = "%sBinary" % name, + name = test_binary_name, testonly = True, custom_package = "org.oppia.android", instruments = "//instrumentation:oppia_test", manifest = "//instrumentation:src/javatests/AndroidManifest.xml", - deps = [":%s_lib" % name], + deps = [test_lib_name], ) # TODO(#3617): Target isn't supported yet. Remove the manual tag once fixed. native.android_instrumentation_test( name = name, target_device = "@android_test_support//tools/android/emulated_devices/generic_phone:android_23_x86_qemu2", - test_app = ":%sBinary" % name, + test_app = test_binary_name, tags = ["manual"], ) build_test( name = "%s_smoke_test" % name, - targets = [name, "%sBinary" % name], + targets = [name, test_binary_name], ) From e6ec869dccfc7fdddd431585e8344e61bbd53467 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 7 Feb 2024 22:48:22 +0000 Subject: [PATCH 13/21] Fixed broken instrumentation builds. This was done by removing the //testing dependency and, instead, having instrumentation targets depend on the direct module within //testing that they need to build. This module & its corresponding implementation binding (and tests) needed to be moved out of //testing and into their own /firebase package. --- .../AdministratorControlsActivityTest.kt | 2 +- .../AdministratorControlsFragmentTest.kt | 2 +- .../AppVersionActivityTest.kt | 2 +- .../ProfileAndDeviceIdActivityTest.kt | 2 +- .../ProfileAndDeviceIdFragmentTest.kt | 2 +- .../CompletedStoryListActivityTest.kt | 2 +- .../LessonThumbnailImageViewTest.kt | 2 +- .../MathExpressionInteractionsViewTest.kt | 2 +- .../AppCompatCheckBoxBindingAdaptersTest.kt | 2 +- .../CircularProgressIndicatorAdaptersTest.kt | 2 +- .../DrawableBindingAdaptersTest.kt | 2 +- .../ImageViewBindingAdaptersTest.kt | 2 +- .../databinding/MarginBindingAdaptersTest.kt | 2 +- ...StateAssemblerMarginBindingAdaptersTest.kt | 2 +- ...tateAssemblerPaddingBindingAdaptersTest.kt | 2 +- .../TextViewBindingAdaptersTest.kt | 2 +- .../databinding/ViewBindingAdaptersTest.kt | 2 +- .../DeveloperOptionsActivityTest.kt | 2 +- .../DeveloperOptionsFragmentTest.kt | 2 +- .../MarkChaptersCompletedActivityTest.kt | 2 +- .../MarkChaptersCompletedFragmentTest.kt | 2 +- .../MarkStoriesCompletedActivityTest.kt | 2 +- .../MarkStoriesCompletedFragmentTest.kt | 2 +- .../MarkTopicsCompletedActivityTest.kt | 2 +- .../MarkTopicsCompletedFragmentTest.kt | 2 +- .../devoptions/ViewEventLogsActivityTest.kt | 2 +- .../devoptions/ViewEventLogsFragmentTest.kt | 2 +- .../ForceNetworkTypeActivityTest.kt | 2 +- .../ForceNetworkTypeFragmentTest.kt | 2 +- .../MathExpressionParserActivityTest.kt | 2 +- .../MathExpressionParserFragmentTest.kt | 2 +- .../android/app/faq/FAQListFragmentTest.kt | 2 +- .../android/app/faq/FAQSingleActivityTest.kt | 2 +- .../android/app/faq/FaqListActivityTest.kt | 2 +- .../android/app/help/HelpActivityTest.kt | 2 +- .../android/app/help/HelpFragmentTest.kt | 2 +- .../android/app/home/HomeActivityTest.kt | 2 +- .../app/home/RecentlyPlayedFragmentTest.kt | 2 +- .../app/home/TopicSummaryViewModelTest.kt | 2 +- .../android/app/home/WelcomeViewModelTest.kt | 2 +- .../PromotedStoryListViewModelTest.kt | 2 +- .../PromotedStoryViewModelTest.kt | 2 +- .../mydownloads/MyDownloadsActivityTest.kt | 2 +- .../mydownloads/MyDownloadsFragmentTest.kt | 2 +- .../notice/BetaNoticeDialogFragmentTest.kt | 2 +- ...dAppDeprecationNoticeDialogFragmentTest.kt | 2 +- ...labilityUpgradeNoticeDialogFragmentTest.kt | 2 +- ...lAppDeprecationNoticeDialogFragmentTest.kt | 2 +- .../OsDeprecationNoticeDialogFragmentTest.kt | 2 +- .../app/onboarding/OnboardingActivityTest.kt | 2 +- .../app/onboarding/OnboardingFragmentTest.kt | 2 +- .../OngoingTopicListActivityTest.kt | 2 +- .../app/options/AppLanguageActivityTest.kt | 2 +- .../app/options/AppLanguageFragmentTest.kt | 2 +- .../app/options/AudioLanguageActivityTest.kt | 2 +- .../app/options/AudioLanguageFragmentTest.kt | 2 +- .../app/options/OptionsActivityTest.kt | 2 +- .../app/options/OptionsFragmentTest.kt | 2 +- .../options/ReadingTextSizeActivityTest.kt | 2 +- .../options/ReadingTextSizeFragmentTest.kt | 2 +- .../android/app/parser/HtmlParserTest.kt | 2 +- .../app/player/audio/AudioFragmentTest.kt | 2 +- .../exploration/BottomSheetOptionsMenuTest.kt | 2 +- .../exploration/ExplorationActivityTest.kt | 2 +- .../app/player/state/StateFragmentTest.kt | 2 +- .../app/policies/PoliciesActivityTest.kt | 2 +- .../app/policies/PoliciesFragmentTest.kt | 2 +- .../app/profile/AddProfileActivityTest.kt | 2 +- .../app/profile/AdminAuthActivityTest.kt | 2 +- .../app/profile/AdminPinActivityTest.kt | 2 +- .../app/profile/PinPasswordActivityTest.kt | 2 +- .../app/profile/ProfileChooserActivityTest.kt | 2 +- .../app/profile/ProfileChooserFragmentTest.kt | 2 +- .../ProfilePictureActivityTest.kt | 2 +- .../ProfileProgressActivityTest.kt | 2 +- .../ProfileProgressFragmentTest.kt | 2 +- .../app/recyclerview/BindableAdapterTest.kt | 2 +- .../resumelesson/ResumeLessonActivityTest.kt | 2 +- .../resumelesson/ResumeLessonFragmentTest.kt | 2 +- .../profile/ProfileEditActivityTest.kt | 2 +- .../profile/ProfileEditFragmentTest.kt | 2 +- .../profile/ProfileListActivityTest.kt | 2 +- .../profile/ProfileListFragmentTest.kt | 2 +- .../profile/ProfileRenameActivityTest.kt | 2 +- .../profile/ProfileRenameFragmentTest.kt | 2 +- .../profile/ProfileResetPinActivityTest.kt | 2 +- .../profile/ProfileResetPinFragmentTest.kt | 2 +- .../android/app/splash/SplashActivityTest.kt | 2 +- .../app/spotlight/SpotlightFragmentTest.kt | 2 +- .../android/app/story/StoryActivityTest.kt | 2 +- .../android/app/story/StoryFragmentTest.kt | 2 +- .../android/app/survey/SurveyActivityTest.kt | 2 +- .../android/app/survey/SurveyFragmentTest.kt | 2 +- .../app/testing/DragDropTestActivityTest.kt | 2 +- ...ionInputInteractionViewTestActivityTest.kt | 2 +- ...ImageRegionSelectionInteractionViewTest.kt | 2 +- .../InputInteractionViewTestActivityTest.kt | 2 +- .../NavigationDrawerActivityDebugTest.kt | 2 +- .../NavigationDrawerActivityProdTest.kt | 2 +- ...tioInputInteractionViewTestActivityTest.kt | 2 +- ...tFontScaleConfigurationUtilActivityTest.kt | 2 +- .../testing/TopicTestActivityForStoryTest.kt | 2 +- .../app/thirdparty/LicenseListActivityTest.kt | 2 +- .../app/thirdparty/LicenseListFragmentTest.kt | 2 +- .../LicenseTextViewerActivityTest.kt | 2 +- .../LicenseTextViewerFragmentTest.kt | 2 +- .../ThirdPartyDependencyListActivityTest.kt | 2 +- .../ThirdPartyDependencyListFragmentTest.kt | 2 +- .../android/app/topic/TopicActivityTest.kt | 2 +- .../android/app/topic/TopicFragmentTest.kt | 2 +- .../conceptcard/ConceptCardFragmentTest.kt | 2 +- .../app/topic/info/TopicInfoFragmentTest.kt | 2 +- .../topic/lessons/TopicLessonsFragmentTest.kt | 2 +- .../practice/TopicPracticeFragmentTest.kt | 2 +- .../QuestionPlayerActivityTest.kt | 2 +- .../revision/TopicRevisionFragmentTest.kt | 2 +- .../revisioncard/RevisionCardActivityTest.kt | 2 +- .../revisioncard/RevisionCardFragmentTest.kt | 2 +- .../app/utility/RatioExtensionsTest.kt | 2 +- .../walkthrough/WalkthroughActivityTest.kt | 2 +- .../WalkthroughFinalFragmentTest.kt | 2 +- .../WalkthroughTopicListFragmentTest.kt | 2 +- .../WalkthroughWelcomeFragmentTest.kt | 2 +- .../activity/ActivityIntentFactoriesTest.kt | 2 +- .../route/ActivityRouterModuleTest.kt | 2 +- .../app/activity/route/ActivityRouterTest.kt | 2 +- .../android/app/home/HomeActivityLocalTest.kt | 2 +- .../app/parser/FractionParsingUiErrorTest.kt | 2 +- .../parser/ListItemLeadingMarginSpanTest.kt | 2 +- .../app/parser/StringToRatioParserTest.kt | 2 +- .../ExplorationActivityLocalTest.kt | 2 +- .../player/state/StateFragmentLocalTest.kt | 2 +- .../ProfileChooserFragmentLocalTest.kt | 2 +- .../app/story/StoryActivityLocalTest.kt | 2 +- .../app/testing/CompletedStoryListSpanTest.kt | 2 +- .../oppia/android/app/testing/HomeSpanTest.kt | 2 +- .../app/testing/OngoingTopicListSpanTest.kt | 2 +- .../PlatformParameterIntegrationTest.kt | 2 +- .../app/testing/ProfileChooserSpanTest.kt | 2 +- .../testing/ProfileProgressSpanCountTest.kt | 2 +- .../app/testing/RecentlyPlayedSpanTest.kt | 2 +- .../app/testing/TopicRevisionSpanTest.kt | 2 +- .../app/testing/activity/TestActivityTest.kt | 2 +- .../AdministratorControlsFragmentTest.kt | 2 +- .../testing/options/OptionsFragmentTest.kt | 2 +- .../player/split/PlayerSplitScreenTest.kt | 2 +- .../state/StateFragmentAccessibilityTest.kt | 2 +- .../topic/info/TopicInfoFragmentLocalTest.kt | 2 +- .../lessons/TopicLessonsFragmentLocalTest.kt | 2 +- .../QuestionPlayerActivityLocalTest.kt | 2 +- .../RevisionCardActivityLocalTest.kt | 2 +- .../ActivityLanguageLocaleHandlerTest.kt | 2 +- .../AppLanguageResourceHandlerTest.kt | 2 +- .../AppLanguageWatcherMixinTest.kt | 2 +- .../app/utility/datetime/DateTimeUtilTest.kt | 2 +- .../MathExpressionAccessibilityUtilTest.kt | 2 +- .../domain/audio/AudioPlayerControllerTest.kt | 2 +- .../auth/AuthenticationControllerTest.kt | 4 +- .../ExplorationDataControllerTest.kt | 2 +- .../ExplorationProgressControllerTest.kt | 2 +- .../ExplorationCheckpointControllerTest.kt | 2 +- .../analytics/FirestoreDataControllerTest.kt | 2 +- .../analytics/LearnerAnalyticsLoggerTest.kt | 2 +- .../analytics/SurveyEventsLoggerTest.kt | 2 +- .../LogReportWorkManagerInitializerTest.kt | 2 +- .../loguploader/LogUploadWorkerTest.kt | 2 +- .../domain/survey/SurveyControllerTest.kt | 2 +- .../survey/SurveyProgressControllerTest.kt | 2 +- instrumentation/BUILD.bazel | 4 +- .../oppia_instrumentation_test.bzl | 2 +- .../instrumentation/application/BUILD.bazel | 2 +- .../application/TestApplicationComponent.kt | 2 +- testing/BUILD.bazel | 1 + .../android/testing/firebase/BUILD.bazel | 22 +++++++++ .../FakeFirebaseAuthWrapperImpl.kt | 2 +- .../TestAuthenticationModule.kt | 2 +- .../android/testing/firebase/BUILD.bazel | 48 +++++++++++++++++++ .../FakeFirebaseAuthWrapperImplTest.kt | 5 +- .../TestAuthenticationModuleTest.kt | 2 +- ...alizeDefaultLocaleRuleCustomContextTest.kt | 2 +- ...InitializeDefaultLocaleRuleOmissionTest.kt | 2 +- .../junit/InitializeDefaultLocaleRuleTest.kt | 2 +- 182 files changed, 254 insertions(+), 182 deletions(-) create mode 100644 testing/src/main/java/org/oppia/android/testing/firebase/BUILD.bazel rename testing/src/main/java/org/oppia/android/testing/{ => firebase}/FakeFirebaseAuthWrapperImpl.kt (97%) rename testing/src/main/java/org/oppia/android/testing/{ => firebase}/TestAuthenticationModule.kt (90%) create mode 100644 testing/src/test/java/org/oppia/android/testing/firebase/BUILD.bazel rename testing/src/test/java/org/oppia/android/testing/{ => firebase}/FakeFirebaseAuthWrapperImplTest.kt (95%) rename testing/src/test/java/org/oppia/android/testing/{ => firebase}/TestAuthenticationModuleTest.kt (98%) diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt index 7d0dbf96afc..4a340d416ca 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsActivityTest.kt @@ -103,8 +103,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentTest.kt index ff5cba27e23..b50d9c099f2 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AdministratorControlsFragmentTest.kt @@ -91,8 +91,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt index cbe287cfaa9..82bc4bd09d3 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/AppVersionActivityTest.kt @@ -81,8 +81,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivityTest.kt index 2710157c685..4a76dfd4479 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdActivityTest.kt @@ -72,8 +72,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index 9bd43e39012..925535d3433 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -101,8 +101,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.logging.TestSyncStatusManager diff --git a/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt index 17f0c3d6f73..60c1d8e03c9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/completedstorylist/CompletedStoryListActivityTest.kt @@ -84,8 +84,8 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/customview/LessonThumbnailImageViewTest.kt b/app/src/sharedTest/java/org/oppia/android/app/customview/LessonThumbnailImageViewTest.kt index 29a4743fe20..7eb357dd46a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/customview/LessonThumbnailImageViewTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/customview/LessonThumbnailImageViewTest.kt @@ -64,9 +64,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt b/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt index 768ba9a67a0..2b8ea2dc02d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt @@ -78,9 +78,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/AppCompatCheckBoxBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/AppCompatCheckBoxBindingAdaptersTest.kt index 7ea576a3ebb..ade4a20211d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/AppCompatCheckBoxBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/AppCompatCheckBoxBindingAdaptersTest.kt @@ -65,9 +65,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/CircularProgressIndicatorAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/CircularProgressIndicatorAdaptersTest.kt index c84c6fc96b2..426294f59cf 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/CircularProgressIndicatorAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/CircularProgressIndicatorAdaptersTest.kt @@ -68,10 +68,10 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/DrawableBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/DrawableBindingAdaptersTest.kt index 5a81aa9f654..9817db99f6a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/DrawableBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/DrawableBindingAdaptersTest.kt @@ -69,9 +69,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/ImageViewBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/ImageViewBindingAdaptersTest.kt index 72f19842249..d5690443bad 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/ImageViewBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/ImageViewBindingAdaptersTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/MarginBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/MarginBindingAdaptersTest.kt index 7bdc00ef976..b720fc78a5d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/MarginBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/MarginBindingAdaptersTest.kt @@ -78,9 +78,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerMarginBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerMarginBindingAdaptersTest.kt index 9e8a843ee06..0e7f32257a7 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerMarginBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerMarginBindingAdaptersTest.kt @@ -77,9 +77,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerPaddingBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerPaddingBindingAdaptersTest.kt index 073add10f38..104b314ef64 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerPaddingBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/StateAssemblerPaddingBindingAdaptersTest.kt @@ -75,9 +75,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/TextViewBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/TextViewBindingAdaptersTest.kt index ca6a286febb..235498e6ef2 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/TextViewBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/TextViewBindingAdaptersTest.kt @@ -67,9 +67,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/databinding/ViewBindingAdaptersTest.kt b/app/src/sharedTest/java/org/oppia/android/app/databinding/ViewBindingAdaptersTest.kt index 9db806e5f0e..716820377d4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/databinding/ViewBindingAdaptersTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/databinding/ViewBindingAdaptersTest.kt @@ -72,9 +72,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt index 55bbad1e323..e2c0034aad8 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsActivityTest.kt @@ -91,8 +91,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt index 8247b045e36..29ea1a94163 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/DeveloperOptionsFragmentTest.kt @@ -86,9 +86,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedActivityTest.kt index 59415795065..0c666f19607 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedActivityTest.kt @@ -77,8 +77,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt index 6125413e6f6..af03c3a086e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkChaptersCompletedFragmentTest.kt @@ -82,9 +82,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.topic.StoryProgressController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedActivityTest.kt index 8d8204d9684..e36a5e93b11 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedActivityTest.kt @@ -68,8 +68,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt index e67d776813a..489691717d9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkStoriesCompletedFragmentTest.kt @@ -77,8 +77,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedActivityTest.kt index 5a575360d80..5e9cfb3fdc4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedActivityTest.kt @@ -68,8 +68,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt index 78214587b28..47e4e0c33a0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/MarkTopicsCompletedFragmentTest.kt @@ -77,8 +77,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsActivityTest.kt index 94dab9dd41d..a3a48b24828 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsActivityTest.kt @@ -69,7 +69,7 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt index 6ec2a227ec1..c42f916f8fa 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/ViewEventLogsFragmentTest.kt @@ -83,7 +83,7 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeFirestoreInstanceWrapperImpl import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeActivityTest.kt index 7bc720e4ae0..c163e91f5e0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeActivityTest.kt @@ -69,8 +69,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeFragmentTest.kt index 25cccdd0bd1..596ce0b7623 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/forcenetworktype/ForceNetworkTypeFragmentTest.kt @@ -73,8 +73,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserActivityTest.kt index 517da7ca48a..c8c71821bc8 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserActivityTest.kt @@ -65,8 +65,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserFragmentTest.kt index cac62ddb6b4..b5d32fa77ee 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/devoptions/mathexpressionparser/MathExpressionParserFragmentTest.kt @@ -74,10 +74,10 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt index 41fefe4329b..48da829d39e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt @@ -79,8 +79,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt index 90d49553c6c..9bfd477a36b 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt @@ -75,8 +75,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/faq/FaqListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/faq/FaqListActivityTest.kt index 680afbdeb44..9b25a1320d4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/faq/FaqListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/faq/FaqListActivityTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt index f00931977eb..f48c81b20ee 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/help/HelpActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt index 73cfb22be58..74fbc2f0e70 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt @@ -93,9 +93,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt index f5e058dfb62..7bcd6a4a196 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/HomeActivityTest.kt @@ -121,10 +121,10 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt index 0aca510567f..e03c49a7ca7 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/RecentlyPlayedFragmentTest.kt @@ -108,9 +108,9 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.lightweightcheckpointing.ExplorationCheckpointTestHelper import org.oppia.android.testing.lightweightcheckpointing.FRACTIONS_STORY_0_EXPLORATION_0_CURRENT_VERSION diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/TopicSummaryViewModelTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/TopicSummaryViewModelTest.kt index 97fc6eb4f8c..19d874cc4a9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/TopicSummaryViewModelTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/TopicSummaryViewModelTest.kt @@ -66,8 +66,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/WelcomeViewModelTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/WelcomeViewModelTest.kt index 9ede16565ca..59ec6348510 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/WelcomeViewModelTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/WelcomeViewModelTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModelTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModelTest.kt index 99cd9dcd48e..5fd5a452779 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModelTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryListViewModelTest.kt @@ -66,8 +66,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryViewModelTest.kt b/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryViewModelTest.kt index ac309882dd1..0ac61cb1caa 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryViewModelTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/home/promotedlist/PromotedStoryViewModelTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsActivityTest.kt index c42a30b0d55..ff6d31f06d7 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsActivityTest.kt @@ -61,8 +61,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt index 2441f617b3d..447b3d33ed1 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt @@ -71,8 +71,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/notice/BetaNoticeDialogFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/notice/BetaNoticeDialogFragmentTest.kt index b98726e61f3..423822f8d19 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/notice/BetaNoticeDialogFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/notice/BetaNoticeDialogFragmentTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/notice/ForcedAppDeprecationNoticeDialogFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/notice/ForcedAppDeprecationNoticeDialogFragmentTest.kt index 675426fe1eb..1af22c3a018 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/notice/ForcedAppDeprecationNoticeDialogFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/notice/ForcedAppDeprecationNoticeDialogFragmentTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/notice/GeneralAvailabilityUpgradeNoticeDialogFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/notice/GeneralAvailabilityUpgradeNoticeDialogFragmentTest.kt index 29c1cde2351..171e62cd76c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/notice/GeneralAvailabilityUpgradeNoticeDialogFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/notice/GeneralAvailabilityUpgradeNoticeDialogFragmentTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/notice/OptionalAppDeprecationNoticeDialogFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/notice/OptionalAppDeprecationNoticeDialogFragmentTest.kt index b981373f23d..db82579e4e9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/notice/OptionalAppDeprecationNoticeDialogFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/notice/OptionalAppDeprecationNoticeDialogFragmentTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/notice/OsDeprecationNoticeDialogFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/notice/OsDeprecationNoticeDialogFragmentTest.kt index 1a522d1242d..51afc4b45e2 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/notice/OsDeprecationNoticeDialogFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/notice/OsDeprecationNoticeDialogFragmentTest.kt @@ -74,9 +74,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingActivityTest.kt index 23704d8ef36..10a388f6f4a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingFragmentTest.kt index e1227d6396f..43dc8c7cef0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/onboarding/OnboardingFragmentTest.kt @@ -88,8 +88,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt index bf37a173a38..d19b037818d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicListActivityTest.kt @@ -82,8 +82,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageActivityTest.kt index 52e8a3cc154..3a2e401d0c5 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageActivityTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageFragmentTest.kt index 07df1432348..cdb12ba202c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/AppLanguageFragmentTest.kt @@ -75,9 +75,9 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageActivityTest.kt index a87d648e98e..52be8c16782 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageActivityTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageFragmentTest.kt index 9511978a74b..c7b5bfe0d86 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/AudioLanguageFragmentTest.kt @@ -74,8 +74,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt index 7aff373149c..dd9d85926e2 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt index da8a49d42a3..8788ead2ab6 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt @@ -90,9 +90,9 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeActivityTest.kt index 6c54efd52c8..ee07540d885 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt index 56933de3067..df07900e97a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/options/ReadingTextSizeFragmentTest.kt @@ -77,8 +77,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt b/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt index a655da4b9e0..571ba12ee85 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt @@ -102,10 +102,10 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.mockito.capture diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt index 173b024aa5f..4f3fb329a19 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/audio/AudioFragmentTest.kt @@ -87,9 +87,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.IsOnRobolectric diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BottomSheetOptionsMenuTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BottomSheetOptionsMenuTest.kt index e390e6eea1a..e378c5285bd 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BottomSheetOptionsMenuTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/BottomSheetOptionsMenuTest.kt @@ -70,9 +70,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt index 6245681585e..800916c4391 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt @@ -130,11 +130,11 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.lightweightcheckpointing.ExplorationCheckpointTestHelper import org.oppia.android.testing.lightweightcheckpointing.FRACTIONS_STORY_0_EXPLORATION_1_CURRENT_VERSION diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt index 0ee896da96d..f295bd9c3e5 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt @@ -151,13 +151,13 @@ import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.lightweightcheckpointing.ExplorationCheckpointTestHelper import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat diff --git a/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesActivityTest.kt index 95dd5e209d2..d8d95d2bab1 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesActivityTest.kt @@ -79,9 +79,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesFragmentTest.kt index 2a318c9324a..07790dc33d8 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/policies/PoliciesFragmentTest.kt @@ -91,9 +91,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/AddProfileActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/AddProfileActivityTest.kt index 175b0a62bf9..34dfb5f3b18 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/AddProfileActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/AddProfileActivityTest.kt @@ -96,12 +96,12 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasHelperText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/AdminAuthActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/AdminAuthActivityTest.kt index cb49cff5daa..cfabe083384 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/AdminAuthActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/AdminAuthActivityTest.kt @@ -82,10 +82,10 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/AdminPinActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/AdminPinActivityTest.kt index ea44c5d0d1c..b6fdce97344 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/AdminPinActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/AdminPinActivityTest.kt @@ -91,11 +91,11 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt index f65a6f5f45a..90c78003600 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/PinPasswordActivityTest.kt @@ -87,11 +87,11 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserActivityTest.kt index 3442c182a7d..74d2f607988 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt index 0418a1339a8..5fff9c4006b 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profile/ProfileChooserFragmentTest.kt @@ -84,8 +84,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfilePictureActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfilePictureActivityTest.kt index 57d8180ed22..deb1c56251e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfilePictureActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfilePictureActivityTest.kt @@ -70,8 +70,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressActivityTest.kt index fc6c676d227..1cad2587804 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt index a4c5187cf25..2f83eb95f5d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/profileprogress/ProfileProgressFragmentTest.kt @@ -108,8 +108,8 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt b/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt index 1d48ecfcf71..c85a4d1c524 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/recyclerview/BindableAdapterTest.kt @@ -98,8 +98,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt index 988cbe99df3..e1e8707c853 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonActivityTest.kt @@ -82,9 +82,9 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt index 7bbc505d9dc..cf138d0d1f3 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/resumelesson/ResumeLessonFragmentTest.kt @@ -84,9 +84,9 @@ import org.oppia.android.domain.topic.RATIOS_STORY_ID_0 import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditActivityTest.kt index ab1aa374f27..1b3a285f095 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditActivityTest.kt @@ -79,8 +79,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt index a6f02aa8d7c..72346233590 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileEditFragmentTest.kt @@ -84,10 +84,10 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListActivityTest.kt index fe93ebd5339..ec65e61024a 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListActivityTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListFragmentTest.kt index 5e571de6a91..d94a0d75a11 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileListFragmentTest.kt @@ -76,8 +76,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameActivityTest.kt index dc8534a913f..8aff6c18532 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameActivityTest.kt @@ -63,9 +63,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentTest.kt index e95194f1de1..77f2aa4d7d0 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileRenameFragmentTest.kt @@ -78,11 +78,11 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinActivityTest.kt index 0a0d8c22316..1e473a5e4a9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinActivityTest.kt @@ -64,9 +64,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentTest.kt index ce23631d2a0..a78db5e7ce2 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/settings/profile/ProfileResetPinFragmentTest.kt @@ -79,11 +79,11 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.TextInputAction.Companion.hasErrorText import org.oppia.android.testing.espresso.TextInputAction.Companion.hasNoErrorText +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt index 2ccef97076a..5fa6d2d41eb 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt @@ -95,10 +95,10 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter diff --git a/app/src/sharedTest/java/org/oppia/android/app/spotlight/SpotlightFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/spotlight/SpotlightFragmentTest.kt index 36f978df8c1..35df5325f0e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/spotlight/SpotlightFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/spotlight/SpotlightFragmentTest.kt @@ -72,9 +72,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt index c4a1776e814..1dda62f55f4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/story/StoryActivityTest.kt @@ -85,9 +85,9 @@ import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt index 1e30882456e..3a9760cec83 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/story/StoryFragmentTest.kt @@ -116,8 +116,8 @@ import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.mockito.anyOrNull import org.oppia.android.testing.mockito.capture diff --git a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt index 4af4459dfef..61ace850d0e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyActivityTest.kt @@ -66,8 +66,8 @@ import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_2 import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt index f1398787462..cf4de9db27c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/survey/SurveyFragmentTest.kt @@ -89,8 +89,8 @@ import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.logging.EventLogSubject import org.oppia.android.testing.platformparameter.TestPlatformParameterModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/DragDropTestActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/DragDropTestActivityTest.kt index 966ada83745..9e7aa64cd7e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/DragDropTestActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/DragDropTestActivityTest.kt @@ -72,8 +72,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/FractionInputInteractionViewTestActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/FractionInputInteractionViewTestActivityTest.kt index 7f5c52581a6..fb4b7a677f4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/FractionInputInteractionViewTestActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/FractionInputInteractionViewTestActivityTest.kt @@ -72,9 +72,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt index 11088d08c32..a2097b83928 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/ImageRegionSelectionInteractionViewTest.kt @@ -83,10 +83,10 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.mockito.capture import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/InputInteractionViewTestActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/InputInteractionViewTestActivityTest.kt index 9041d7fa64d..2ce962ee356 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/InputInteractionViewTestActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/InputInteractionViewTestActivityTest.kt @@ -72,9 +72,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt index 0fac18cd543..6ede2fb1889 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityDebugTest.kt @@ -99,9 +99,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt index 9ec9f47ee79..2ac71b84993 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityProdTest.kt @@ -107,9 +107,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/RatioInputInteractionViewTestActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/RatioInputInteractionViewTestActivityTest.kt index 57b3c1b0604..3968ee5bda7 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/RatioInputInteractionViewTestActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/RatioInputInteractionViewTestActivityTest.kt @@ -79,9 +79,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/TestFontScaleConfigurationUtilActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/TestFontScaleConfigurationUtilActivityTest.kt index 5815a6f0971..906d24f97a1 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/TestFontScaleConfigurationUtilActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/TestFontScaleConfigurationUtilActivityTest.kt @@ -67,8 +67,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/testing/TopicTestActivityForStoryTest.kt b/app/src/sharedTest/java/org/oppia/android/app/testing/TopicTestActivityForStoryTest.kt index 03c8b40c315..f59711ead38 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/testing/TopicTestActivityForStoryTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/testing/TopicTestActivityForStoryTest.kt @@ -71,8 +71,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListActivityTest.kt index cc6d13cc284..b73ce7a0773 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListActivityTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListFragmentTest.kt index b50e60a6cfa..a8dd3ae36fd 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseListFragmentTest.kt @@ -78,8 +78,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerActivityTest.kt index e1545f34c32..fb424fd2440 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerActivityTest.kt @@ -71,8 +71,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerFragmentTest.kt index 03d9b1c666a..07bb62e85c9 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/LicenseTextViewerFragmentTest.kt @@ -68,8 +68,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListActivityTest.kt index da5a3be066d..0a2fd1f4fa4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListActivityTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListFragmentTest.kt index 7691445e8a2..419fa4515ef 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/thirdparty/ThirdPartyDependencyListFragmentTest.kt @@ -77,8 +77,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt index 8cf06d4dfb4..a82efa5f8cb 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicActivityTest.kt @@ -82,9 +82,9 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt index 0b42029e742..875d5936cb5 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/TopicFragmentTest.kt @@ -94,8 +94,8 @@ import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.platformparameter.TestPlatformParameterModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt index 846884c529d..ac0c6ab72aa 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/conceptcard/ConceptCardFragmentTest.kt @@ -103,11 +103,11 @@ import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RichTextViewMatcher.Companion.containsRichText import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/info/TopicInfoFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/info/TopicInfoFragmentTest.kt index a8ea6bf7896..9cfb0cd31d6 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/info/TopicInfoFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/info/TopicInfoFragmentTest.kt @@ -88,11 +88,11 @@ import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.espresso.ImageViewMatcher.Companion.hasScaleType +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt index 45abdc11143..ed64716a398 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentTest.kt @@ -110,8 +110,8 @@ import org.oppia.android.domain.topic.RATIOS_STORY_ID_0 import org.oppia.android.domain.topic.RATIOS_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.lightweightcheckpointing.ExplorationCheckpointTestHelper import org.oppia.android.testing.lightweightcheckpointing.FRACTIONS_STORY_0_EXPLORATION_0_CURRENT_VERSION diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt index 3f8b7eae213..c4ec0d84a88 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/practice/TopicPracticeFragmentTest.kt @@ -88,8 +88,8 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt index 9bd58c51e8c..03423d24c83 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityTest.kt @@ -126,11 +126,11 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.espresso.EditTextInputAction +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt index 2daf1860e6b..de936dccb21 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/revision/TopicRevisionFragmentTest.kt @@ -89,10 +89,10 @@ import org.oppia.android.domain.topic.FRACTIONS_TOPIC_ID import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.ImageViewMatcher.Companion.hasScaleType +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt index 278c43c94d8..d570e4ec204 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityTest.kt @@ -82,10 +82,10 @@ import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt index 7422990cea4..5831cc043b5 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/topic/revisioncard/RevisionCardFragmentTest.kt @@ -104,11 +104,11 @@ import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.DisableAccessibilityChecks import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/utility/RatioExtensionsTest.kt b/app/src/sharedTest/java/org/oppia/android/app/utility/RatioExtensionsTest.kt index f8e1dedfdb9..fa2d84e008c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/utility/RatioExtensionsTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/utility/RatioExtensionsTest.kt @@ -60,8 +60,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt index e289674673e..b583e012dc7 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughActivityTest.kt @@ -74,8 +74,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughFinalFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughFinalFragmentTest.kt index 79e0caf8e70..2b6ab7d39bc 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughFinalFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughFinalFragmentTest.kt @@ -76,8 +76,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughTopicListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughTopicListFragmentTest.kt index d90dca2bb15..ee17909aa1d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughTopicListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughTopicListFragmentTest.kt @@ -77,11 +77,11 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.environment.TestEnvironmentConfig import org.oppia.android.testing.espresso.GenericViewMatchers.Companion.withOpaqueBackground +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt index 0634f55de2b..288fa127272 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/walkthrough/WalkthroughWelcomeFragmentTest.kt @@ -72,8 +72,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.OppiaTestRule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt b/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt index 47a343b0316..5d0844289a3 100644 --- a/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt +++ b/app/src/test/java/org/oppia/android/app/activity/ActivityIntentFactoriesTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt index 104ee920e47..d90f9471261 100644 --- a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt +++ b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterModuleTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt index bea5d205bc5..f644125b802 100644 --- a/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt +++ b/app/src/test/java/org/oppia/android/app/activity/route/ActivityRouterTest.kt @@ -74,8 +74,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt index 5c86e2b542c..d9eb01477ec 100644 --- a/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/home/HomeActivityLocalTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/parser/FractionParsingUiErrorTest.kt b/app/src/test/java/org/oppia/android/app/parser/FractionParsingUiErrorTest.kt index 1b5dbb6b44a..d22af58e95b 100644 --- a/app/src/test/java/org/oppia/android/app/parser/FractionParsingUiErrorTest.kt +++ b/app/src/test/java/org/oppia/android/app/parser/FractionParsingUiErrorTest.kt @@ -58,8 +58,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt b/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt index 7aa3bba8f81..d993ffd3de8 100644 --- a/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/parser/ListItemLeadingMarginSpanTest.kt @@ -84,10 +84,10 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.TestPlatform +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt b/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt index 794be78f7bc..acbf5c9fec8 100644 --- a/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt +++ b/app/src/test/java/org/oppia/android/app/parser/StringToRatioParserTest.kt @@ -59,9 +59,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt index 9ba1741236e..edc6c0a91e3 100644 --- a/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/exploration/ExplorationActivityLocalTest.kt @@ -70,8 +70,8 @@ import org.oppia.android.domain.topic.TEST_STORY_ID_0 import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt index 1d278a6a9da..c5442bff54e 100644 --- a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt @@ -138,7 +138,6 @@ import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.BuildEnvironment import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestImageLoaderModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor @@ -146,6 +145,7 @@ import org.oppia.android.testing.environment.TestEnvironmentConfig import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.KonfettiViewMatcher.Companion.hasActiveConfetti import org.oppia.android.testing.espresso.KonfettiViewMatcher.Companion.hasExpectedNumberOfActiveSystems +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule diff --git a/app/src/test/java/org/oppia/android/app/profile/ProfileChooserFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/profile/ProfileChooserFragmentLocalTest.kt index 35dd0310c63..9ac373f8edd 100644 --- a/app/src/test/java/org/oppia/android/app/profile/ProfileChooserFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/profile/ProfileChooserFragmentLocalTest.kt @@ -61,8 +61,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/story/StoryActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/story/StoryActivityLocalTest.kt index ee383f8ec5b..2b60ef54096 100644 --- a/app/src/test/java/org/oppia/android/app/story/StoryActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/story/StoryActivityLocalTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/testing/CompletedStoryListSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/CompletedStoryListSpanTest.kt index 5ecdfdcf3cc..b837db394bf 100644 --- a/app/src/test/java/org/oppia/android/app/testing/CompletedStoryListSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/CompletedStoryListSpanTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt index 7ef9b806b93..1ed839774da 100644 --- a/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/HomeSpanTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/OngoingTopicListSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/OngoingTopicListSpanTest.kt index b38e93506fd..6f4ecf14c9a 100644 --- a/app/src/test/java/org/oppia/android/app/testing/OngoingTopicListSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/OngoingTopicListSpanTest.kt @@ -65,8 +65,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/PlatformParameterIntegrationTest.kt b/app/src/test/java/org/oppia/android/app/testing/PlatformParameterIntegrationTest.kt index 0941c35c37c..68f5e78c518 100644 --- a/app/src/test/java/org/oppia/android/app/testing/PlatformParameterIntegrationTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/PlatformParameterIntegrationTest.kt @@ -81,8 +81,8 @@ import org.oppia.android.domain.platformparameter.syncup.PlatformParameterSyncUp import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.network.MockPlatformParameterService import org.oppia.android.testing.network.RetrofitTestModule diff --git a/app/src/test/java/org/oppia/android/app/testing/ProfileChooserSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/ProfileChooserSpanTest.kt index bfea9b66185..e0f11812c55 100644 --- a/app/src/test/java/org/oppia/android/app/testing/ProfileChooserSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/ProfileChooserSpanTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/testing/ProfileProgressSpanCountTest.kt b/app/src/test/java/org/oppia/android/app/testing/ProfileProgressSpanCountTest.kt index 83608031b85..4dd699158b9 100644 --- a/app/src/test/java/org/oppia/android/app/testing/ProfileProgressSpanCountTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/ProfileProgressSpanCountTest.kt @@ -64,8 +64,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt index fed517d1912..8d05adc7ebf 100644 --- a/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/RecentlyPlayedSpanTest.kt @@ -67,8 +67,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.story.StoryProgressTestHelper diff --git a/app/src/test/java/org/oppia/android/app/testing/TopicRevisionSpanTest.kt b/app/src/test/java/org/oppia/android/app/testing/TopicRevisionSpanTest.kt index 5fe8a3fb3c8..55574573642 100644 --- a/app/src/test/java/org/oppia/android/app/testing/TopicRevisionSpanTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/TopicRevisionSpanTest.kt @@ -63,8 +63,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/activity/TestActivityTest.kt b/app/src/test/java/org/oppia/android/app/testing/activity/TestActivityTest.kt index f23ffd3dd6b..23e0211298b 100644 --- a/app/src/test/java/org/oppia/android/app/testing/activity/TestActivityTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/activity/TestActivityTest.kt @@ -60,8 +60,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt b/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt index e6d2a7f4812..c9d01ffbce5 100644 --- a/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/administratorcontrols/AdministratorControlsFragmentTest.kt @@ -70,8 +70,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt b/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt index bd942c2b0e4..462d087efd6 100644 --- a/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/options/OptionsFragmentTest.kt @@ -66,8 +66,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/test/java/org/oppia/android/app/testing/player/split/PlayerSplitScreenTest.kt b/app/src/test/java/org/oppia/android/app/testing/player/split/PlayerSplitScreenTest.kt index 649ad5306b8..9e3c3edc499 100644 --- a/app/src/test/java/org/oppia/android/app/testing/player/split/PlayerSplitScreenTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/player/split/PlayerSplitScreenTest.kt @@ -61,8 +61,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt b/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt index 7b33b32cad0..fd39ae0660e 100644 --- a/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt +++ b/app/src/test/java/org/oppia/android/app/testing/player/state/StateFragmentAccessibilityTest.kt @@ -70,8 +70,8 @@ import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_4 import org.oppia.android.domain.topic.TEST_STORY_ID_0 import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/topic/info/TopicInfoFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/topic/info/TopicInfoFragmentLocalTest.kt index cda806ffed1..f4e4081e436 100644 --- a/app/src/test/java/org/oppia/android/app/topic/info/TopicInfoFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/topic/info/TopicInfoFragmentLocalTest.kt @@ -60,8 +60,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentLocalTest.kt index b5ef86c5597..d48ad3f170c 100644 --- a/app/src/test/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/topic/lessons/TopicLessonsFragmentLocalTest.kt @@ -60,8 +60,8 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt index b388ade740a..c5cfcca74d3 100644 --- a/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/topic/questionplayer/QuestionPlayerActivityLocalTest.kt @@ -87,10 +87,10 @@ import org.oppia.android.domain.question.WrongAnswerScorePenalty import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.topic.TEST_SKILL_ID_1 import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.espresso.EditTextInputAction import org.oppia.android.testing.espresso.KonfettiViewMatcher.Companion.hasActiveConfetti +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityLocalTest.kt b/app/src/test/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityLocalTest.kt index 42b14d83075..8667a942f21 100644 --- a/app/src/test/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/topic/revisioncard/RevisionCardActivityLocalTest.kt @@ -62,8 +62,8 @@ import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.topic.SUBTOPIC_TOPIC_ID import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/app/src/test/java/org/oppia/android/app/translation/ActivityLanguageLocaleHandlerTest.kt b/app/src/test/java/org/oppia/android/app/translation/ActivityLanguageLocaleHandlerTest.kt index b234a2ae58a..408d7df55fa 100644 --- a/app/src/test/java/org/oppia/android/app/translation/ActivityLanguageLocaleHandlerTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/ActivityLanguageLocaleHandlerTest.kt @@ -73,9 +73,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt b/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt index 9ce6d2ce22c..5689577c68c 100644 --- a/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt @@ -66,10 +66,10 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration diff --git a/app/src/test/java/org/oppia/android/app/translation/AppLanguageWatcherMixinTest.kt b/app/src/test/java/org/oppia/android/app/translation/AppLanguageWatcherMixinTest.kt index 95f05fa2ebb..f3231f3ac7e 100644 --- a/app/src/test/java/org/oppia/android/app/translation/AppLanguageWatcherMixinTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/AppLanguageWatcherMixinTest.kt @@ -71,9 +71,9 @@ import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.translation.TranslationController import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.DefineAppLanguageLocaleContext import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.profile.ProfileTestHelper diff --git a/app/src/test/java/org/oppia/android/app/utility/datetime/DateTimeUtilTest.kt b/app/src/test/java/org/oppia/android/app/utility/datetime/DateTimeUtilTest.kt index 5cd6e77f8cf..ea9a9d89a34 100644 --- a/app/src/test/java/org/oppia/android/app/utility/datetime/DateTimeUtilTest.kt +++ b/app/src/test/java/org/oppia/android/app/utility/datetime/DateTimeUtilTest.kt @@ -61,8 +61,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt b/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt index 64800e1d5e8..97bff878691 100644 --- a/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt +++ b/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt @@ -78,8 +78,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration diff --git a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt index dbf2d829fe1..f7652a7e08b 100644 --- a/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/audio/AudioPlayerControllerTest.kt @@ -53,11 +53,11 @@ import org.oppia.android.domain.profile.ProfileManagementController import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_5 import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.AsyncResultSubject.Companion.assertThat import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt index ca80f6e297d..4208244c46e 100644 --- a/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt @@ -14,10 +14,10 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule -import org.oppia.android.testing.FakeFirebaseAuthWrapperImpl -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows +import org.oppia.android.testing.firebase.FakeFirebaseAuthWrapperImpl +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.time.FakeOppiaClockModule import org.oppia.android.util.data.DataProvidersInjector diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt index 8aab3fe63ad..deee65f9f9a 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationDataControllerTest.kt @@ -50,10 +50,10 @@ import org.oppia.android.domain.topic.TEST_STORY_ID_2 import org.oppia.android.domain.topic.TEST_TOPIC_ID_0 import org.oppia.android.domain.topic.TEST_TOPIC_ID_1 import org.oppia.android.testing.FakeExceptionLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt index f70c336f8bc..af38311d4b5 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/ExplorationProgressControllerTest.kt @@ -83,11 +83,11 @@ import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.OppiaTestRule import org.oppia.android.testing.RunOn -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.EventLogSubject import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.robolectric.RobolectricModule diff --git a/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt index 6256ff55290..bfef2cedd25 100644 --- a/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/exploration/lightweightcheckpointing/ExplorationCheckpointControllerTest.kt @@ -49,10 +49,10 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.topic.FRACTIONS_EXPLORATION_ID_0 import org.oppia.android.domain.topic.FRACTIONS_EXPLORATION_ID_1 -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.environment.TestEnvironmentConfig +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.lightweightcheckpointing.ExplorationCheckpointTestHelper import org.oppia.android.testing.lightweightcheckpointing.FRACTIONS_EXPLORATION_0_TITLE import org.oppia.android.testing.lightweightcheckpointing.FRACTIONS_STORY_0_EXPLORATION_0_CURRENT_VERSION diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt index 02b49b292a9..2de079ee3c0 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/FirestoreDataControllerTest.kt @@ -27,9 +27,9 @@ import org.oppia.android.domain.oppialogger.FirestoreLogStorageCacheSize import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakeFirestoreEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt index 74ab58fe35e..a036c2a304d 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt @@ -43,9 +43,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_2 import org.oppia.android.domain.topic.TEST_EXPLORATION_ID_5 import org.oppia.android.testing.FakeAnalyticsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt index f82ab30c03d..a8962bb0af4 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/SurveyEventsLoggerTest.kt @@ -23,8 +23,8 @@ import org.oppia.android.domain.oppialogger.survey.SurveyEventsLogger import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeFirestoreEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.platformparameter.TestPlatformParameterModule diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogReportWorkManagerInitializerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogReportWorkManagerInitializerTest.kt index 50450041a09..9f9443e1708 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogReportWorkManagerInitializerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogReportWorkManagerInitializerTest.kt @@ -38,8 +38,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterModule import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModule import org.oppia.android.domain.testing.oppialogger.loguploader.FakeLogUploader import org.oppia.android.testing.FakeExceptionLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt index 1b715670f33..6ecf7a83e28 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt @@ -44,8 +44,8 @@ import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.FakeFirestoreEventLogger import org.oppia.android.testing.FakePerformanceMetricsEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.SyncStatusTestModule import org.oppia.android.testing.logging.TestSyncStatusManager import org.oppia.android.testing.mockito.anyOrNull diff --git a/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt index 4517b0b6504..8ea319426f5 100644 --- a/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/survey/SurveyControllerTest.kt @@ -19,9 +19,9 @@ import org.oppia.android.domain.oppialogger.ApplicationIdSeed import org.oppia.android.domain.oppialogger.LogStorageModule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.testing.FakeExceptionLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers import org.oppia.android.testing.threading.TestDispatcherModule diff --git a/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt index e0e8e1deade..ea336df027a 100644 --- a/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/survey/SurveyProgressControllerTest.kt @@ -25,9 +25,9 @@ import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.testing.FakeAnalyticsEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.FakeFirestoreEventLogger -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.data.DataProviderTestMonitor +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.logging.EventLogSubject import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestCoroutineDispatchers diff --git a/instrumentation/BUILD.bazel b/instrumentation/BUILD.bazel index eeb4f436d50..f6ffffcdc8a 100644 --- a/instrumentation/BUILD.bazel +++ b/instrumentation/BUILD.bazel @@ -6,10 +6,10 @@ Note that: of the test suite. """ -exports_files(["src/javatests/AndroidManifest.xml"]) - load("@bazel_skylib//rules:build_test.bzl", "build_test") +exports_files(["src/javatests/AndroidManifest.xml"]) + # Used for end-to-end tests android_binary( name = "oppia_test", diff --git a/instrumentation/oppia_instrumentation_test.bzl b/instrumentation/oppia_instrumentation_test.bzl index 8a3f74b64ce..6319bbf0ba3 100644 --- a/instrumentation/oppia_instrumentation_test.bzl +++ b/instrumentation/oppia_instrumentation_test.bzl @@ -2,8 +2,8 @@ Instrumentation macros to define up end-to-end tests. """ -load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") load("@bazel_skylib//rules:build_test.bzl", "build_test") +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") def oppia_instrumentation_test( name, diff --git a/instrumentation/src/java/org/oppia/android/instrumentation/application/BUILD.bazel b/instrumentation/src/java/org/oppia/android/instrumentation/application/BUILD.bazel index 5d9fe4ac612..5e9c6382d77 100644 --- a/instrumentation/src/java/org/oppia/android/instrumentation/application/BUILD.bazel +++ b/instrumentation/src/java/org/oppia/android/instrumentation/application/BUILD.bazel @@ -25,7 +25,7 @@ kt_android_library( "//app/src/main/java/org/oppia/android/app/application/testing:testing_build_flavor_module", "//data/src/main/java/org/oppia/android/data/backends/gae:network_config_annotations", "//domain", - "//testing", + "//testing/src/main/java/org/oppia/android/testing/firebase:test_authentication_module", "//utility", "//utility/src/main/java/org/oppia/android/util/logging:standard_event_logging_configuration_module", "//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module", diff --git a/instrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt b/instrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt index fbf99ee8103..fe588b21105 100644 --- a/instrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt +++ b/instrumentation/src/java/org/oppia/android/instrumentation/application/TestApplicationComponent.kt @@ -45,7 +45,7 @@ import org.oppia.android.domain.platformparameter.syncup.PlatformParameterSyncUp import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.util.accessibility.AccessibilityProdModule import org.oppia.android.util.caching.AssetModule import org.oppia.android.util.caching.CachingModule diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 9bed8754f08..95a90957cfd 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -40,6 +40,7 @@ kt_android_library( "//model/src/main/proto:performance_metrics_event_logger_java_proto_lite", "//testing/src/main/java/org/oppia/android/testing/data:async_result_subject", "//testing/src/main/java/org/oppia/android/testing/data:data_provider_test_monitor", + "//testing/src/main/java/org/oppia/android/testing/firebase:test_authentication_module", "//testing/src/main/java/org/oppia/android/testing/threading:test_coroutine_dispatchers", "//testing/src/main/java/org/oppia/android/testing/time:fake_oppia_clock", "//third_party:androidx_core_core-ktx", diff --git a/testing/src/main/java/org/oppia/android/testing/firebase/BUILD.bazel b/testing/src/main/java/org/oppia/android/testing/firebase/BUILD.bazel new file mode 100644 index 00000000000..78b9c0ffb82 --- /dev/null +++ b/testing/src/main/java/org/oppia/android/testing/firebase/BUILD.bazel @@ -0,0 +1,22 @@ +""" +Package for test-only Firebase utilities. +""" + +load("@dagger//:workspace_defs.bzl", "dagger_rules") +load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") + +kt_android_library( + name = "test_authentication_module", + testonly = True, + srcs = [ + "FakeFirebaseAuthWrapperImpl.kt", + "TestAuthenticationModule.kt", + ], + visibility = ["//:oppia_testing_visibility"], + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/auth:firebase_auth_wrapper", + ], +) + +dagger_rules() diff --git a/testing/src/main/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImpl.kt b/testing/src/main/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImpl.kt similarity index 97% rename from testing/src/main/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImpl.kt rename to testing/src/main/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImpl.kt index 8f8a9d54b53..616448ce4a2 100644 --- a/testing/src/main/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImpl.kt +++ b/testing/src/main/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImpl.kt @@ -1,4 +1,4 @@ -package org.oppia.android.testing +package org.oppia.android.testing.firebase import org.oppia.android.domain.auth.FirebaseAuthWrapper import org.oppia.android.domain.auth.FirebaseUserWrapper diff --git a/testing/src/main/java/org/oppia/android/testing/TestAuthenticationModule.kt b/testing/src/main/java/org/oppia/android/testing/firebase/TestAuthenticationModule.kt similarity index 90% rename from testing/src/main/java/org/oppia/android/testing/TestAuthenticationModule.kt rename to testing/src/main/java/org/oppia/android/testing/firebase/TestAuthenticationModule.kt index ed973730f5a..649f684b064 100644 --- a/testing/src/main/java/org/oppia/android/testing/TestAuthenticationModule.kt +++ b/testing/src/main/java/org/oppia/android/testing/firebase/TestAuthenticationModule.kt @@ -1,4 +1,4 @@ -package org.oppia.android.testing +package org.oppia.android.testing.firebase import dagger.Module import dagger.Provides diff --git a/testing/src/test/java/org/oppia/android/testing/firebase/BUILD.bazel b/testing/src/test/java/org/oppia/android/testing/firebase/BUILD.bazel new file mode 100644 index 00000000000..c6d5f002b6d --- /dev/null +++ b/testing/src/test/java/org/oppia/android/testing/firebase/BUILD.bazel @@ -0,0 +1,48 @@ +""" +Tests for test-only Firebase utilities. +""" + +load("@dagger//:workspace_defs.bzl", "dagger_rules") +load("//:oppia_android_test.bzl", "oppia_android_test") + +oppia_android_test( + name = "FakeFirebaseAuthWrapperImplTest", + srcs = ["FakeFirebaseAuthWrapperImplTest.kt"], + custom_package = "org.oppia.android.testing.firebase", + test_class = "org.oppia.android.testing.firebase.FakeFirebaseAuthWrapperImplTest", + test_manifest = "//testing:test_manifest", + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", + "//testing", + "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", + "//testing/src/main/java/org/oppia/android/testing/threading:test_module", + "//testing/src/main/java/org/oppia/android/testing/time:test_module", + "//third_party:com_google_truth_truth", + "//third_party:junit_junit", + "//third_party:org_robolectric_robolectric", + "//third_party:robolectric_android-all", + ], +) + +oppia_android_test( + name = "TestAuthenticationModuleTest", + srcs = ["TestAuthenticationModuleTest.kt"], + custom_package = "org.oppia.android.testing.firebase", + test_class = "org.oppia.android.testing.firebase.TestAuthenticationModuleTest", + test_manifest = "//testing:test_manifest", + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", + "//testing", + "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", + "//testing/src/main/java/org/oppia/android/testing/threading:test_module", + "//testing/src/main/java/org/oppia/android/testing/time:test_module", + "//third_party:com_google_truth_truth", + "//third_party:junit_junit", + "//third_party:org_robolectric_robolectric", + "//third_party:robolectric_android-all", + ], +) + +dagger_rules() diff --git a/testing/src/test/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImplTest.kt b/testing/src/test/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImplTest.kt similarity index 95% rename from testing/src/test/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImplTest.kt rename to testing/src/test/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImplTest.kt index 3da520b2da4..d26d56c8480 100644 --- a/testing/src/test/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImplTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/firebase/FakeFirebaseAuthWrapperImplTest.kt @@ -1,4 +1,4 @@ -package org.oppia.android.testing +package org.oppia.android.testing.firebase import android.app.Application import android.content.Context @@ -14,7 +14,8 @@ import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.domain.auth.FirebaseUserWrapper import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule -import org.oppia.android.testing.FakeFirebaseAuthWrapperImpl.FakeAuthState +import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.FakeFirebaseAuthWrapperImpl.FakeAuthState import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule diff --git a/testing/src/test/java/org/oppia/android/testing/TestAuthenticationModuleTest.kt b/testing/src/test/java/org/oppia/android/testing/firebase/TestAuthenticationModuleTest.kt similarity index 98% rename from testing/src/test/java/org/oppia/android/testing/TestAuthenticationModuleTest.kt rename to testing/src/test/java/org/oppia/android/testing/firebase/TestAuthenticationModuleTest.kt index e9a9a5f9b23..284f0b27bc4 100644 --- a/testing/src/test/java/org/oppia/android/testing/TestAuthenticationModuleTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/firebase/TestAuthenticationModuleTest.kt @@ -1,4 +1,4 @@ -package org.oppia.android.testing +package org.oppia.android.testing.firebase import android.app.Application import android.content.Context diff --git a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleCustomContextTest.kt b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleCustomContextTest.kt index 71f53946331..b5076ee912e 100644 --- a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleCustomContextTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleCustomContextTest.kt @@ -60,8 +60,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule diff --git a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt index 385742c3a2c..5463cb0e542 100644 --- a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleOmissionTest.kt @@ -57,9 +57,9 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.assertThrows +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule diff --git a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleTest.kt b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleTest.kt index 896afc9b13e..3a8f7eaf441 100644 --- a/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/junit/InitializeDefaultLocaleRuleTest.kt @@ -61,8 +61,8 @@ import org.oppia.android.domain.platformparameter.PlatformParameterSingletonModu import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.domain.workmanager.WorkManagerConfigurationModule -import org.oppia.android.testing.TestAuthenticationModule import org.oppia.android.testing.TestLogReportingModule +import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.threading.TestDispatcherModule import org.oppia.android.testing.time.FakeOppiaClockModule From 8dbf4dc04a95d95f394c25ab75755f945702b0d7 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 7 Feb 2024 23:42:43 +0000 Subject: [PATCH 14/21] Add missing CODEOWNERS line. --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 00aff7fcea9..fb5866d071e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -110,6 +110,7 @@ /testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricAssessorTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt @oppia/android-app-infrastructure-reviewers +/testing/src/*/java/org/oppia/android/testing/firebase/ @oppia/android-app-infrastructure-reviewers /testing/src/*/java/org/oppia/android/testing/lightweightcheckpointing/ @oppia/android-app-infrastructure-reviewers /testing/src/*/java/org/oppia/android/testing/logging/ @oppia/android-app-infrastructure-reviewers /testing/src/*/java/org/oppia/android/testing/math/ @oppia/android-app-infrastructure-reviewers From 9c3805711833cb1b315f63abadd6ea0c8b5fd4f3 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 7 Feb 2024 23:44:20 +0000 Subject: [PATCH 15/21] Remove old files from CODEOWNERS. --- .github/CODEOWNERS | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index fb5866d071e..b4a1de1c04a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -94,18 +94,14 @@ /testing/src/main/java/org/oppia/android/testing/FakeAnalyticsEventLogger.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakeExceptionLogger.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakeFirebaseAuthInstanceWrapperImpl.kt @oppia/android-app-infrastructure-reviewers -/testing/src/main/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImpl.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakeFirestoreEventLogger.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakeFirestoreInstanceWrapperImpl.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakePerformanceMetricAssessor.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/FakePerformanceMetricsEventLogger.kt @oppia/android-app-infrastructure-reviewers -/testing/src/main/java/org/oppia/android/testing/TestAuthenticationModule.kt @oppia/android-app-infrastructure-reviewers -/testing/src/test/java/org/oppia/android/testing/TestAuthenticationModuleTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/TestImageLoaderModule.kt @oppia/android-app-infrastructure-reviewers /testing/src/main/java/org/oppia/android/testing/TestLogReportingModule.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt @oppia/android-app-infrastructure-reviewers -/testing/src/test/java/org/oppia/android/testing/FakeFirebaseAuthWrapperImplTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricAssessorTest.kt @oppia/android-app-infrastructure-reviewers /testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt @oppia/android-app-infrastructure-reviewers From fad48ede88b6cdd4fc81dfa387e8b9bd0a6f8659 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 8 Feb 2024 00:46:30 +0000 Subject: [PATCH 16/21] Add missing tests for TestBlazeWorkspace changes. Also includes some minor clean-ups within TestBazelWorkspaceTest. --- .../scripts/testing/TestBazelWorkspace.kt | 3 +- .../scripts/testing/TestBazelWorkspaceTest.kt | 217 ++++++++++++------ 2 files changed, 148 insertions(+), 72 deletions(-) diff --git a/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt b/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt index f1230c0f63d..7bec4b85889 100644 --- a/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt +++ b/scripts/src/java/org/oppia/android/scripts/testing/TestBazelWorkspace.kt @@ -123,7 +123,8 @@ class TestBazelWorkspace(private val temporaryRootFolder: TemporaryFolder) { withExtraDependency: String? = null, subpackage: String? = null ): Iterable { - initEmptyWorkspace() // Ensure the workspace is at least initialized. + // Note that the workspace doesn't need to be explicitly initialized here since the call below + // to addTestToBuildFile() will initialize it. check(testName !in testFileMap) { "Test '$testName' already exists" } val testFile = if (subpackage != null) { diff --git a/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt b/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt index 00cbba1f19c..e20b633bbc9 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/testing/TestBazelWorkspaceTest.kt @@ -23,9 +23,7 @@ import java.lang.IllegalStateException // Function name: test names are conventionally named with underscores. @Suppress("FunctionName") class TestBazelWorkspaceTest { - @Rule - @JvmField - var tempFolder = TemporaryFolder() + @field:[Rule JvmField] val tempFolder = TemporaryFolder() @Test fun testCreateTestUtility_doesNotImmediatelyCreateAnyFiles() { @@ -37,7 +35,7 @@ class TestBazelWorkspaceTest { } @Test - fun testInitEmptyWorkspace_emptyDirectory_createsEmptyWorkspace() { + fun testInitEmptyWorkspace_emptyDirectory_createsEmptyWorkspaceFile() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) testBazelWorkspace.initEmptyWorkspace() @@ -48,6 +46,30 @@ class TestBazelWorkspaceTest { assertThat(workspaceFile.readLines()).isEmpty() } + @Test + fun testInitEmptyWorkspace_emptyDirectory_createsBazelVersionFile() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.initEmptyWorkspace() + + // A .bazelversion file should now exist with the correct version. + val bazelVersionFile = File(tempFolder.root, ".bazelversion") + assertThat(bazelVersionFile.exists()).isTrue() + assertThat(bazelVersionFile.readText().trim()).isEqualTo("4.0.0") + } + + @Test + fun testInitEmptyWorkspace_emptyDirectory_createsBazelRcFile() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.initEmptyWorkspace() + + // A .bazelversion file should now exist with the correct flags. + val bazelRcFile = File(tempFolder.root, ".bazelrc") + assertThat(bazelRcFile.exists()).isTrue() + assertThat(bazelRcFile.readText().trim()).isEqualTo("--noenable_bzlmod") + } + @Test fun testInitEmptyWorkspace_fileCreationFails_throwsAssertionError() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) @@ -85,11 +107,34 @@ class TestBazelWorkspaceTest { ) val workspaceFile = testBazelWorkspace.workspaceFile - val workspaceContent = workspaceFile.readAsJoinedString() - + val workspaceContent = workspaceFile.readText() assertThat(workspaceContent).contains("com.android.support:support-annotations:28.0.0") } + @Test + fun testSetupWorkspaceForRulesJvmExternal_withOneDep_setsUpBazelVersion() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.setUpWorkspaceForRulesJvmExternal( + listOf("com.android.support:support-annotations:28.0.0") + ) + + val bazelVersionContent = tempFolder.getBazelVersionFile().readText().trim() + assertThat(bazelVersionContent).isEqualTo("4.0.0") + } + + @Test + fun testSetupWorkspaceForRulesJvmExternal_withOneDep_setsUpBazelRc() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.setUpWorkspaceForRulesJvmExternal( + listOf("com.android.support:support-annotations:28.0.0") + ) + + val bazelRcContent = tempFolder.getBazelRcFile().readText().trim() + assertThat(bazelRcContent).isEqualTo("--noenable_bzlmod") + } + @Test fun testSetupWorkspaceForRulesJvmExternal_withTwoDeps_containsCorrectList() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) @@ -102,7 +147,7 @@ class TestBazelWorkspaceTest { ) val workspaceFile = testBazelWorkspace.workspaceFile - val workspaceContent = workspaceFile.readAsJoinedString() + val workspaceContent = workspaceFile.readText() assertThat(workspaceContent).contains("com.android.support:support-annotations:28.0.0") assertThat(workspaceContent).contains("io.fabric.sdk.android:fabric:1.4.7") @@ -122,7 +167,7 @@ class TestBazelWorkspaceTest { ) val workspaceFile = testBazelWorkspace.workspaceFile - val workspaceContent = workspaceFile.readAsJoinedString() + val workspaceContent = workspaceFile.readText() assertThat(workspaceContent).contains("com.android.support:support-annotations:28.0.0") assertThat(workspaceContent).contains("io.fabric.sdk.android:fabric:1.4.7") @@ -143,7 +188,7 @@ class TestBazelWorkspaceTest { ) val workspaceFile = testBazelWorkspace.workspaceFile - val workspaceContent = workspaceFile.readAsJoinedString() + val workspaceContent = workspaceFile.readText() assertThat(workspaceContent).contains("com.android.support:support-annotations:28.0.0") assertThat(workspaceContent).doesNotContain("io.fabric.sdk.android:fabric:1.4.7") @@ -158,7 +203,7 @@ class TestBazelWorkspaceTest { ) val workspaceFile = testBazelWorkspace.workspaceFile - val workspaceContent = workspaceFile.readAsJoinedString() + val workspaceContent = workspaceFile.readText() assertThat(workspaceContent).contains( """ @@ -212,7 +257,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_reusedTestName_throwsException() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") val exception = assertThrows() { @@ -228,21 +272,45 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_firstTest_setsUpWorkspace() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTest.kt") ) - val workspaceContent = tempFolder.getWorkspaceFile().readAsJoinedString() + val workspaceContent = tempFolder.getWorkspaceFile().readText() assertThat(workspaceContent).contains("kt_register_toolchains()") } + @Test + fun testAddTestToBuildFile_firstTest_setsUpBazelVersion() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.addTestToBuildFile( + testName = "FirstTest", + testFile = tempFolder.newFile("FirstTest.kt") + ) + + val bazelVersionContent = tempFolder.getBazelVersionFile().readText().trim() + assertThat(bazelVersionContent).isEqualTo("4.0.0") + } + + @Test + fun testAddTestToBuildFile_firstTest_setsUpBazelRc() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.addTestToBuildFile( + testName = "FirstTest", + testFile = tempFolder.newFile("FirstTest.kt") + ) + + val bazelRcContent = tempFolder.getBazelRcFile().readText().trim() + assertThat(bazelRcContent).isEqualTo("--noenable_bzlmod") + } + @Test fun testAddTestToBuildFile_firstTest_returnsTestBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -255,7 +323,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_secondTest_doesNotChangeWorkspace() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTest.kt") @@ -275,14 +342,13 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_firstTest_initializesBuildFileOnlyForTests() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTest.kt") ) - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_test")).isEqualTo(1) assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(0) } @@ -290,7 +356,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_secondTest_doesNotReinitializeBuildFile() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTest.kt") @@ -302,14 +367,13 @@ class TestBazelWorkspaceTest { ) // The load line should only exist once in the file. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_test")).isEqualTo(1) } @Test fun testAddTestToBuildFile_unusedTestName_appendsBasicTest() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -317,7 +381,7 @@ class TestBazelWorkspaceTest { ) // There should be 1 test in the file with empty deps and correct source. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = []") @@ -326,7 +390,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withGeneratedDep_configuresBuildFileForLibraries() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -335,14 +398,13 @@ class TestBazelWorkspaceTest { ) // The build file should now be initialized for libraries. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(1) } @Test fun testAddTestToBuildFile_unusedTestName_withGeneratedDep_appendsLibraryAndTestWithDep() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -351,7 +413,7 @@ class TestBazelWorkspaceTest { ) // Ensure the test is arranged correctly. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = [\"//:FirstTestDependency_lib\",]") @@ -363,7 +425,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_firstTest_withGeneratedDep_returnsTestDepBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -378,7 +439,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_secondTest_withGeneratedDep_returnsTestDepBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", testFile = tempFolder.newFile("FirstTest.kt") @@ -397,7 +457,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withExtraDep_appendsTestWithDep() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -406,7 +465,7 @@ class TestBazelWorkspaceTest { ) // Ensure the test is arranged correctly. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = [\"//:ExtraDep\",]") @@ -415,7 +474,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withSubpackage_appendsToSubpackageBuildFile() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() tempFolder.newFolder("subpackage") testBazelWorkspace.addTestToBuildFile( @@ -437,7 +495,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withSubpackage_returnsNewBuildAndTestFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() tempFolder.newFolder("subpackage") val files = testBazelWorkspace.addTestToBuildFile( @@ -453,7 +510,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withMultipleSubpackages_returnsNewBuildAndTestFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val subpackage = "subpackage.first.second" tempFolder.newFolder(*(subpackage.split(".")).toTypedArray()) val files = testBazelWorkspace.addTestToBuildFile( @@ -471,7 +527,6 @@ class TestBazelWorkspaceTest { @Test fun testAddTestToBuildFile_unusedTestName_withGeneratedAndExtraDeps_includesBothInTestDeps() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.addTestToBuildFile( testName = "FirstTest", @@ -481,7 +536,7 @@ class TestBazelWorkspaceTest { ) // Both dependencies should be included in the test's deps. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("deps = [\"//:FirstTestDependency_lib\",\"//:ExtraDep\",]") } @@ -489,7 +544,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_reusedTestName_throwsException() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") val exception = assertThrows() { @@ -502,18 +556,36 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_firstTest_setsUpWorkspace() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") - val workspaceContent = tempFolder.getWorkspaceFile().readAsJoinedString() + val workspaceContent = tempFolder.getWorkspaceFile().readText() assertThat(workspaceContent).contains("kt_register_toolchains()") } + @Test + fun testCreateTest_firstTest_setsUpBazelVersion() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.createTest(testName = "FirstTest") + + val bazelVersionContent = tempFolder.getBazelVersionFile().readText().trim() + assertThat(bazelVersionContent).isEqualTo("4.0.0") + } + + @Test + fun testCreateTest_firstTest_setsUpBazelRc() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.createTest(testName = "FirstTest") + + val bazelRcContent = tempFolder.getBazelRcFile().readText().trim() + assertThat(bazelRcContent).isEqualTo("--noenable_bzlmod") + } + @Test fun testCreateTest_firstTest_returnsTestBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.createTest(testName = "FirstTest") @@ -523,7 +595,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_secondTest_doesNotChangeWorkspace() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") val workspaceSize = tempFolder.getWorkspaceFile().length() @@ -537,11 +608,10 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_firstTest_initializesBuildFileOnlyForTests() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_test")).isEqualTo(1) assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(0) } @@ -549,25 +619,23 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_secondTest_doesNotReinitializeBuildFile() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") testBazelWorkspace.createTest(testName = "SecondTest") // The load line should only exist once in the file. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_test")).isEqualTo(1) } @Test fun testCreateTest_unusedTestName_appendsBasicTest() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") // There should be 1 test in the file with empty deps and correct source. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = []") @@ -576,7 +644,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withGeneratedDep_configuresBuildFileForLibraries() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest( testName = "FirstTest", @@ -584,14 +651,13 @@ class TestBazelWorkspaceTest { ) // The build file should now be initialized for libraries. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(1) } @Test fun testCreateTest_unusedTestName_withGeneratedDep_appendsLibraryAndTestWithDep() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest( testName = "FirstTest", @@ -599,7 +665,7 @@ class TestBazelWorkspaceTest { ) // Ensure the test is arranged correctly. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = [\"//:FirstTestDependency_lib\",]") @@ -611,7 +677,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_firstTest_withGeneratedDep_returnsTestDepBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.createTest( testName = "FirstTest", @@ -625,7 +690,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_secondTest_withGeneratedDep_returnsTestDepBuildWorkspaceFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest") val files = testBazelWorkspace.createTest( @@ -640,12 +704,11 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withExtraDep_appendsTestWithDep() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest", withExtraDependency = "//:ExtraDep") // Ensure the test is arranged correctly. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("srcs = [\"FirstTest.kt\"]") assertThat(buildContent).contains("deps = [\"//:ExtraDep\",]") @@ -654,7 +717,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withSubpackage_appendsToSubpackageBuildFile() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest(testName = "FirstTest", subpackage = "subpackage") @@ -671,7 +733,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withSubpackage_returnsNewBuildAndTestFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.createTest(testName = "FirstTest", subpackage = "subpackage") @@ -682,7 +743,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withMultipleSubpackages_returnsNewBuildAndTestFiles() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val files = testBazelWorkspace.createTest( testName = "FirstTest", @@ -698,7 +758,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateTest_unusedTestName_withGeneratedAndExtraDeps_includesBothInTestDeps() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createTest( testName = "FirstTest", @@ -707,7 +766,7 @@ class TestBazelWorkspaceTest { ) // Both dependencies should be included in the test's deps. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_test\\(")).isEqualTo(1) assertThat(buildContent).contains("deps = [\"//:FirstTestDependency_lib\",\"//:ExtraDep\",]") } @@ -715,24 +774,42 @@ class TestBazelWorkspaceTest { @Test fun testCreateLibrary_firstLib_unusedName_configuresWorkspaceAndBuild() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "ExampleDep") - val workspaceContent = tempFolder.getWorkspaceFile().readAsJoinedString() - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val workspaceContent = tempFolder.getWorkspaceFile().readText() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(workspaceContent).contains("kt_register_toolchains()") assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(1) } + @Test + fun testCreateLibrary_firstLib_unusedName_setsUpBazelVersion() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.createLibrary(dependencyName = "ExampleDep") + + val bazelVersionContent = tempFolder.getBazelVersionFile().readText().trim() + assertThat(bazelVersionContent).isEqualTo("4.0.0") + } + + @Test + fun testCreateLibrary_firstLib_unusedName_setsUpBazelRc() { + val testBazelWorkspace = TestBazelWorkspace(tempFolder) + + testBazelWorkspace.createLibrary(dependencyName = "ExampleDep") + + val bazelRcContent = tempFolder.getBazelRcFile().readText().trim() + assertThat(bazelRcContent).isEqualTo("--noenable_bzlmod") + } + @Test fun testCreateLibrary_firstLib_unusedName_appendsJvmLibraryDeclaration() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "ExampleDep") - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("kt_jvm_library\\(")).isEqualTo(1) assertThat(buildContent).contains("name = \"ExampleDep_lib\"") assertThat(buildContent).contains("srcs = [\"ExampleDep.kt\"]") @@ -741,7 +818,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateLibrary_firstLib_unusedName_returnsBuildLibAndWorkspaceFilesWithTargetName() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() val (targetName, files) = testBazelWorkspace.createLibrary(dependencyName = "ExampleDep") @@ -752,7 +828,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateLibrary_secondLib_unusedName_doesNotChangeWorkspace() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "FirstLib") val workspaceSize = tempFolder.getWorkspaceFile().length() @@ -765,13 +840,12 @@ class TestBazelWorkspaceTest { @Test fun testCreateLibrary_secondLib_unusedName_appendsJvmLibraryDeclaration() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "FirstLib") testBazelWorkspace.createLibrary(dependencyName = "SecondLib") // The kt_jvm_library declaration should only exist once, and both libraries should exist. - val buildContent = testBazelWorkspace.rootBuildFile.readAsJoinedString() + val buildContent = testBazelWorkspace.rootBuildFile.readText() assertThat(buildContent.countMatches("load\\(.+?kt_jvm_library")).isEqualTo(1) assertThat(buildContent.countMatches("kt_jvm_library\\(")).isEqualTo(2) assertThat(buildContent).contains("name = \"FirstLib_lib\"") @@ -783,7 +857,6 @@ class TestBazelWorkspaceTest { @Test fun testCreateLibrary_secondLib_reusedName_throwsException() { val testBazelWorkspace = TestBazelWorkspace(tempFolder) - testBazelWorkspace.initEmptyWorkspace() testBazelWorkspace.createLibrary(dependencyName = "FirstLib") val exception = assertThrows() { @@ -801,7 +874,7 @@ class TestBazelWorkspaceTest { testBazelWorkspace.createTest(testName = "FirstTest") // The workspace should only be configured once (due to the library initialization). - val workspaceContent = tempFolder.getWorkspaceFile().readAsJoinedString() + val workspaceContent = tempFolder.getWorkspaceFile().readText() assertThat(workspaceContent.countMatches("http_archive\\(")).isEqualTo(1) } @@ -813,7 +886,7 @@ class TestBazelWorkspaceTest { testBazelWorkspace.createLibrary(dependencyName = "FirstLib") // The workspace should only be configured once (due to the test initialization). - val workspaceContent = tempFolder.getWorkspaceFile().readAsJoinedString() + val workspaceContent = tempFolder.getWorkspaceFile().readText() assertThat(workspaceContent.countMatches("http_archive\\(")).isEqualTo(1) } @@ -901,7 +974,9 @@ class TestBazelWorkspaceTest { private fun TemporaryFolder.getWorkspaceFile(): File = File(root, "WORKSPACE") - private fun File.readAsJoinedString(): String = readLines().joinToString(separator = "\n") + private fun TemporaryFolder.getBazelVersionFile(): File = File(root, ".bazelversion") + + private fun TemporaryFolder.getBazelRcFile(): File = File(root, ".bazelrc") private fun File.isRelativeTo(base: File): Boolean = relativeToOrNull(base) != null From e1802c8242eaa7877360c8301177a1e8980f722b Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 8 Feb 2024 01:14:07 +0000 Subject: [PATCH 17/21] Add missing Firebase auth tests. --- .../org/oppia/android/domain/auth/BUILD.bazel | 46 +++++++++++++++++++ .../auth/FirebaseAuthWrapperImplTest.kt | 1 - 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/domain/src/test/java/org/oppia/android/domain/auth/BUILD.bazel b/domain/src/test/java/org/oppia/android/domain/auth/BUILD.bazel index 61f22c5ed07..7b549aa2c45 100644 --- a/domain/src/test/java/org/oppia/android/domain/auth/BUILD.bazel +++ b/domain/src/test/java/org/oppia/android/domain/auth/BUILD.bazel @@ -5,6 +5,29 @@ Tests for libraries providing authentication with Firebase functionality. load("@dagger//:workspace_defs.bzl", "dagger_rules") load("//:oppia_android_test.bzl", "oppia_android_test") +oppia_android_test( + name = "AuthenticationControllerTest", + srcs = ["AuthenticationControllerTest.kt"], + custom_package = "org.oppia.android.domain.auth", + test_class = "org.oppia.android.domain.auth.AuthenticationControllerTest", + test_manifest = "//domain:test_manifest", + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/auth:auth_module", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", + "//testing", + "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", + "//testing/src/main/java/org/oppia/android/testing/threading:test_module", + "//testing/src/main/java/org/oppia/android/testing/time:test_module", + "//third_party:androidx_test_ext_junit", + "//third_party:com_google_truth_truth", + "//third_party:junit_junit", + "//third_party:org_mockito_mockito-core", + "//third_party:org_robolectric_robolectric", + "//third_party:robolectric_android-all", + ], +) + oppia_android_test( name = "AuthenticationModuleTest", srcs = ["AuthenticationModuleTest.kt"], @@ -27,4 +50,27 @@ oppia_android_test( ], ) +oppia_android_test( + name = "FirebaseAuthWrapperImplTest", + srcs = ["FirebaseAuthWrapperImplTest.kt"], + custom_package = "org.oppia.android.domain.auth", + test_class = "org.oppia.android.domain.auth.FirebaseAuthWrapperImplTest", + test_manifest = "//domain:test_manifest", + deps = [ + ":dagger", + "//domain/src/main/java/org/oppia/android/domain/auth:auth_module", + "//domain/src/main/java/org/oppia/android/domain/oppialogger/analytics:prod_module", + "//testing", + "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", + "//testing/src/main/java/org/oppia/android/testing/threading:test_module", + "//testing/src/main/java/org/oppia/android/testing/time:test_module", + "//third_party:androidx_test_ext_junit", + "//third_party:com_google_truth_truth", + "//third_party:junit_junit", + "//third_party:org_mockito_mockito-core", + "//third_party:org_robolectric_robolectric", + "//third_party:robolectric_android-all", + ], +) + dagger_rules() diff --git a/domain/src/test/java/org/oppia/android/domain/auth/FirebaseAuthWrapperImplTest.kt b/domain/src/test/java/org/oppia/android/domain/auth/FirebaseAuthWrapperImplTest.kt index 28a07b49b39..8983ae92125 100644 --- a/domain/src/test/java/org/oppia/android/domain/auth/FirebaseAuthWrapperImplTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/auth/FirebaseAuthWrapperImplTest.kt @@ -31,7 +31,6 @@ import javax.inject.Singleton @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FirebaseAuthWrapperImplTest.TestApplication::class) - class FirebaseAuthWrapperImplTest { @Inject From d3cbd9356aadd3197101ca446d904863245f76af Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 8 Feb 2024 01:34:40 +0000 Subject: [PATCH 18/21] Post-merge fixes for previously missed tests. --- .../auth/AuthenticationControllerTest.kt | 78 +++++++++++-------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt index 4208244c46e..2b69a7e7c76 100644 --- a/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/auth/AuthenticationControllerTest.kt @@ -11,13 +11,21 @@ import dagger.Module import dagger.Provides import kotlinx.coroutines.CoroutineDispatcher import org.junit.Before +import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mock +import org.mockito.Mockito.verify +import org.mockito.Mockito.verifyNoInteractions +import org.mockito.junit.MockitoJUnit +import org.mockito.junit.MockitoRule import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleModule import org.oppia.android.testing.TestLogReportingModule -import org.oppia.android.testing.assertThrows import org.oppia.android.testing.firebase.FakeFirebaseAuthWrapperImpl import org.oppia.android.testing.firebase.TestAuthenticationModule +import org.oppia.android.testing.mockito.capture import org.oppia.android.testing.robolectric.RobolectricModule import org.oppia.android.testing.time.FakeOppiaClockModule import org.oppia.android.util.data.DataProvidersInjector @@ -36,17 +44,16 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = AuthenticationControllerTest.TestApplication::class) class AuthenticationControllerTest { - @Inject - lateinit var firebaseAuthWrapper: FirebaseAuthWrapper + @field:[Rule JvmField] val mockitoRule: MockitoRule = MockitoJUnit.rule() - @Inject - lateinit var fakeFirebaseAuthWrapperImpl: FakeFirebaseAuthWrapperImpl + @Inject lateinit var firebaseAuthWrapper: FirebaseAuthWrapper + @Inject lateinit var fakeFirebaseAuthWrapperImpl: FakeFirebaseAuthWrapperImpl + @Inject lateinit var authenticationController: AuthenticationController + @field:[Inject BackgroundDispatcher] lateinit var backgroundDispatcher: CoroutineDispatcher - @Inject - lateinit var authenticationController: AuthenticationController - - @field:[Inject BackgroundDispatcher] - lateinit var backgroundDispatcher: CoroutineDispatcher + @Mock lateinit var mockFakeSuccessCallback: FakeSuccessCallback + @Mock lateinit var mockFakeFailureCallback: FakeFailureCallback + @Captor lateinit var throwableCaptor: ArgumentCaptor @Before fun setUp() { @@ -54,48 +61,49 @@ class AuthenticationControllerTest { } @Test - fun testAuthentication_getCurrentUser_userSignedIn_returnsInstanceOfFirebaseUserWrapper() { + fun testAuthentication_signInAnonymously_onlyOnSuccessCalled() { fakeFirebaseAuthWrapperImpl.simulateSignInSuccess() firebaseAuthWrapper.signInAnonymously( - onSuccess = {}, - onFailure = {} + onSuccess = mockFakeSuccessCallback::onSuccess, + onFailure = mockFakeFailureCallback::onFailure ) - val user = authenticationController.currentFirebaseUser - - assertThat(user).isInstanceOf(FirebaseUserWrapper::class.java) + // onSuccess should be called. + verify(mockFakeSuccessCallback).onSuccess() + verifyNoInteractions(mockFakeFailureCallback) } @Test - fun testAuthentication_signInAnonymously_succeeds() { - fakeFirebaseAuthWrapperImpl.simulateSignInSuccess() + fun testAuthentication_signInAnonymously_onlyOnFailureCalled() { + fakeFirebaseAuthWrapperImpl.simulateSignInFailure() firebaseAuthWrapper.signInAnonymously( - onSuccess = {}, - onFailure = {} + onSuccess = mockFakeSuccessCallback::onSuccess, + onFailure = mockFakeFailureCallback::onFailure ) - val user = authenticationController.currentFirebaseUser - - assertThat(user).isInstanceOf(FirebaseUserWrapper::class.java) + // onFailure should be called with the failure details. + verify(mockFakeFailureCallback).onFailure(capture(throwableCaptor)) + verifyNoInteractions(mockFakeSuccessCallback) + assertThat(throwableCaptor.value).hasMessageThat().contains("Sign-in failure") } @Test - fun testAuthentication_signInAnonymously_failure_returnsException() { - fakeFirebaseAuthWrapperImpl.simulateSignInFailure() + fun testAuthentication_getCurrentUser_userSignedIn_returnsInstanceOfFirebaseUserWrapper() { + fakeFirebaseAuthWrapperImpl.simulateSignInSuccess() + firebaseAuthWrapper.signInAnonymously( + onSuccess = mockFakeSuccessCallback::onSuccess, + onFailure = mockFakeFailureCallback::onFailure + ) - assertThrows(Throwable::class) { - firebaseAuthWrapper.signInAnonymously( - onSuccess = {}, - onFailure = {} - ) - } + val user = authenticationController.currentFirebaseUser + + assertThat(user).isInstanceOf(FirebaseUserWrapper::class.java) } private fun setUpTestApplicationComponent() { - ApplicationProvider.getApplicationContext() - .inject(this) + ApplicationProvider.getApplicationContext().inject(this) } @Module @@ -141,4 +149,8 @@ class AuthenticationControllerTest { override fun getDataProvidersInjector(): DataProvidersInjector = component } + + interface FakeSuccessCallback { fun onSuccess() } + + interface FakeFailureCallback { fun onFailure(failure: Throwable) } } From 8de4d5162d49232f045e10105eac5a3cfacc872e Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 9 Feb 2024 23:24:27 +0000 Subject: [PATCH 19/21] Improve new test robustness. Required upgrade of kotlinx-coroutines-core. --- ...ScriptBackgroundCoroutineDispatcherTest.kt | 2 + third_party/maven_install.json | 112 ++++++++++++------ third_party/versions.bzl | 2 +- 3 files changed, 79 insertions(+), 37 deletions(-) diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcherTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcherTest.kt index 68329ac15fa..c1d4f98314b 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcherTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/ScriptBackgroundCoroutineDispatcherTest.kt @@ -72,6 +72,8 @@ class ScriptBackgroundCoroutineDispatcherTest { runBlocking { taskStartedChannel.receive() } dispatcher.close() + // This slows down the test, but provides assurance that the task was definitely cancelled. + runBlocking { delay(2_000L) } // The task should not have run since it was cancelled, but no exception will be thrown. verifyNoMoreInteractions(mockRunnable) diff --git a/third_party/maven_install.json b/third_party/maven_install.json index 24221d97d55..42841194450 100644 --- a/third_party/maven_install.json +++ b/third_party/maven_install.json @@ -1,8 +1,8 @@ { "dependency_tree": { "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", - "__INPUT_ARTIFACTS_HASH": -1629412368, - "__RESOLVED_ARTIFACTS_HASH": 1784154617, + "__INPUT_ARTIFACTS_HASH": -1278449106, + "__RESOLVED_ARTIFACTS_HASH": 896273545, "conflict_resolution": { "androidx.constraintlayout:constraintlayout:1.1.3": "androidx.constraintlayout:constraintlayout:2.0.1", "androidx.core:core:1.0.1": "androidx.core:core:1.3.1", @@ -1783,12 +1783,12 @@ { "coord": "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0", "dependencies": [ - "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1", "androidx.lifecycle:lifecycle-common:2.2.0", "androidx.annotation:annotation:1.1.0", "androidx.lifecycle:lifecycle-livedata:aar:2.2.0", "androidx.lifecycle:lifecycle-livedata-core:aar:2.2.0", "androidx.lifecycle:lifecycle-livedata-core-ktx:aar:2.2.0", + "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3", "androidx.arch.core:core-common:2.1.0", "org.jetbrains.kotlin:kotlin-stdlib:1.5.0", "androidx.arch.core:core-runtime:aar:2.1.0" @@ -1797,7 +1797,7 @@ "androidx.lifecycle:lifecycle-livedata:aar:2.2.0", "androidx.lifecycle:lifecycle-livedata-core-ktx:aar:2.2.0", "org.jetbrains.kotlin:kotlin-stdlib:1.5.0", - "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1" + "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" ], "file": "v1/https/maven.google.com/androidx/lifecycle/lifecycle-livedata-ktx/2.2.0/lifecycle-livedata-ktx-2.2.0.aar", "mirror_urls": [ @@ -1813,12 +1813,12 @@ { "coord": "androidx.lifecycle:lifecycle-livedata-ktx:jar:sources:2.2.0", "dependencies": [ - "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.1", "androidx.arch.core:core-runtime:aar:sources:2.1.0", "org.jetbrains.kotlin:kotlin-stdlib:jar:sources:1.5.0", "androidx.lifecycle:lifecycle-livedata-core:aar:sources:2.2.0", "androidx.lifecycle:lifecycle-livedata:aar:sources:2.2.0", "androidx.lifecycle:lifecycle-livedata-core-ktx:aar:sources:2.2.0", + "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.3", "androidx.annotation:annotation:jar:sources:1.1.0", "androidx.arch.core:core-common:jar:sources:2.1.0", "androidx.lifecycle:lifecycle-common:jar:sources:2.2.0" @@ -1827,7 +1827,7 @@ "androidx.lifecycle:lifecycle-livedata:aar:sources:2.2.0", "androidx.lifecycle:lifecycle-livedata-core-ktx:aar:sources:2.2.0", "org.jetbrains.kotlin:kotlin-stdlib:jar:sources:1.5.0", - "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.1" + "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.3" ], "file": "v1/https/maven.google.com/androidx/lifecycle/lifecycle-livedata-ktx/2.2.0/lifecycle-livedata-ktx-2.2.0-sources.jar", "mirror_urls": [ @@ -9637,13 +9637,12 @@ { "coord": "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1", "dependencies": [ - "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1", - "org.jetbrains.kotlin:kotlin-stdlib-common:1.5.0", - "org.jetbrains.kotlin:kotlin-stdlib:1.5.0" + "org.jetbrains.kotlin:kotlin-stdlib:1.5.0", + "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" ], "directDependencies": [ "org.jetbrains.kotlin:kotlin-stdlib:1.5.0", - "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1" + "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" ], "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-android/1.4.1/kotlinx-coroutines-android-1.4.1.jar", "mirror_urls": [ @@ -9660,12 +9659,11 @@ "coord": "org.jetbrains.kotlinx:kotlinx-coroutines-android:jar:sources:1.4.1", "dependencies": [ "org.jetbrains.kotlin:kotlin-stdlib:jar:sources:1.5.0", - "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.1", - "org.jetbrains.kotlin:kotlin-stdlib-common:jar:sources:1.5.0" + "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.3" ], "directDependencies": [ "org.jetbrains.kotlin:kotlin-stdlib:jar:sources:1.5.0", - "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.1" + "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.3" ], "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-android/1.4.1/kotlinx-coroutines-android-1.4.1-sources.jar", "mirror_urls": [ @@ -9679,7 +9677,7 @@ "url": "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-android/1.4.1/kotlinx-coroutines-android-1.4.1-sources.jar" }, { - "coord": "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1", + "coord": "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.3", "dependencies": [ "org.jetbrains.kotlin:kotlin-stdlib-common:1.5.0", "org.jetbrains.kotlin:kotlin-stdlib:1.5.0" @@ -9688,19 +9686,19 @@ "org.jetbrains.kotlin:kotlin-stdlib:1.5.0", "org.jetbrains.kotlin:kotlin-stdlib-common:1.5.0" ], - "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1.jar", + "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3.jar", "mirror_urls": [ - "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1.jar", - "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1.jar", - "https://maven.fabric.io/public/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1.jar", - "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1.jar", - "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1.jar" + "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3.jar", + "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3.jar", + "https://maven.fabric.io/public/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3.jar", + "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3.jar", + "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3.jar" ], - "sha256": "6d2f87764b6638f27aff12ed380db4b63c9d46ba55dc32683a650598fa5a3e22", - "url": "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1.jar" + "sha256": "f7be08ddf86bd88020da7b78adbf44228799cca54d5c0c4396d850bc66725163", + "url": "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3.jar" }, { - "coord": "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.1", + "coord": "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:jar:sources:1.4.3", "dependencies": [ "org.jetbrains.kotlin:kotlin-stdlib:jar:sources:1.5.0", "org.jetbrains.kotlin:kotlin-stdlib-common:jar:sources:1.5.0" @@ -9709,16 +9707,58 @@ "org.jetbrains.kotlin:kotlin-stdlib:jar:sources:1.5.0", "org.jetbrains.kotlin:kotlin-stdlib-common:jar:sources:1.5.0" ], - "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1-sources.jar", + "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3-sources.jar", + "mirror_urls": [ + "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3-sources.jar", + "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3-sources.jar", + "https://maven.fabric.io/public/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3-sources.jar", + "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3-sources.jar", + "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3-sources.jar" + ], + "sha256": "6f1a3f8be952a3c7c003cb32eca36a92a7afc4affea6cd8b769dd23d7f14bad2", + "url": "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.4.3/kotlinx-coroutines-core-jvm-1.4.3-sources.jar" + }, + { + "coord": "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3", + "dependencies": [ + "org.jetbrains.kotlin:kotlin-stdlib-common:1.5.0", + "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.3", + "org.jetbrains.kotlin:kotlin-stdlib:1.5.0" + ], + "directDependencies": [ + "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.3" + ], + "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3.jar", + "mirror_urls": [ + "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3.jar", + "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3.jar", + "https://maven.fabric.io/public/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3.jar", + "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3.jar", + "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3.jar" + ], + "sha256": "de487d57b156e4e237abbc9cf7fff8777b2495aff6caa8bc4e9cf6ec859f0224", + "url": "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3.jar" + }, + { + "coord": "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.3", + "dependencies": [ + "org.jetbrains.kotlin:kotlin-stdlib:jar:sources:1.5.0", + "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:jar:sources:1.4.3", + "org.jetbrains.kotlin:kotlin-stdlib-common:jar:sources:1.5.0" + ], + "directDependencies": [ + "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:jar:sources:1.4.3" + ], + "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3-sources.jar", "mirror_urls": [ - "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1-sources.jar", - "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1-sources.jar", - "https://maven.fabric.io/public/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1-sources.jar", - "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1-sources.jar", - "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1-sources.jar" + "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3-sources.jar", + "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3-sources.jar", + "https://maven.fabric.io/public/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3-sources.jar", + "https://maven.google.com/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3-sources.jar", + "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3-sources.jar" ], - "sha256": "bb339efebc2d9141401f1aa43a035abe929210e362cfff13d03c6b7b11dc0469", - "url": "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.1/kotlinx-coroutines-core-1.4.1-sources.jar" + "sha256": "315d99f5b340ceaba2cb898eff7e6414fd615b27e3f093b84ac13ac31c2f7dc0", + "url": "https://repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.4.3/kotlinx-coroutines-core-1.4.3-sources.jar" }, { "coord": "org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.2.2", @@ -9753,13 +9793,13 @@ { "coord": "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2", "dependencies": [ - "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1", "org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.2.2", - "org.jetbrains.kotlin:kotlin-stdlib:1.5.0" + "org.jetbrains.kotlin:kotlin-stdlib:1.5.0", + "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" ], "directDependencies": [ "org.jetbrains.kotlin:kotlin-stdlib:1.5.0", - "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1", + "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3", "org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.2.2" ], "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-test/1.2.2/kotlinx-coroutines-test-1.2.2.jar", @@ -9777,12 +9817,12 @@ "coord": "org.jetbrains.kotlinx:kotlinx-coroutines-test:jar:sources:1.2.2", "dependencies": [ "org.jetbrains.kotlin:kotlin-stdlib:jar:sources:1.5.0", - "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.1", + "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.3", "org.jetbrains.kotlinx:kotlinx-coroutines-debug:jar:sources:1.2.2" ], "directDependencies": [ "org.jetbrains.kotlin:kotlin-stdlib:jar:sources:1.5.0", - "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.1", + "org.jetbrains.kotlinx:kotlinx-coroutines-core:jar:sources:1.4.3", "org.jetbrains.kotlinx:kotlinx-coroutines-debug:jar:sources:1.2.2" ], "file": "v1/https/repo1.maven.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-test/1.2.2/kotlinx-coroutines-test-1.2.2-sources.jar", diff --git a/third_party/versions.bzl b/third_party/versions.bzl index 24195afce9e..e07eaec259e 100644 --- a/third_party/versions.bzl +++ b/third_party/versions.bzl @@ -76,7 +76,7 @@ MAVEN_PRODUCTION_DEPENDENCY_VERSIONS = { "org.checkerframework:checker-qual": "3.13.0", "org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar": "1.3.72", "org.jetbrains.kotlinx:kotlinx-coroutines-android": "1.4.1", - "org.jetbrains.kotlinx:kotlinx-coroutines-core": "1.4.1", + "org.jetbrains.kotlinx:kotlinx-coroutines-core": "1.4.3", "org.jetbrains:annotations:jar": "13.0", } From 3f69f11ced1150056ebf1e2cdc708f2ef8acd7e6 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 9 Feb 2024 23:27:15 +0000 Subject: [PATCH 20/21] Fix updated Maven license deps. --- scripts/assets/maven_dependencies.textproto | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/assets/maven_dependencies.textproto b/scripts/assets/maven_dependencies.textproto index 7305bccdd78..1477c40a73b 100644 --- a/scripts/assets/maven_dependencies.textproto +++ b/scripts/assets/maven_dependencies.textproto @@ -1017,8 +1017,19 @@ maven_dependency { } } maven_dependency { - artifact_name: "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1" - artifact_version: "1.4.1" + artifact_name: "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.3" + artifact_version: "1.4.3" + license { + license_name: "The Apache Software License, Version 2.0" + original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" + scrapable_link { + url: "https://www.apache.org/licenses/LICENSE-2.0.txt" + } + } +} +maven_dependency { + artifact_name: "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" + artifact_version: "1.4.3" license { license_name: "The Apache Software License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" From 2916770e765507917c24844f88830f591fcd7b4f Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 14 Feb 2024 12:24:01 -0800 Subject: [PATCH 21/21] Update scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt Co-authored-by: Adhiambo Peres <59600948+adhiamboperes@users.noreply.github.com> --- .../javatests/org/oppia/android/scripts/common/GitClientTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt index 5cbda509373..c3126339eca 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/GitClientTest.kt @@ -35,7 +35,7 @@ class GitClientTest { @After fun tearDown() { // Print the status of the git repository to help with debugging in the cases of test failures - // and to help manually verify the expect git state at the end of each test. + // and to help manually verify the expected git state at the end of each test. println("git status (at end of test):") println(testGitRepository.status(checkForGitRepository = false)) }