Skip to content

Commit

Permalink
Swapi url update. Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sreeharikv112 committed May 25, 2020
1 parent f606b81 commit 2820a8b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {
versionName "1.0"
testInstrumentationRunner "com.dev.ccodetest.app.CustomInstrumentationRunner"
multiDexEnabled true
buildConfigField "String", "BASE_URL", "\"https://swapi.co/api/\""
buildConfigField "String", "BASE_URL", "\"https://swapi.dev/api/\""
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package com.dev.ccodetest.platform
/**
* Custom result object.
*/
class LiveDataWrapper<T>(val responseRESPONSESTATUS: RESPONSESTATUS, val response: T? = null, val error: Throwable? = null) {
class LiveDataWrapper<T>(
val responseStatus: RESPONSESTATUS,
val response: T? = null,
val error: Throwable? = null
) {

enum class RESPONSESTATUS {
SUCCESS, LOADING, ERROR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import android.view.View
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.dev.ccodetest.R
import com.dev.ccodetest.models.login.AllPeople
import com.dev.ccodetest.models.login.AllPeopleResult
Expand Down Expand Up @@ -62,7 +61,7 @@ class LoginActivityFragment : BaseFragment() {

//---------------Observers---------------//
private val mDataObserver = Observer<LiveDataWrapper<AllPeople>> { result ->
when (result?.responseRESPONSESTATUS) {
when (result?.responseStatus) {
LiveDataWrapper.RESPONSESTATUS.LOADING -> {
// Loading data
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/test/java/com/dev/ccodetest/base/BaseUTTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ abstract class BaseUTTest : KoinTest {
* Reads input file and converts to json
*/
fun getJson(path : String) : String {
val uri = javaClass.classLoader.getResource(path)
val uri = javaClass.classLoader!!.getResource(path)
val file = File(uri.path)
return String(file.readBytes())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class LoginActivityViewModelTest: BaseUTTest(){
mLoginActivityViewModel.requestLoginActivityData(mParam)

assert(mLoginActivityViewModel.mAllPeopleResponse.value != null)
assert(mLoginActivityViewModel.mAllPeopleResponse.value!!.responseRESPONSESTATUS
assert(
mLoginActivityViewModel.mAllPeopleResponse.value!!.responseStatus
== LiveDataWrapper.RESPONSESTATUS.SUCCESS)
val testResult = mLoginActivityViewModel.mAllPeopleResponse.value as LiveDataWrapper<AllPeople>
assertEquals(testResult.response!!.next,mNextValue)
Expand Down

0 comments on commit 2820a8b

Please sign in to comment.