Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproduce ArrayIndexOutOfBoundsException Bug #168 #188

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions common/src/test/java/org/openmrs/analytics/ParquetUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class ParquetUtilTest {

private String observationBundle;

private String observationBundleWithBigDecimal;

private ParquetUtil parquetUtil;

private FhirContext fhirContext;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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<Path> 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();
Expand Down
189 changes: 189 additions & 0 deletions common/src/test/resources/observation_bundle2.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
]
}