mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-01 15:23:54 +01:00
Issue-5662-kotlinstyle (#5833)
* *.kt: bulk correction of formatting using ktlint --format * *.kt: replace wildcard imports and second stage auto format ktlint --format * QuizQuestionTest.kt: modified property names to camel case to meet ktlint standard * LevelControllerTest.kt: modified property names to camel case to meet ktlint standard * QuizActivityUnitTest.kt: modified property names to camel case to meet ktlint standard * MediaDetailFragmentUnitTests.kt: modified property names to camel case to meet ktlint standard * UploadWorker.kt: modified property names to camel case to meet ktlint standard * UploadClient.kt: modified property names to camel case to meet ktlint standard * BasePagingPresenter.kt: modified property names to camel case to meet ktlint standard * DescriptionEditActivity.kt: modified property names to camel case to meet ktlint standard * OnSwipeTouchListener.kt: modified property names to camel case to meet ktlint standard * MediaDetailFragmentUnitTests.kt: corrected excessive line length to meet ktlint standard * DepictedItem.kt: corrected property name format and catch format to for ktlint standard * UploadCategoryAdapter.kt: corrected class definition format to meet ktlint standard * CustomSelectorActivity.kt: reformatted function names to first letter lowercase to meet ktlint standard * MediaDetailFragmentUnitTests.kt: fix string literal indentation to meet ktlint standard * NotForUploadDao.kt: file renamed to match class name, new file NotForUploadStatusDao.kt * UploadedDao.kt: file renamed to match class name, new file UploadedStatusDao.kt * Urls.kt: fixed excessive line length for ktLint standard * Snak_partial.kt & Statement_partial.kt: refactored to remove underscores in class names to meet ktLint standard * *.kt: fixed consecutive KDOC error for ktLint * PageableBaseDataSourceTest.kt & UploadPresenterTest.kt: fixed excessive line lengths to meet ktLint standard * CheckboxTriStatesTest.kt: renamed file to match class name to meet ktLint standard * .kt: resolved backing-property-naming error in ktLint, made matching properties public, matched names and refactored * TestConnectionFactory.kt: fixed property naming to adhere to ktLint standard
This commit is contained in:
parent
950539c55c
commit
2d82a430c4
405 changed files with 11032 additions and 9137 deletions
|
|
@ -14,7 +14,6 @@ import org.robolectric.annotation.Config
|
|||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||
class AccountUtilUnitTest {
|
||||
|
||||
private lateinit var context: FakeContextWrapper
|
||||
private lateinit var accountUtil: AccountUtil
|
||||
|
||||
|
|
@ -58,4 +57,4 @@ class AccountUtilUnitTest {
|
|||
FakeContextWrapperWithException(ApplicationProvider.getApplicationContext())
|
||||
Assert.assertEquals(AccountUtil.account(context), null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import androidx.test.core.app.ApplicationProvider
|
|||
import fr.free.nrw.commons.OkHttpConnectionFactory
|
||||
import fr.free.nrw.commons.R
|
||||
import fr.free.nrw.commons.TestCommonsApplication
|
||||
import fr.free.nrw.commons.createTestClient
|
||||
import fr.free.nrw.commons.auth.login.LoginResult
|
||||
import fr.free.nrw.commons.createTestClient
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
|
|
@ -30,11 +30,9 @@ import org.robolectric.annotation.Config
|
|||
import org.robolectric.fakes.RoboMenuItem
|
||||
import java.lang.reflect.Method
|
||||
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||
class LoginActivityUnitTests {
|
||||
|
||||
private lateinit var menuItem: MenuItem
|
||||
private lateinit var context: Context
|
||||
|
||||
|
|
@ -92,12 +90,13 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnEditorActionCaseDefault() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onEditorAction",
|
||||
TextView::class.java,
|
||||
Int::class.java,
|
||||
KeyEvent::class.java
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"onEditorAction",
|
||||
TextView::class.java,
|
||||
Int::class.java,
|
||||
KeyEvent::class.java,
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity, textView, 0, keyEvent)
|
||||
}
|
||||
|
|
@ -105,9 +104,10 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testSkipLogin() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"skipLogin"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"skipLogin",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
@ -115,9 +115,10 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testForgotPassword() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"forgotPassword"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"forgotPassword",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
@ -125,9 +126,10 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnPrivacyPolicyClicked() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onPrivacyPolicyClicked"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"onPrivacyPolicyClicked",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
@ -135,9 +137,10 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testSignUp() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"signUp"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"signUp",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
@ -145,10 +148,11 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnPostCreate() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onPostCreate",
|
||||
Bundle::class.java
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"onPostCreate",
|
||||
Bundle::class.java,
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity, bundle)
|
||||
}
|
||||
|
|
@ -157,9 +161,10 @@ class LoginActivityUnitTests {
|
|||
@Throws(Exception::class)
|
||||
fun testOnDestroy() {
|
||||
`when`(progressDialog.isShowing).thenReturn(true)
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onDestroy"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"onDestroy",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
@ -168,9 +173,10 @@ class LoginActivityUnitTests {
|
|||
@Throws(Exception::class)
|
||||
fun testOnDestroyWithException() {
|
||||
`when`(progressDialog.isShowing).thenThrow(NullPointerException())
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onDestroy"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"onDestroy",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
@ -178,10 +184,11 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnLoginSuccessCaseDefault() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onLoginSuccess",
|
||||
LoginResult::class.java
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"onLoginSuccess",
|
||||
LoginResult::class.java,
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity, loginResult)
|
||||
}
|
||||
|
|
@ -190,10 +197,11 @@ class LoginActivityUnitTests {
|
|||
@Throws(Exception::class)
|
||||
fun testOnLoginSuccess() {
|
||||
`when`(progressDialog.isShowing).thenReturn(true)
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onLoginSuccess",
|
||||
LoginResult::class.java
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"onLoginSuccess",
|
||||
LoginResult::class.java,
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity, loginResult)
|
||||
}
|
||||
|
|
@ -201,9 +209,10 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testShowPasswordResetPrompt() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"showPasswordResetPrompt"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"showPasswordResetPrompt",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
@ -211,9 +220,10 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testHideProgress() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"hideProgress"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"hideProgress",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
@ -225,9 +235,10 @@ class LoginActivityUnitTests {
|
|||
`when`(applicationKvStore.getBoolean("login_skipped", false)).thenReturn(true)
|
||||
`when`(sessionManager.currentAccount).thenReturn(account)
|
||||
`when`(sessionManager.isUserLoggedIn).thenReturn(true)
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onResume"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"onResume",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
@ -235,9 +246,10 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnStart() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onStart"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"onStart",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
@ -245,9 +257,10 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnStop() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onStop"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"onStop",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
@ -255,9 +268,10 @@ class LoginActivityUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testOnPostResume() {
|
||||
val method: Method = LoginActivity::class.java.getDeclaredMethod(
|
||||
"onPostResume"
|
||||
)
|
||||
val method: Method =
|
||||
LoginActivity::class.java.getDeclaredMethod(
|
||||
"onPostResume",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(activity)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,12 +20,10 @@ import org.robolectric.annotation.Config
|
|||
import org.robolectric.annotation.LooperMode
|
||||
import java.lang.reflect.Method
|
||||
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||
@LooperMode(LooperMode.Mode.PAUSED)
|
||||
class SessionManagerUnitTests {
|
||||
|
||||
private lateinit var sessionManager: SessionManager
|
||||
private lateinit var accountManager: AccountManager
|
||||
|
||||
|
|
@ -59,9 +57,10 @@ class SessionManagerUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testRemoveAccountCaseNull() {
|
||||
val method: Method = SessionManager::class.java.getDeclaredMethod(
|
||||
"removeAccount"
|
||||
)
|
||||
val method: Method =
|
||||
SessionManager::class.java.getDeclaredMethod(
|
||||
"removeAccount",
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(sessionManager)
|
||||
}
|
||||
|
|
@ -71,10 +70,11 @@ class SessionManagerUnitTests {
|
|||
fun testUpdateAccount() {
|
||||
`when`(loginResult.userName).thenReturn("username")
|
||||
`when`(loginResult.password).thenReturn("password")
|
||||
val method: Method = SessionManager::class.java.getDeclaredMethod(
|
||||
"updateAccount",
|
||||
LoginResult::class.java
|
||||
)
|
||||
val method: Method =
|
||||
SessionManager::class.java.getDeclaredMethod(
|
||||
"updateAccount",
|
||||
LoginResult::class.java,
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(sessionManager, loginResult)
|
||||
}
|
||||
|
|
@ -118,11 +118,12 @@ class SessionManagerUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testCreateAccount() {
|
||||
val method: Method = SessionManager::class.java.getDeclaredMethod(
|
||||
"createAccount",
|
||||
String::class.java,
|
||||
String::class.java
|
||||
)
|
||||
val method: Method =
|
||||
SessionManager::class.java.getDeclaredMethod(
|
||||
"createAccount",
|
||||
String::class.java,
|
||||
String::class.java,
|
||||
)
|
||||
method.isAccessible = true
|
||||
Assert.assertEquals(method.invoke(sessionManager, "username", "password"), true)
|
||||
}
|
||||
|
|
@ -130,10 +131,11 @@ class SessionManagerUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testSetUserLoggedIn() {
|
||||
val method: Method = SessionManager::class.java.getDeclaredMethod(
|
||||
"setUserLoggedIn",
|
||||
Boolean::class.java
|
||||
)
|
||||
val method: Method =
|
||||
SessionManager::class.java.getDeclaredMethod(
|
||||
"setUserLoggedIn",
|
||||
Boolean::class.java,
|
||||
)
|
||||
method.isAccessible = true
|
||||
method.invoke(sessionManager, true)
|
||||
}
|
||||
|
|
@ -141,9 +143,10 @@ class SessionManagerUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testGetUserName() {
|
||||
val method: Method = SessionManager::class.java.getDeclaredMethod(
|
||||
"getUserName"
|
||||
)
|
||||
val method: Method =
|
||||
SessionManager::class.java.getDeclaredMethod(
|
||||
"getUserName",
|
||||
)
|
||||
method.isAccessible = true
|
||||
Assert.assertEquals(method.invoke(sessionManager), null)
|
||||
}
|
||||
|
|
@ -151,11 +154,11 @@ class SessionManagerUnitTests {
|
|||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun testGetPassword() {
|
||||
val method: Method = SessionManager::class.java.getDeclaredMethod(
|
||||
"getPassword"
|
||||
)
|
||||
val method: Method =
|
||||
SessionManager::class.java.getDeclaredMethod(
|
||||
"getPassword",
|
||||
)
|
||||
method.isAccessible = true
|
||||
Assert.assertEquals(method.invoke(sessionManager), null)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,11 +14,9 @@ import org.robolectric.Robolectric
|
|||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||
class SignupActivityTest {
|
||||
|
||||
private lateinit var activity: SignupActivity
|
||||
|
||||
@Mock
|
||||
|
|
@ -49,4 +47,4 @@ class SignupActivityTest {
|
|||
`when`(webView.canGoBack()).thenReturn(true)
|
||||
activity.onBackPressed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import org.mockito.MockitoAnnotations
|
|||
import java.lang.reflect.Field
|
||||
|
||||
class WikiAccountAuthenticatorServiceUnitTest {
|
||||
|
||||
private lateinit var service: WikiAccountAuthenticatorService
|
||||
|
||||
@Before
|
||||
|
|
@ -30,5 +29,4 @@ class WikiAccountAuthenticatorServiceUnitTest {
|
|||
field.set(service, null)
|
||||
Assert.assertEquals(service.onBind(null), null)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import org.robolectric.annotation.LooperMode
|
|||
@Config(sdk = [21], application = TestCommonsApplication::class)
|
||||
@LooperMode(LooperMode.Mode.PAUSED)
|
||||
class WikiAccountAuthenticatorUnitTest {
|
||||
|
||||
private lateinit var context: Context
|
||||
private lateinit var authenticator: WikiAccountAuthenticator
|
||||
|
||||
|
|
@ -64,7 +63,7 @@ class WikiAccountAuthenticatorUnitTest {
|
|||
val intent: Intent? = bundle.getParcelable(AccountManager.KEY_INTENT)
|
||||
Assert.assertEquals(
|
||||
intent?.extras!![AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE],
|
||||
response
|
||||
response,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +88,7 @@ class WikiAccountAuthenticatorUnitTest {
|
|||
fun testGetAuthTokenLabelCaseNonNull() {
|
||||
Assert.assertEquals(
|
||||
authenticator.getAuthTokenLabel(BuildConfig.ACCOUNT_TYPE),
|
||||
AccountUtil.AUTH_TOKEN_TYPE
|
||||
AccountUtil.AUTH_TOKEN_TYPE,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -110,5 +109,4 @@ class WikiAccountAuthenticatorUnitTest {
|
|||
val bundle: Bundle? = authenticator.getAccountRemovalAllowed(response, account)
|
||||
Assert.assertEquals(bundle?.getBoolean(AccountManager.KEY_BOOLEAN_RESULT), true)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ package fr.free.nrw.commons.auth.csrf
|
|||
|
||||
import com.google.gson.stream.MalformedJsonException
|
||||
import fr.free.nrw.commons.MockWebServerTest
|
||||
import fr.free.nrw.commons.OkHttpConnectionFactory.HttpStatusException
|
||||
import fr.free.nrw.commons.auth.SessionManager
|
||||
import fr.free.nrw.commons.auth.login.LoginClient
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwException
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers.any
|
||||
import org.mockito.ArgumentMatchers.eq
|
||||
|
|
@ -11,8 +13,6 @@ import org.mockito.ArgumentMatchers.isA
|
|||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.verify
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwException
|
||||
import fr.free.nrw.commons.OkHttpConnectionFactory.HttpStatusException
|
||||
|
||||
class CsrfTokenClientTest : MockWebServerTest() {
|
||||
private val cb = mock(CsrfTokenClient.Callback::class.java)
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@ import android.net.Uri
|
|||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.stream.MalformedJsonException
|
||||
import fr.free.nrw.commons.MockWebServerTest
|
||||
import io.reactivex.observers.TestObserver
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import fr.free.nrw.commons.wikidata.model.WikiSite
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwQueryResponse
|
||||
import fr.free.nrw.commons.wikidata.json.NamespaceTypeAdapter
|
||||
import fr.free.nrw.commons.wikidata.json.PostProcessingTypeAdapter
|
||||
import fr.free.nrw.commons.wikidata.json.UriTypeAdapter
|
||||
import fr.free.nrw.commons.wikidata.json.WikiSiteTypeAdapter
|
||||
import fr.free.nrw.commons.wikidata.model.WikiSite
|
||||
import fr.free.nrw.commons.wikidata.model.page.Namespace
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwQueryResponse
|
||||
import io.reactivex.observers.TestObserver
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
|
|
@ -21,29 +21,36 @@ import retrofit2.converter.gson.GsonConverterFactory
|
|||
class UserExtendedInfoClientTest : MockWebServerTest() {
|
||||
private var apiService: LoginInterface? = null
|
||||
private val observer = TestObserver<MwQueryResponse>()
|
||||
private val gson = GsonBuilder()
|
||||
.registerTypeHierarchyAdapter(Uri::class.java, UriTypeAdapter()
|
||||
.nullSafe())
|
||||
.registerTypeHierarchyAdapter(
|
||||
Namespace::class.java, NamespaceTypeAdapter()
|
||||
.nullSafe())
|
||||
.registerTypeAdapter(
|
||||
WikiSite::class.java, WikiSiteTypeAdapter()
|
||||
.nullSafe())
|
||||
.registerTypeAdapterFactory(PostProcessingTypeAdapter())
|
||||
.create()
|
||||
private val gson =
|
||||
GsonBuilder()
|
||||
.registerTypeHierarchyAdapter(
|
||||
Uri::class.java,
|
||||
UriTypeAdapter()
|
||||
.nullSafe(),
|
||||
).registerTypeHierarchyAdapter(
|
||||
Namespace::class.java,
|
||||
NamespaceTypeAdapter()
|
||||
.nullSafe(),
|
||||
).registerTypeAdapter(
|
||||
WikiSite::class.java,
|
||||
WikiSiteTypeAdapter()
|
||||
.nullSafe(),
|
||||
).registerTypeAdapterFactory(PostProcessingTypeAdapter())
|
||||
.create()
|
||||
|
||||
@Before
|
||||
@Throws(Throwable::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
|
||||
apiService = Retrofit.Builder()
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.baseUrl(server().url)
|
||||
.build()
|
||||
.create(LoginInterface::class.java)
|
||||
apiService =
|
||||
Retrofit
|
||||
.Builder()
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
.addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.baseUrl(server().url)
|
||||
.build()
|
||||
.create(LoginInterface::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -57,9 +64,14 @@ class UserExtendedInfoClientTest : MockWebServerTest() {
|
|||
.assertComplete()
|
||||
.assertNoErrors()
|
||||
.assertValue { result: MwQueryResponse ->
|
||||
result.query()!!
|
||||
.userInfo()!!.id() == 24531888 && result.query()!!.getUserResponse("USER")!!
|
||||
.name() == "USER"
|
||||
result
|
||||
.query()!!
|
||||
.userInfo()!!
|
||||
.id() == 24531888 &&
|
||||
result
|
||||
.query()!!
|
||||
.getUserResponse("USER")!!
|
||||
.name() == "USER"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue