From 79ad0aebb505fb9b25d34d04fd043808e20cab85 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 19 Feb 2020 18:01:18 -0500 Subject: [PATCH] Add a test --- .../r4/FhirResourceDaoR4QueryCountTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java index ee059080b41..2b5380886de 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4QueryCountTest.java @@ -133,6 +133,38 @@ public class FhirResourceDaoR4QueryCountTest extends BaseJpaR4Test { assertEquals(0, myCaptureQueriesListener.getDeleteQueriesForCurrentThread().size()); } + + @Test + public void testCreateWithClientAssignedId() { + myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.DISABLED); + + runInTransaction(() -> { + Patient p = new Patient(); + p.getMaritalStatus().setText("123"); + return myPatientDao.create(p).getId().toUnqualified(); + }); + + myCaptureQueriesListener.clear(); + + runInTransaction(() -> { + Patient p = new Patient(); + p.setId("AAA"); + p.getMaritalStatus().setText("123"); + return myPatientDao.update(p).getId().toUnqualified(); + }); + + myCaptureQueriesListener.logSelectQueriesForCurrentThread(); + assertEquals(1, myCaptureQueriesListener.getSelectQueriesForCurrentThread().size()); + myCaptureQueriesListener.logUpdateQueriesForCurrentThread(); + assertEquals(0, myCaptureQueriesListener.getUpdateQueriesForCurrentThread().size()); + myCaptureQueriesListener.logInsertQueriesForCurrentThread(); + assertEquals(4, myCaptureQueriesListener.getInsertQueriesForCurrentThread().size()); + myCaptureQueriesListener.logDeleteQueriesForCurrentThread(); + assertEquals(0, myCaptureQueriesListener.getDeleteQueriesForCurrentThread().size()); + } + + + @AfterClass public static void afterClassClearContext() { TestUtil.clearAllStaticFieldsForUnitTest();