Skip to content

Commit

Permalink
Fix #2967 Refactor packages for services (#2970)
Browse files Browse the repository at this point in the history
* Move mocks and api util to testing module

* Remove completed explorations from data class

* Update fake JSON

* Add data objects for entry point

* Fix packages for services

* Fix JSON & data class to match

* Fix test package names & imports

* Revert "Remove completed explorations from data class"

This reverts commit 9c1b800.

* Revert "Update fake JSON"

This reverts commit ea0847a.

* Revert "Add data objects for entry point"

This reverts commit 445e320.

* Revert "Fix JSON & data class to match"

This reverts commit c9c0752.

* Remove extra data object changes

* Remove entry point data object

* Undo persistent cache store test change

* Move api utils to testing/network package
  • Loading branch information
jcqli authored Mar 25, 2021
1 parent f81d8a3 commit 6bf456a
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 65 deletions.
28 changes: 18 additions & 10 deletions data/src/test/assets/api_mocks/feedback_reporting.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
{
"api_key": "",
"app_context": {
"entry_point": "navigation_drawer",
"completed_exploration_ids": [
0,
1
],
"topic_progress": {},
"text_size": "large",
"text_lang": "EN",
"audio_lang": "EN",
"download_and_update_only_on_wifi": true,
"automatically_update_topics": false,
"is_admin": false
"is_admin": false,
"event_logs": [
"example",
"event"
],
"logcat_logs": [
"example",
"log"
]
},
"device_context": {
"device_model": "example_model",
"sdk_version": 23,
"device_brand": "example_brand",
"build_fingerprint": "example_fingerprint_id",
"phone_type": "telephony_network_type",
"network_type": "wifi",
"device_lang": "EN"
"network_type": "wifi"
},
"report_creation_timestamp": 1610519337000,
"report_creation_timestamp_ms": 1610519337000,
"system_context": {
"package_name": "example.package.name",
"package_code": "example_version_code",
"version_name": "0.1-alpha-abcdef1234",
"package_version_code": 1,
"country_locale": "IN",
"language_locale": "EN"
},
"user_feedback": {
"user_supplied_feedback": {
"report_type": "suggestion",
"category": "language_suggestion",
"feedback_list": [],
"user_input": "french"
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.oppia.android.data.backends.test
package org.oppia.android.data.backends.gae

import android.app.Application
import androidx.test.core.app.ApplicationProvider
Expand All @@ -11,10 +11,8 @@ import dagger.Provides
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.data.backends.ApiUtils
import org.oppia.android.data.backends.api.MockTopicService
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkModule
import org.oppia.android.testing.network.ApiUtils
import org.oppia.android.testing.network.MockTopicService
import org.robolectric.annotation.LooperMode
import retrofit2.Retrofit
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.oppia.android.data.backends.test
package org.oppia.android.data.backends.gae.api

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import okhttp3.OkHttpClient
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.data.backends.api.MockClassroomService
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.ClassroomService
import org.oppia.android.testing.network.MockClassroomService
import org.robolectric.annotation.LooperMode
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
Expand All @@ -21,7 +20,7 @@ import retrofit2.mock.NetworkBehavior
*/
@RunWith(AndroidJUnit4::class)
@LooperMode(LooperMode.Mode.PAUSED)
class MockClassroomTest {
class ClassroomServiceTest {
private lateinit var mockRetrofit: MockRetrofit
private lateinit var retrofit: Retrofit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.oppia.android.data.backends.test
package org.oppia.android.data.backends.gae.api

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import okhttp3.OkHttpClient
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.data.backends.api.MockConceptCardService
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.ConceptCardService
import org.oppia.android.testing.network.MockConceptCardService
import org.robolectric.annotation.LooperMode
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
Expand All @@ -21,7 +20,7 @@ import retrofit2.mock.NetworkBehavior
*/
@RunWith(AndroidJUnit4::class)
@LooperMode(LooperMode.Mode.PAUSED)
class MockConceptCardTest {
class ConceptCardServiceTest {
private lateinit var mockRetrofit: MockRetrofit
private lateinit var retrofit: Retrofit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.oppia.android.data.backends.test
package org.oppia.android.data.backends.gae.api

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import okhttp3.OkHttpClient
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.data.backends.api.MockExplorationService
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.ExplorationService
import org.oppia.android.testing.network.MockExplorationService
import org.robolectric.annotation.LooperMode
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
Expand All @@ -21,7 +20,7 @@ import retrofit2.mock.NetworkBehavior
*/
@RunWith(AndroidJUnit4::class)
@LooperMode(LooperMode.Mode.PAUSED)
class MockExplorationTest {
class ExplorationServiceTest {
private lateinit var mockRetrofit: MockRetrofit
private lateinit var retrofit: Retrofit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.oppia.android.data.backends.test
package org.oppia.android.data.backends.gae.api

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
Expand All @@ -8,12 +8,11 @@ import okhttp3.OkHttpClient
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.data.backends.ApiUtils
import org.oppia.android.data.backends.api.MockFeedbackReportingService
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.FeedbackReportingService
import org.oppia.android.data.backends.gae.model.GaeFeedbackReport
import org.oppia.android.testing.network.ApiUtils
import org.oppia.android.testing.network.MockFeedbackReportingService
import org.robolectric.annotation.LooperMode
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
Expand All @@ -23,7 +22,7 @@ import retrofit2.mock.NetworkBehavior
/** Test for [FeedbackReportingService] retrofit instance using a [MockFeedbackReportingService]. */
@RunWith(AndroidJUnit4::class)
@LooperMode(LooperMode.Mode.PAUSED)
class MockFeedbackReportingTest {
class FeedbackReportingServiceTest {
private lateinit var mockRetrofit: MockRetrofit
private lateinit var retrofit: Retrofit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.oppia.android.data.backends.test
package org.oppia.android.data.backends.gae.api

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import okhttp3.OkHttpClient
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.data.backends.api.MockQuestionPlayerService
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.QuestionPlayerService
import org.oppia.android.testing.network.MockQuestionPlayerService
import org.robolectric.annotation.LooperMode
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
Expand All @@ -21,7 +20,7 @@ import retrofit2.mock.NetworkBehavior
*/
@RunWith(AndroidJUnit4::class)
@LooperMode(LooperMode.Mode.PAUSED)
class MockQuestionPlayerTest {
class QuestionPlayerServiceTest {
private lateinit var mockRetrofit: MockRetrofit
private lateinit var retrofit: Retrofit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.oppia.android.data.backends.test
package org.oppia.android.data.backends.gae.api

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import okhttp3.OkHttpClient
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.data.backends.api.MockStoryService
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.StoryService
import org.oppia.android.testing.network.MockStoryService
import org.robolectric.annotation.LooperMode
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
Expand All @@ -21,7 +20,7 @@ import retrofit2.mock.NetworkBehavior
*/
@RunWith(AndroidJUnit4::class)
@LooperMode(LooperMode.Mode.PAUSED)
class MockStoryTest {
class StoryServiceTest {
private lateinit var mockRetrofit: MockRetrofit
private lateinit var retrofit: Retrofit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.oppia.android.data.backends.test
package org.oppia.android.data.backends.gae.api

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import okhttp3.OkHttpClient
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.data.backends.api.MockSubtopicService
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.SubtopicService
import org.oppia.android.testing.network.MockSubtopicService
import org.robolectric.annotation.LooperMode
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
Expand All @@ -21,7 +20,7 @@ import retrofit2.mock.NetworkBehavior
*/
@RunWith(AndroidJUnit4::class)
@LooperMode(LooperMode.Mode.PAUSED)
class MockSubtopicTest {
class SubtopicServiceTest {
private lateinit var mockRetrofit: MockRetrofit
private lateinit var retrofit: Retrofit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.oppia.android.data.backends.test
package org.oppia.android.data.backends.gae.api

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import okhttp3.OkHttpClient
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.android.data.backends.api.MockTopicService
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.TopicService
import org.oppia.android.testing.network.MockTopicService
import org.robolectric.annotation.LooperMode
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
Expand All @@ -21,7 +20,7 @@ import retrofit2.mock.NetworkBehavior
*/
@RunWith(AndroidJUnit4::class)
@LooperMode(LooperMode.Mode.PAUSED)
class MockTopicTest {
class TopicServiceTest {
private lateinit var mockRetrofit: MockRetrofit
private lateinit var retrofit: Retrofit

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.oppia.android.data.backends
package org.oppia.android.testing.network

import org.json.JSONException
import org.json.JSONObject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.oppia.android.data.backends.api
package org.oppia.android.testing.network

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import org.oppia.android.data.backends.ApiUtils
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.ClassroomService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.oppia.android.data.backends.api
package org.oppia.android.testing.network

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import org.oppia.android.data.backends.ApiUtils
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.ConceptCardService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.oppia.android.data.backends.api
package org.oppia.android.testing.network

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import org.oppia.android.data.backends.ApiUtils
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.ExplorationService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.oppia.android.data.backends.api
package org.oppia.android.testing.network

import org.oppia.android.data.backends.gae.api.FeedbackReportingService
import org.oppia.android.data.backends.gae.model.GaeFeedbackReport
import retrofit2.Call
import retrofit2.mock.BehaviorDelegate

/** Mock FeedbackReportingService to check that the service is properly requested. */
/** Mock [FeedbackReportingService] to check that the service is properly requested. */
class MockFeedbackReportingService(
private val delegate: BehaviorDelegate<FeedbackReportingService>
) : FeedbackReportingService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.oppia.android.data.backends.api
package org.oppia.android.testing.network

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import org.oppia.android.data.backends.ApiUtils
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.QuestionPlayerService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.oppia.android.data.backends.api
package org.oppia.android.testing.network

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import org.oppia.android.data.backends.ApiUtils
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.StoryService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.oppia.android.data.backends.api
package org.oppia.android.testing.network

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import org.oppia.android.data.backends.ApiUtils
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.SubtopicService
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.oppia.android.data.backends.api
package org.oppia.android.testing.network

import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import org.oppia.android.data.backends.ApiUtils
import org.oppia.android.data.backends.gae.NetworkInterceptor
import org.oppia.android.data.backends.gae.NetworkSettings
import org.oppia.android.data.backends.gae.api.TopicService
Expand Down

0 comments on commit 6bf456a

Please sign in to comment.