From 6ba38a031a7c82fbe7a57b8b530b28b453022a14 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 25 Dec 2024 06:51:54 +1100 Subject: [PATCH] Testing fixes for instance generation --- .../main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java | 2 +- .../org/hl7/fhir/r5/testfactory/ProfileBasedFactory.java | 5 +++++ .../fhir/generation/tests/TestInstanceGenerationTester.java | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index 09038416b..42f882d5e 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -1014,7 +1014,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } } - if (!noLimits) { + if (!noLimits && !p.hasParameter("count")) { p.addParameter("count", expandCodesLimit); p.addParameter("offset", 0); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/testfactory/ProfileBasedFactory.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/testfactory/ProfileBasedFactory.java index 06f5dca04..9621df45a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/testfactory/ProfileBasedFactory.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/testfactory/ProfileBasedFactory.java @@ -430,6 +430,11 @@ public class ProfileBasedFactory { ValueSetExpansionOutcome vse = fpe.getWorker().expandVS(vs, true, false, 100); if (vse.isOk()) { ls.others.add("ValueSet "+vs.getVersionedUrl()+" "+ValueSetUtilities.countExpansion(vse.getValueset().getExpansion().getContains())+" concepts"); + if (testing) { + for (ValueSetExpansionContainsComponent cc : vse.getValueset().getExpansion().getContains()) { + ls.others.add(cc.getSystem()+"#"+cc.getCode()+" : \""+cc.getDisplay()+"\" ("+cc.hasContains()+")"); + } + } return pickRandomConcept(vse.getValueset().getExpansion().getContains()); } else { ls.others.add("ValueSet "+vs.getVersionedUrl()+": error = "+vse.getError()); diff --git a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/generation/tests/TestInstanceGenerationTester.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/generation/tests/TestInstanceGenerationTester.java index 1f172021b..64ee1cf7e 100644 --- a/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/generation/tests/TestInstanceGenerationTester.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/generation/tests/TestInstanceGenerationTester.java @@ -84,6 +84,7 @@ public class TestInstanceGenerationTester { tdf.setTesting(true); // no randomness System.out.println("Execute Test Data Factory '"+tdf.getName()+"'. Log in "+tdf.statedLog()); tdf.execute(); + System.out.println(TextFile.fileToString(Utilities.path(log, tdf.statedLog()))); } // now, check output @@ -96,7 +97,7 @@ public class TestInstanceGenerationTester { } for (String name : Utilities.strings("Patient-1.json", "Encounter-1.json", "MedicationStatement-1.json", "Observation-bp-1.json", "Observation-weight-1.json")) { - String diff = new CompareUtilities(null, null).checkJsonSrcIsSame(name, TextFile.fileToString(Utilities.path(output, name)), TextFile.fileToString(Utilities.path(expected, name)), false); + String diff = new CompareUtilities(null, null).checkJsonSrcIsSame(name, TextFile.fileToString(Utilities.path(expected, name)), TextFile.fileToString(Utilities.path(output, name)), false); Assertions.assertNull(diff, "unexpected difference for "+name); } }