Skip to content

Commit

Permalink
add test and guard for entry item with missing elements
Browse files Browse the repository at this point in the history
  • Loading branch information
pld committed Dec 21, 2024
1 parent 2c96061 commit c15c012
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,12 @@ constructor(
}
if (sectionComponent.hasEntry() && sectionComponent.entry.isNotEmpty()) {
sectionComponent.entry.forEach { entryReference ->
addBinaryToConfigsJsonMap(
entryReference,
configsLoadedCallback,
)
if (entryReference.hasReferenceElement() && entryReference.hasIdentifier()) {
addBinaryToConfigsJsonMap(
entryReference,
configsLoadedCallback,
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,33 @@ class ConfigurationRegistryTest : RobolectricTest() {
assertTrue(configRegistry.configsJsonMap.containsKey("resource2"))
}

@Test
fun testPopulateConfigurationsMapWithEntryMissingId() = runTest {
val composition =
Composition().apply {
section =
listOf(
SectionComponent().apply {
entry =
listOf(
Reference().apply {
reference = "Binary/1"
},
Reference().apply {
reference = "Binary/2"
identifier = Identifier().apply { value = "resource2" }
},
)
},
)
}

coEvery { fhirEngine.get<Binary>(any()) } returns Binary().apply { content = ByteArray(0) }
configRegistry.populateConfigurationsMap(context, composition, false, "app-id") {}
assertEquals(1, configRegistry.configsJsonMap.size)
assertTrue(configRegistry.configsJsonMap.containsKey("resource2"))
}

@Test
fun testPopulateConfigurationsMapWithFocusAndEntry() = runTest {
val composition =
Expand Down

0 comments on commit c15c012

Please sign in to comment.