Skip to content

Commit

Permalink
use let and fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pld committed Mar 3, 2023
1 parent fd41093 commit 91500bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,23 @@ constructor(
bundleName = LocalizationHelper.STRINGS_BASE_BUNDLE_NAME,
locale = Locale.getDefault(),
template = getConfigValueWithParam<T>(paramsMap, configKey, configsJsonMap)

// java.util.NoSuchElementException: Key application is missing in the map.
)
)
.decodeJson(jsonInstance = json)
}

/**
* receives @paramsMap , @configKey and @ConfigJsonMap as inputs and
* interpolates the value if found and if paramsMap are not empty return the result
* return the value if key is found and paramsMap is empty
* receives @paramsMap , @configKey and @ConfigJsonMap as inputs and interpolates the value if
* found and if paramsMap are not empty return the result return the value if key is found and
* paramsMap is empty
*/
inline fun <reified T : Configuration> getConfigValueWithParam(
paramsMap: Map<String, String>?,
configKey: String,
configsJsonMap: Map<String, String>
) =
if (paramsMap?.isNullOrEmpty() == false)
configsJsonMap.getValue(configKey).interpolate(paramsMap)
else configsJsonMap.getValue(configKey)
configsJsonMap.getValue(configKey).let { jsonValue ->
if (paramsMap?.isNullOrEmpty() == false) jsonValue.interpolate(paramsMap) else jsonValue
}

inline fun <reified T : Configuration> retrieveConfigurations(configType: ConfigType): List<T> =
configsJsonMap.values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class RegisterRepositoryTest : RobolectricTest() {
Assert.assertEquals(20, recordsCount)
}
}

@Test
fun loadRegisterDataWithParamsReturnsFilteredResources() = runTest {
val group =
Expand Down

0 comments on commit 91500bb

Please sign in to comment.