From 1927db69f2581a2910e26035d305bb50767a9c7c Mon Sep 17 00:00:00 2001 From: kimaina Date: Wed, 14 Jul 2021 13:46:28 +0300 Subject: [PATCH] Reproduce ArrayIndexOutOfBoundsException #168 --- .../openmrs/analytics/ParquetUtilTest.java | 19 ++ .../test/resources/observation_bundle2.json | 189 ++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 common/src/test/resources/observation_bundle2.json diff --git a/common/src/test/java/org/openmrs/analytics/ParquetUtilTest.java b/common/src/test/java/org/openmrs/analytics/ParquetUtilTest.java index e720d3275..9a3ea5e3e 100644 --- a/common/src/test/java/org/openmrs/analytics/ParquetUtilTest.java +++ b/common/src/test/java/org/openmrs/analytics/ParquetUtilTest.java @@ -60,6 +60,8 @@ public class ParquetUtilTest { private String observationBundle; + private String observationBundleWithBigDecimal; + private ParquetUtil parquetUtil; private FhirContext fhirContext; @@ -76,6 +78,8 @@ public void setup() throws IOException { ParquetUtil.initializeAvroConverters(); patientBundle = Resources.toString(Resources.getResource("patient_bundle.json"), StandardCharsets.UTF_8); observationBundle = Resources.toString(Resources.getResource("observation_bundle.json"), StandardCharsets.UTF_8); + observationBundleWithBigDecimal = Resources.toString(Resources.getResource("observation_bundle2.json"), + StandardCharsets.UTF_8); this.fhirContext = FhirContext.forR4(); parquetUtil = new ParquetUtil(PARQUET_ROOT, 0, 0, "TEST_", fileSystem); } @@ -177,6 +181,21 @@ public void createSingleOutput() throws IOException { assertThat(files.count(), equalTo(1L)); } + @Test + public void writeBundlesWithBigDecimalValue() throws IOException { + initilizeLocalFileSystem(); + parquetUtil = new ParquetUtil(rootPath.toString(), 0, 0, "", fileSystem); + IParser parser = fhirContext.newJsonParser(); + Bundle bundle = parser.parseResource(Bundle.class, observationBundleWithBigDecimal); + for (Bundle.BundleEntryComponent entry : bundle.getEntry()) { + parquetUtil.write(entry.getResource()); + } + parquetUtil.closeAllWriters(); + Stream files = Files.list(rootPath.resolve("Observation")) + .filter(f -> f.toString().startsWith(rootPath.toString() + "/Observation/Observation_output-")); + assertThat(files.count(), equalTo(1L)); + } + @Test public void createMultipleOutputByTime() throws IOException, InterruptedException { initilizeLocalFileSystem(); diff --git a/common/src/test/resources/observation_bundle2.json b/common/src/test/resources/observation_bundle2.json new file mode 100644 index 000000000..342f9644c --- /dev/null +++ b/common/src/test/resources/observation_bundle2.json @@ -0,0 +1,189 @@ +{ + "resourceType": "Bundle", + "id": "bf3bcfcc-2b34-45e3-8a60-ef04ef7060ef", + "meta": { + "lastUpdated": "2020-09-30T14:04:02.282-04:00", + "tag": [ + { + "system": "http://hl7.org/fhir/v3/ObservationValue", + "code": "SUBSETTED", + "display": "Resource encoded in summary mode" + } + ] + }, + "type": "searchset", + "total": 4, + "link": [ + { + "relation": "self", + "url": "http://localhost:9020/openmrs/ws/fhir2/R4/Observation?_count=10&_getpagesoffset=0&_summary=data" + } + ], + "entry": [ + + { + "fullUrl": "http://localhost:9020/openmrs/ws/fhir2/R4/Observation/2c98a790-1a48-4b75-b458-ceb2d51f5df1", + "resource": { + "resourceType": "Observation", + "id": "2c98a790-1a48-4b75-b458-ceb2d51f5df1", + "status": "final", + "category": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/observation-category", + "code": "laboratory", + "display": "Laboratory" + } + ] + } + ], + "code": { + "coding": [ + { + "code": "a898c87a-1350-11df-a1f1-0026b9348838", + "display": "BODY SURFACE AREA" + } + ] + }, + "subject": { + "reference": "Patient/7_SOME_PATIENT_REF", + "type": "Patient", + "display": "NO_NAME" + }, + "encounter": { + "reference": "Encounter/8_SOME_ENC_REF", + "type": "Encounter" + }, + "effectiveDateTime": "2021-04-16T11:12:33+03:00", + "issued": "2021-04-16T11:13:33.000+03:00", + "valueQuantity": { + "value": 1.8287822299126937 + } + } + }, + { + "fullUrl": "http://localhost:9020/openmrs/ws/fhir2/R4/Observation/2c98a790-1a48-4b75-b458-ceb2d51f5df2", + "resource": { + "resourceType": "Observation", + "id": "2c98a790-1a48-4b75-b458-ceb2d51f5df2", + "status": "final", + "category": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/observation-category", + "code": "laboratory", + "display": "Laboratory" + } + ] + } + ], + "code": { + "coding": [ + { + "code": "a898c87a-1350-11df-a1f1-0026b9348838", + "display": "BODY SURFACE AREA" + } + ] + }, + "subject": { + "reference": "Patient/7_SOME_PATIENT_REF", + "type": "Patient", + "display": "NO_NAME" + }, + "encounter": { + "reference": "Encounter/8_SOME_ENC_REF", + "type": "Encounter" + }, + "effectiveDateTime": "2021-04-16T11:12:33+03:00", + "issued": "2021-04-16T11:13:33.000+03:00", + "valueQuantity": { + "value": 1.8287822299126937 + } + } + }, + { + "fullUrl": "http://localhost:9020/openmrs/ws/fhir2/R4/Observation/2c98a790-1a48-4b75-b458-ceb2d51f5df3", + "resource": { + "resourceType": "Observation", + "id": "2c98a790-1a48-4b75-b458-ceb2d51f5df3", + "status": "final", + "category": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/observation-category", + "code": "laboratory", + "display": "Laboratory" + } + ] + } + ], + "code": { + "coding": [ + { + "code": "a898c87a-1350-11df-a1f1-0026b9348838", + "display": "BODY SURFACE AREA" + } + ] + }, + "subject": { + "reference": "Patient/7_SOME_PATIENT_REF", + "type": "Patient", + "display": "NO_NAME" + }, + "encounter": { + "reference": "Encounter/8_SOME_ENC_REF", + "type": "Encounter" + }, + "effectiveDateTime": "2021-04-16T11:12:33+03:00", + "issued": "2021-04-16T11:13:33.000+03:00", + "valueQuantity": { + "value": 1.8287822299126937 + } + } + }, + { + "fullUrl": "http://localhost:9020/openmrs/ws/fhir2/R4/Observation/2c98a790-1a48-4b75-b458-ceb2d51f5df4", + "resource": { + "resourceType": "Observation", + "id": "2c98a790-1a48-4b75-b458-ceb2d51f5df4", + "status": "final", + "category": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/observation-category", + "code": "laboratory", + "display": "Laboratory" + } + ] + } + ], + "code": { + "coding": [ + { + "code": "a898c87a-1350-11df-a1f1-0026b9348838", + "display": "BODY SURFACE AREA" + } + ] + }, + "subject": { + "reference": "Patient/7_SOME_PATIENT_REF", + "type": "Patient", + "display": "NO_NAME" + }, + "encounter": { + "reference": "Encounter/8_SOME_ENC_REF", + "type": "Encounter" + }, + "effectiveDateTime": "2021-04-16T11:12:33+03:00", + "issued": "2021-04-16T11:13:33.000+03:00", + "valueQuantity": { + "value": 1.8287822299126937 + } + } + } + ] +} \ No newline at end of file