Skip to content

Commit

Permalink
5018
Browse files Browse the repository at this point in the history
  • Loading branch information
ktiniatros committed Nov 4, 2022
1 parent dba0aef commit fb6b36e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ val fuzzyMatchingModule = module {
}

factory<SelectionDataUtil> {
fun getFormattedString(stringResId: Int, template: String): String {
return androidContext().getString(stringResId, template)
}
SelectionDataUtilImpl(
get(),
get(),
get(),
androidContext().resources::getQuantityString,
::getFormattedString,
androidContext()::getString
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import nl.rijksoverheid.ctr.holder.get_events.models.RemoteEvent.Companion.TYPE_
import nl.rijksoverheid.ctr.holder.get_events.models.RemoteEvent.Companion.TYPE_TEST
import nl.rijksoverheid.ctr.holder.get_events.models.RemoteEvent.Companion.TYPE_VACCINATION
import nl.rijksoverheid.ctr.holder.get_events.models.RemoteEvent.Companion.TYPE_VACCINATION_ASSESSMENT
import nl.rijksoverheid.ctr.holder.get_events.models.RemoteEventVaccination
import nl.rijksoverheid.ctr.holder.your_events.utils.RemoteEventStringUtil
import nl.rijksoverheid.ctr.holder.your_events.utils.YourEventsFragmentUtil

Expand All @@ -33,6 +34,7 @@ class SelectionDataUtilImpl(
private val yourEventsFragmentUtil: YourEventsFragmentUtil,
private val remoteEventStringUtil: RemoteEventStringUtil,
private val getQuantityString: (Int, Int) -> String,
private val getFormattedString: (Int, String) -> String,
private val getString: (Int) -> String
) : SelectionDataUtil {

Expand Down Expand Up @@ -94,7 +96,19 @@ class SelectionDataUtilImpl(
val data = remoteEvents.map { event ->
val eventDate = event.getDate()
SelectionDetailData(
type = remoteEventStringUtil.remoteEventTitle(event.javaClass),
type = "${remoteEventStringUtil.remoteEventTitle(event.javaClass)}${
if (providerIdentifier.startsWith("dcc") && event is RemoteEventVaccination) {
val dose = event.vaccination?.doseNumber
val totalDoses = event.vaccination?.totalDoses
if (dose != null && totalDoses != null) {
" ${getFormattedString(R.string.your_vaccination_explanation_dose, "$dose/$totalDoses")}"
} else {
""
}
} else {
""
}
}",
providerIdentifiers = listOf(
yourEventsFragmentUtil.getProviderName(
configProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ class SelectionDataUtilImplTest : AutoCloseKoinTest() {
private val yourEventsFragmentUtil: YourEventsFragmentUtil by inject()
private val remoteEventStringUtil: RemoteEventStringUtil by inject()

private fun getFormattedString(stringResId: Int, formattedString: String): String {
return getApplication().getString(stringResId, formattedString)
}
private val selectionDataUtil by lazy {
SelectionDataUtilImpl(
cachedAppConfigUseCase,
yourEventsFragmentUtil,
remoteEventStringUtil,
getApplication().resources::getQuantityString,
::getFormattedString,
getApplication()::getString
)
}
Expand Down Expand Up @@ -101,4 +105,15 @@ class SelectionDataUtilImplTest : AutoCloseKoinTest() {
assertEquals(expectedData[index], data.type)
}
}

@Test
fun `details string for dcc vaccinations display dose`() {
val actualData = selectionDataUtil.details("dcc_code1", listOf(RemoteEventVaccination(RemoteEvent.TYPE_VACCINATION, "", mockk {
every { date } returns LocalDate.now()
every { doseNumber } returns "2"
every { totalDoses } returns "2"
})))

assertEquals("Vaccinatie dosis 2/2", actualData.first().type)
}
}

0 comments on commit fb6b36e

Please sign in to comment.