meta.versionId Incremented After Update Operation With No Changes (DSTU 3) (#4349)
* Tests for R4 (passing) and DSTU3 (failing) * Fix Co-authored-by: nathaniel.doef <nathaniel.doef@smilecdr.com>
This commit is contained in:
parent
b8760cc022
commit
d639a2a86d
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 4348
|
||||
jira: SMILE-5651
|
||||
title: "Previously, if a DSTU3 Resource was updated and no changes were made, the `meta.versionId` value was
|
||||
incremented incorrectly. This has been fixed."
|
|
@ -705,7 +705,10 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean allExtensionsRemoved = extensions.isEmpty();
|
||||
if(allExtensionsRemoved){
|
||||
hasExtensions = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4576,6 +4576,22 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateResourceAfterReadOperationAndNoChangesShouldNotChangeVersion(){
|
||||
// Create Patient
|
||||
Patient patient = new Patient();
|
||||
patient = (Patient) myClient.create().resource(patient).execute().getResource();
|
||||
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
|
||||
|
||||
// Read Patient
|
||||
patient = (Patient) myClient.read().resource("Patient").withId(patient.getIdElement()).execute();
|
||||
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
|
||||
|
||||
// Update Patient with no changes
|
||||
patient = (Patient) myClient.update().resource(patient).execute().getResource();
|
||||
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateBadInputViaGet() throws IOException {
|
||||
|
||||
|
|
|
@ -762,6 +762,22 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateResourceAfterReadOperationAndNoChangesShouldNotChangeVersion(){
|
||||
// Create Patient
|
||||
Patient patient = new Patient();
|
||||
patient = (Patient) myClient.create().resource(patient).execute().getResource();
|
||||
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
|
||||
|
||||
// Read Patient
|
||||
patient = (Patient) myClient.read().resource("Patient").withId(patient.getIdElement()).execute();
|
||||
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
|
||||
|
||||
// Update Patient with no changes
|
||||
patient = (Patient) myClient.update().resource(patient).execute().getResource();
|
||||
assertEquals(1, patient.getIdElement().getVersionIdPartAsLong());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWithNoBody() throws IOException {
|
||||
|
||||
|
|
Loading…
Reference in New Issue