Skip to content

Commit e8677e1

Browse files
committed
applied spotless and detekt on core:testing MIFOSAC-300
1 parent 8f1fb9a commit e8677e1

File tree

9 files changed

+91
-16
lines changed

9 files changed

+91
-16
lines changed

core/domain/src/test/java/com/mifos/core/domain/GroupListPagingSourceTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import androidx.paging.PagingSource
55
import androidx.paging.testing.TestPager
66
import com.mifos.core.objects.group.Group
77
import com.mifos.core.testing.repository.TestGroupsListRepository
8-
import com.mifos.core.testing.repository.errorMessage
8+
import com.mifos.core.testing.repository.ERROR_MESSAGE
99
import com.mifos.core.testing.repository.getPagedData
1010
import com.mifos.core.testing.repository.sampleGroups
1111
import com.mifos.core.testing.util.MainDispatcherRule
@@ -158,7 +158,7 @@ class GroupListPagingSourceTest {
158158
val result = pager.refresh()
159159
assertTrue(result is PagingSource.LoadResult.Error)
160160

161-
assertEquals(errorMessage, result.throwable.message)
161+
assertEquals(ERROR_MESSAGE, result.throwable.message)
162162

163163
val page = pager.getLastLoadedPage()
164164
assertNull(page)

core/testing/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
110
plugins {
211
alias(libs.plugins.mifos.android.library)
312
alias(libs.plugins.mifos.android.library.compose)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2024 Mifos Initiative
4+
5+
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
6+
If a copy of the MPL was not distributed with this file,
7+
You can obtain one at https://mozilla.org/MPL/2.0/.
8+
9+
See https://github.com/openMF/android-client/blob/master/LICENSE.md
10+
-->
211
<manifest>
312

413
</manifest>

core/testing/src/main/java/com/mifos/core/testing/MifosTestRunner.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
110
package com.mifos.core.testing
211

312
import android.app.Application

core/testing/src/main/java/com/mifos/core/testing/di/TestDispatcherModule.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
110
package com.mifos.core.testing.di
211

312
import dagger.Module

core/testing/src/main/java/com/mifos/core/testing/di/TestDispatchersModule.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
110
package com.mifos.core.testing.di
211

312
import com.mifos.core.common.network.Dispatcher

core/testing/src/main/java/com/mifos/core/testing/repository/TestGroupsListRepository.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
110
package com.mifos.core.testing.repository
211

312
import com.mifos.core.data.repository.GroupsListRepository
@@ -6,14 +15,14 @@ import kotlinx.coroutines.flow.Flow
615
import kotlinx.coroutines.flow.MutableStateFlow
716
import kotlinx.coroutines.flow.emptyFlow
817

9-
const val errorMessage = "Unable to load data from server"
18+
const val ERROR_MESSAGE = "Unable to load data from server"
1019

1120
class TestGroupsListRepository : GroupsListRepository {
1221
private val data = MutableStateFlow<List<Group>?>(sampleGroups)
1322

1423
override suspend fun getAllGroups(paged: Boolean, offset: Int, limit: Int): List<Group> {
1524
return if (data.value == null) {
16-
throw RuntimeException(errorMessage)
25+
throw RuntimeException(ERROR_MESSAGE)
1726
} else {
1827
data.value!!.getPagedData(offset, limit)
1928
}
@@ -178,7 +187,7 @@ val sampleGroups = listOf(
178187
id = 30,
179188
accountNo = "ACC-030",
180189
name = "Group 30",
181-
)
190+
),
182191
)
183192

184193
fun <T> List<T>.getPagedData(offset: Int, limit: Int): List<T> {
@@ -191,4 +200,4 @@ fun <T> List<T>.getPagedData(offset: Int, limit: Int): List<T> {
191200
}
192201
val endIndex = (adjustedOffset + limit).coerceAtMost(size)
193202
return subList(adjustedOffset, endIndex)
194-
}
203+
}

core/testing/src/main/java/com/mifos/core/testing/repository/TestSearchRepository.kt

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
110
package com.mifos.core.testing.repository
211

312
import com.mifos.core.data.repository.SearchRepository
@@ -15,26 +24,29 @@ class TestSearchRepository : SearchRepository {
1524
override suspend fun searchResources(
1625
query: String,
1726
resources: String?,
18-
exactMatch: Boolean?
27+
exactMatch: Boolean?,
1928
): Flow<List<SearchedEntity>> {
2029
return sampleResults.map { list ->
2130
when {
2231
query.isBlank() && resources.isNullOrBlank() -> emptyList()
2332
else -> {
2433
list.asSequence().filter { entity ->
25-
(resources.isNullOrBlank() || entity.entityType.equals(
26-
resources,
27-
ignoreCase = true
28-
)) && (query.isBlank() || when {
29-
exactMatch == true -> entity.entityName.equals(query, ignoreCase = true) ||
34+
(
35+
resources.isNullOrBlank() || entity.entityType.equals(
36+
resources,
37+
ignoreCase = true,
38+
)
39+
) && (
40+
query.isBlank() || when {
41+
exactMatch == true -> entity.entityName.equals(query, ignoreCase = true) ||
3042
entity.entityAccountNo.equals(query, ignoreCase = true) ||
3143
entity.parentName.equals(query, true)
3244

33-
else -> entity.entityName?.contains(query, ignoreCase = true) == true ||
45+
else -> entity.entityName?.contains(query, ignoreCase = true) == true ||
3446
entity.entityAccountNo?.contains(query, ignoreCase = true) == true ||
3547
entity.parentName?.contains(query, true) == true
36-
}
37-
)
48+
}
49+
)
3850
}.toList()
3951
}
4052
}
@@ -45,4 +57,4 @@ class TestSearchRepository : SearchRepository {
4557
fun addSampleResults(results: List<SearchedEntity>) {
4658
sampleResults.update { results }
4759
}
48-
}
60+
}

core/testing/src/main/java/com/mifos/core/testing/util/MainDispatcherRule.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
110
package com.mifos.core.testing.util
211

312
import kotlinx.coroutines.Dispatchers

0 commit comments

Comments
 (0)