@@ -8,11 +8,14 @@ import assertk.assertions.isNotEmpty
88import assertk.assertions.isNotNull
99import assertk.assertions.isTrue
1010import assertk.assertions.messageContains
11+ import com.fasterxml.jackson.annotation.JsonProperty
12+ import gov.cdc.prime.fhirconverter.translation.hl7.ValueSetCollection
1113import gov.cdc.prime.fhirconverter.translation.hl7.schema.ConfigSchemaReader.readOneYamlSchema
1214import gov.cdc.prime.fhirconverter.translation.hl7.schema.converter.HL7ConverterSchema
1315import gov.cdc.prime.fhirconverter.translation.hl7.schema.fhirTransform.FhirTransformSchema
1416import gov.cdc.prime.fhirconverter.translation.hl7.utils.helpers.SchemaReferenceResolverHelper
1517import java.io.File
18+ import java.util.SortedMap
1619import kotlin.test.Test
1720
1821class ConfigSchemaReaderTests {
@@ -83,7 +86,7 @@ class ConfigSchemaReaderTests {
8386
8487 @Test
8588 fun `test read converter vs fhir transform` () {
86- // This is a valid fhir transform schema
89+ // This is a valid fhir transform schema with value set
8790 assertThat(
8891 ConfigSchemaReader .fromFile(
8992 " classpath:/schema/fhir-transforms/sample_schema.yml" ,
@@ -177,6 +180,25 @@ class ConfigSchemaReaderTests {
177180 assertThat(schema.name).isEqualTo(" /schema/schema-read-test-06/ORU_R01_extends.yml" )
178181 }
179182
183+ @Test
184+ fun `test subtype class must inherit from ValueSetCollection` () {
185+ // Implementation of [ValueSetCollection] to allow valueSet to be retrieved from a lookup table.
186+ class ClassInheritFromValueSetCollection
187+ (@JsonProperty(" testValues" ) private val testValues: SortedMap <String , String >) : ValueSetCollection {
188+ override fun toSortedMap (): SortedMap <String , String > = testValues
189+ override fun getMappedValue (keyValue : String ): String? = null
190+ override fun isNotEmpty (): Boolean = testValues.isNotEmpty()
191+ }
192+ class ClassNotInheritFromValueSetCollection
193+ assertThat(
194+ ConfigSchemaReader .addValueSetClass(ClassInheritFromValueSetCollection ::class .java)
195+ )
196+
197+ assertFailure {
198+ ConfigSchemaReader .addValueSetClass(ClassNotInheritFromValueSetCollection ::class .java)
199+ }
200+ }
201+
180202 @Test
181203 fun `test read FHIR Transform from file` () {
182204 assertThat(
0 commit comments