mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Convert mwapi/wikidata to kotlin (part 1) (#5991)
* Convert OkHttpJsonApiClient and CategoryApi to kotlin * Convert GsonUtil to kotlin * Convert WikidataConstants to kotlin * Convert WikidataEditListener to kotlin * Convert WikidataEditService to kotlin * work in progress * Convert RequiredFieldsCheckOnReadTypeAdapterFactory to kotlin * Converted type adapters * Convert WikiSiteTypeAdapter to kotlin * Fixed nullability
This commit is contained in:
parent
9dd504e560
commit
3777f18bf9
41 changed files with 1490 additions and 1746 deletions
|
|
@ -69,7 +69,7 @@ public abstract class MockWebServerTest {
|
|||
.baseUrl(url)
|
||||
.callbackExecutor(new ImmediateExecutor())
|
||||
.client(okHttpClient)
|
||||
.addConverterFactory(GsonConverterFactory.create(GsonUtil.getDefaultGson()))
|
||||
.addConverterFactory(GsonConverterFactory.create(GsonUtil.INSTANCE.getDefaultGson()))
|
||||
.build()
|
||||
.create(clazz);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,13 +49,13 @@ class CampaignsPresenterTest {
|
|||
campaignsSingle = Single.just(campaignResponseDTO)
|
||||
campaignsPresenter = CampaignsPresenter(okHttpJsonApiClient, testScheduler, testScheduler)
|
||||
campaignsPresenter.onAttachView(view)
|
||||
Mockito.`when`(okHttpJsonApiClient.campaigns).thenReturn(campaignsSingle)
|
||||
Mockito.`when`(okHttpJsonApiClient.getCampaigns()).thenReturn(campaignsSingle)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getCampaignsTestNoCampaigns() {
|
||||
campaignsPresenter.getCampaigns()
|
||||
verify(okHttpJsonApiClient).campaigns
|
||||
verify(okHttpJsonApiClient).getCampaigns()
|
||||
testScheduler.triggerActions()
|
||||
verify(view).showCampaigns(null)
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ class CampaignsPresenterTest {
|
|||
Mockito.`when`(campaign.endDate).thenReturn(endDateString)
|
||||
Mockito.`when`(campaign.startDate).thenReturn(startDateString)
|
||||
Mockito.`when`(campaignResponseDTO.campaigns).thenReturn(campaigns)
|
||||
verify(okHttpJsonApiClient).campaigns
|
||||
verify(okHttpJsonApiClient).getCampaigns()
|
||||
testScheduler.triggerActions()
|
||||
verify(view).showCampaigns(campaign)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ class UserClientTest {
|
|||
|
||||
@Test
|
||||
fun isUserBlockedFromCommonsForInfinitelyBlockedUser() {
|
||||
val userInfo = Mockito.mock(UserInfo::class.java)
|
||||
Mockito.`when`(userInfo.blockexpiry()).thenReturn("infinite")
|
||||
val userInfo = UserInfo(blockexpiry = "infinite")
|
||||
val mwQueryResult = Mockito.mock(MwQueryResult::class.java)
|
||||
Mockito.`when`(mwQueryResult.userInfo()).thenReturn(userInfo)
|
||||
val mockResponse = Mockito.mock(MwQueryResponse::class.java)
|
||||
|
|
@ -49,8 +48,7 @@ class UserClientTest {
|
|||
val currentDate = Date()
|
||||
val expiredDate = Date(currentDate.time + 10000)
|
||||
|
||||
val userInfo = Mockito.mock(UserInfo::class.java)
|
||||
Mockito.`when`(userInfo.blockexpiry()).thenReturn(DateUtil.iso8601DateFormat(expiredDate))
|
||||
val userInfo = UserInfo(blockexpiry = DateUtil.iso8601DateFormat(expiredDate))
|
||||
val mwQueryResult = Mockito.mock(MwQueryResult::class.java)
|
||||
Mockito.`when`(mwQueryResult.userInfo()).thenReturn(userInfo)
|
||||
val mockResponse = Mockito.mock(MwQueryResponse::class.java)
|
||||
|
|
@ -65,8 +63,7 @@ class UserClientTest {
|
|||
|
||||
@Test
|
||||
fun isUserBlockedFromCommonsForNeverBlockedUser() {
|
||||
val userInfo = Mockito.mock(UserInfo::class.java)
|
||||
Mockito.`when`(userInfo.blockexpiry()).thenReturn("")
|
||||
val userInfo = UserInfo(blockexpiry = "")
|
||||
val mwQueryResult = Mockito.mock(MwQueryResult::class.java)
|
||||
Mockito.`when`(mwQueryResult.userInfo()).thenReturn(userInfo)
|
||||
val mockResponse = Mockito.mock(MwQueryResponse::class.java)
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ class NearbyParentFragmentUnitTest {
|
|||
@Throws(Exception::class)
|
||||
fun testOnDestroy() {
|
||||
fragment.onDestroy()
|
||||
verify(wikidataEditListener).setAuthenticationStateListener(null)
|
||||
verify(wikidataEditListener).authenticationStateListener = null
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
|
|
|
|||
|
|
@ -120,26 +120,16 @@ class NotificationClientTest {
|
|||
) = Notification().apply {
|
||||
setId(notificationId)
|
||||
|
||||
setTimestamp(
|
||||
Notification.Timestamp().apply {
|
||||
setUtciso8601(timestamp)
|
||||
},
|
||||
)
|
||||
setTimestamp(Notification.Timestamp().apply { setUtciso8601(timestamp) })
|
||||
|
||||
contents =
|
||||
Notification.Contents().apply {
|
||||
setCompactHeader(compactHeader)
|
||||
contents = Notification.Contents().apply {
|
||||
setCompactHeader(compactHeader)
|
||||
|
||||
links =
|
||||
Notification.Links().apply {
|
||||
setPrimary(
|
||||
GsonUtil.getDefaultGson().toJsonTree(
|
||||
Notification.Link().apply {
|
||||
setUrl(primaryUrl)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
links = Notification.Links().apply {
|
||||
setPrimary(GsonUtil.defaultGson.toJsonTree(
|
||||
Notification.Link().apply { setUrl(primaryUrl) }
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue