-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #5: GAE Abstraction part 1 - Topic Page handler [Blocked: #85] #78
Merged
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
7269d15
Initial introduction of the data source module.
BenHenning ac16d10
Data module dependencies, retrofit and models
bf96010
Removed kapt from build.gradle in data
ef62740
Javadoc comments
93d703b
Introduce one possible integration with Dagger 2.
BenHenning 3679c4c
Javadoc comments added
a4e0ad5
Reolved Javadoc mistakes
d187b56
Update build.gradle proto directive to use 'compile' instead of (#81)
d27d161
Merge remote-tracking branch 'upstream/introduce-data-module' into ga…
5d5da22
Renaming test cases
07b51d5
Test cases for TopicService
a52bb57
Made changes to OppiaGaeClient
1d6c39b
Made changes to OppiaGaeClient
b476e8e
TopicService test code using Json response
4aadf7a
Revert changes in codeStyles/Project.xml
d03a527
Revert changes in codeStyles/Project.xml
a380eaa
Optimise imports
1da9475
Check NetworkInterceptor part
842dc21
Fix part of #9: Introduce Retrofit classroom data handler service (#83)
veena14cs ffde992
Resolve typo
f5ae749
Merge branch 'gae-abstraction-base' of https://github.com/oppia/oppia…
0049548
Resolve merge conflicts with develop branch
cd94945
NetworkModule introduced
e392406
Daggerify NetworkInterceptor
5eccceb
Make retrofit dependency as api
1751f36
Javadocs and linking of oppia-web to models
798cf41
Changes in Javadoc, naming and test cases code
80249a8
Merge remote-tracking branch 'upstream/develop' into gae-abstraction-…
bb62037
Updated TODO comments and NetworkInterceptorTest
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
TopicService test code using Json response
- Loading branch information
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.oppia.data | ||
|
||
import org.oppia.data.backends.gae.NetworkSettings | ||
|
||
/** An object that contains fake json responses for test cases */ | ||
object FakeJsonResponse { | ||
|
||
/** Dummy json response with XSSI Prfix for [NetworkInterceptorTest] */ | ||
const val DUMMY_RESPONSE_WITH_XSSI_PREFIX: String = NetworkSettings.XSSI_PREFIX + "\n" + "{\"is_valid_response\": true}" | ||
/** Dummy json response without XSSI Prfix for [NetworkInterceptorTest] */ | ||
const val DUMMY_RESPONSE_WITHOUT_XSSI_PREFIX: String = "{\"is_valid_response\": true}" | ||
/** Fake json response for [MockTopicService] */ | ||
const val TOPIC_SERVICE_RESPONSE: String = "{\"canonical_story_dicts\":[{\"title\":\"Story 1\",\"description\":\"Story Description\",\"id\":\"4wv9hSZ4F67I\"}],\"is_moderator\":true,\"is_admin\":true,\"topic_name\":\"Topic1\",\"username\":\"rt4914\",\"skill_descriptions\":{\"A9j9taXAqqkV\":\"Skill 1\"},\"user_email\":\"test@example.com\",\"iframed\":false,\"additional_story_dicts\":[],\"additional_angular_modules\":[],\"is_topic_manager\":false,\"uncategorized_skill_ids\":[],\"topic_id\":\"baWJOUFeUAnn\",\"degrees_of_mastery\":{\"A9j9taXAqqkV\":null},\"subtopics\":[{\"skill_ids\":[\"A9j9taXAqqkV\"],\"title\":\"Subtopic 1\",\"id\":1}],\"is_super_admin\":true}" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
package org.oppia.data | ||
|
||
import com.squareup.moshi.JsonAdapter | ||
import com.squareup.moshi.Moshi | ||
import org.oppia.data.backends.gae.api.TopicService | ||
import org.oppia.data.backends.gae.model.GaeTopic | ||
import retrofit2.Call | ||
import retrofit2.mock.BehaviorDelegate | ||
|
||
/** | ||
* Mock TopicService with dummy data | ||
* Mock TopicService with dummy data from [FakeJsonResponse] | ||
*/ | ||
class MockTopicService(private val delegate: BehaviorDelegate<TopicService>) : TopicService { | ||
override fun getTopicByName(topicName: String): Call<GaeTopic> { | ||
val topic = GaeTopic( | ||
"1", | ||
"Test Topic", | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
null | ||
) | ||
return delegate.returningResponse(topic).getTopicByName("Test Topic") | ||
val topic = MockGaeTopic() | ||
return delegate.returningResponse(topic).getTopicByName(topicName) | ||
} | ||
} | ||
|
||
private fun MockGaeTopic(): Any? { | ||
val jsonResponse: String = FakeJsonResponse.TOPIC_SERVICE_RESPONSE | ||
|
||
val moshi = Moshi.Builder().build() | ||
val adapter: JsonAdapter<GaeTopic> = moshi.adapter(GaeTopic::class.java) | ||
val mockGaeTopic = adapter.fromJson(jsonResponse) | ||
|
||
return mockGaeTopic!! | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? I thought this is implied in Kotlin since it doesn't require using checked exceptions. I thought this only serves to set Kotlin methods up for Java use, but in this case I believe JUnit methods are called reflectively and are assumed to throw exceptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did search this on internet but haven't found a proper answer for this. I have seen different resources which uses this and there are some resources which do not use this.
Even I am not sure, whether we actually need this or not.