From 9fef4fe1ebc6945b068ad81a0409ef4ee802184f Mon Sep 17 00:00:00 2001 From: Tadgh Date: Wed, 17 Feb 2021 15:05:49 -0500 Subject: [PATCH] Rework MDM tests --- .../ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java index 72091e7..247b0b7 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java @@ -77,8 +77,7 @@ public class ExampleServerR4IT { // Wait until the MDM message has been processed await().until(() -> getPatients().size(), equalTo(2)); - List persons = getPatients(); - Patient goldenRecord = persons.get(0); + Patient goldenRecord = getGoldenResourcePatient(); // Verify that a golden record Patient was created assertNotNull(goldenRecord.getMeta().getTag("http://hapifhir.io/fhir/NamingSystem/mdm-record-status", "GOLDEN_RECORD")); @@ -90,6 +89,17 @@ public class ExampleServerR4IT { retVal.sort(comparing(o -> ((Patient) o).getMeta().getLastUpdated()).reversed()); return retVal; } + private Patient getGoldenResourcePatient() { + Bundle bundle = ourClient.search() + .forResource(Patient.class) + .withTag("http://hapifhir.io/fhir/NamingSystem/mdm-record-status", "GOLDEN_RECORD") + .cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute(); + if (bundle.getEntryFirstRep() != null) { + return (Patient) bundle.getEntryFirstRep().getResource(); + } else { + return null; + } + } @Test @Order(1)