4657 method name is inconsistent with the method behavior (#4659)

* Test implementation

* providing method getMessageKeyOrDefault();

* providing changelog

* preping codereview.

* Deprecating method getMessageKeyOrNull in favor of getMessagekey()

* updating comments following code review.

* Bumping version to 6.5.13-SNAPSHOT

* passing all tests.

---------

Co-authored-by: peartree <etienne.poirier@smilecdr.com>
This commit is contained in:
Etienne Poirier 2023-04-17 10:41:08 -04:00 committed by GitHub
parent 7bdbda9ef0
commit 88459d0d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
86 changed files with 229 additions and 114 deletions

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-bom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<packaging>pom</packaging>
<name>HAPI FHIR BOM</name>
@ -12,7 +12,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-cli</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../../hapi-deployable-pom</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -0,0 +1,4 @@
---
type: fix
issue: 4657
title: "Fixing inconsistency between the method behavior and naming."

View File

@ -11,7 +11,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -70,7 +70,7 @@ public class SubscriptionDeliveringMessageSubscriber extends BaseSubscriptionDel
private ResourceModifiedJsonMessage convertDeliveryMessageToResourceModifiedMessage(ResourceDeliveryMessage theMsg, IBaseResource thePayloadResource) {
ResourceModifiedMessage payload = new ResourceModifiedMessage(myFhirContext, thePayloadResource, theMsg.getOperationType());
payload.setMessageKey(theMsg.getMessageKeyOrNull());
payload.setMessageKey(theMsg.getMessageKeyOrDefault());
payload.setTransactionId(theMsg.getTransactionId());
payload.setPartitionId(theMsg.getRequestPartitionId());
return new ResourceModifiedJsonMessage(payload);

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -31,6 +31,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import static org.apache.commons.lang3.StringUtils.defaultString;
@SuppressWarnings("WeakerAccess")
public abstract class BaseResourceMessage implements IResourceMessage, IModelJson {
@ -162,8 +164,14 @@ public abstract class BaseResourceMessage implements IResourceMessage, IModelJso
myMediaType = theMediaType;
}
@Deprecated
@Nullable
public String getMessageKeyOrNull() {
return getMessageKey();
}
@Nullable
public String getMessageKey() {
return myMessageKey;
}
@ -171,6 +179,26 @@ public abstract class BaseResourceMessage implements IResourceMessage, IModelJso
myMessageKey = theMessageKey;
}
/**
* Returns {@link #getMessageKey()} or {@link #getMessageKeyDefaultValue()} when {@link #getMessageKey()} returns <code>null</code>.
*
* @return the message key value or default
*/
@Nullable
public String getMessageKeyOrDefault() {
return defaultString(getMessageKey(), getMessageKeyDefaultValue());
}
/**
* Provides a fallback value when method {@link #getMessageKey()} returns <code>null</code>.
*
* @return null by default
*/
@Nullable
protected String getMessageKeyDefaultValue(){
return null;
}
public enum OperationTypeEnum {
CREATE(RestOperationTypeEnum.CREATE),
UPDATE(RestOperationTypeEnum.UPDATE),
@ -188,4 +216,5 @@ public abstract class BaseResourceMessage implements IResourceMessage, IModelJso
return myRestOperationTypeEnum;
}
}
}

View File

@ -29,6 +29,7 @@ import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.util.ResourceReferenceInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
@ -221,14 +222,10 @@ public abstract class BaseResourceModifiedMessage extends BaseResourceMessage im
return true;
}
@Nullable
@Override
public String getMessageKeyOrNull() {
if (super.getMessageKeyOrNull() != null) {
return super.getMessageKeyOrNull();
}
return myPayloadId;
public String getMessageKeyOrDefault() {
return StringUtils.defaultString(super.getMessageKey(), myPayloadId);
}
}

View File

@ -22,12 +22,14 @@ package ca.uhn.fhir.rest.server.messaging.json;
import ca.uhn.fhir.model.api.IModelJson;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import javax.annotation.Nullable;
import static java.util.Objects.isNull;
import static org.apache.commons.lang3.StringUtils.defaultString;
public abstract class BaseJsonMessage<T> implements Message<T>, IModelJson {
@ -60,13 +62,38 @@ public abstract class BaseJsonMessage<T> implements Message<T>, IModelJson {
return myHeaders;
}
public void setHeaders(HapiMessageHeaders theHeaders) {
myHeaders = theHeaders;
}
@Deprecated
@Nullable
public String getMessageKeyOrNull() {
public String getMessageKeyOrNull() {
return getMessageKey();
}
@Nullable
public String getMessageKey() {
return null;
}
/**
* Returns {@link #getMessageKey()} or {@link #getMessageKeyDefaultValue()} when {@link #getMessageKey()} returns null.
*
* @return the message key value or default
*/
@Nullable
public String getMessageKeyOrDefault() {
return defaultString(getMessageKey(), getMessageKeyDefaultValue());
}
/**
* Provides a fallback value when the value returned by {@link #getMessageKey()} is null.
*
* @return null by default
*/
@Nullable
protected String getMessageKeyDefaultValue(){
return null;
}
}

View File

@ -70,7 +70,13 @@ public class ResourceOperationJsonMessage extends BaseJsonMessage<ResourceOperat
@Nullable
@Override
public String getMessageKeyOrNull() {
return myPayload.getMessageKeyOrNull();
public String getMessageKey() {
return myPayload.getMessageKey();
}
@Nullable
@Override
public String getMessageKeyOrDefault() {
return myPayload.getMessageKeyOrDefault();
}
}

View File

@ -7,7 +7,7 @@
<parent>
<artifactId>hapi-fhir-serviceloaders</artifactId>
<groupId>ca.uhn.hapi.fhir</groupId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<artifactId>hapi-fhir-serviceloaders</artifactId>
<groupId>ca.uhn.hapi.fhir</groupId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -21,7 +21,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-caching-api</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
</dependency>
<dependency>

View File

@ -7,7 +7,7 @@
<parent>
<artifactId>hapi-fhir-serviceloaders</artifactId>
<groupId>ca.uhn.hapi.fhir</groupId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<artifactId>hapi-fhir</artifactId>
<groupId>ca.uhn.hapi.fhir</groupId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>hapi-deployable-pom</artifactId>
<groupId>ca.uhn.hapi.fhir</groupId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-spring-boot-samples</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
</parent>
<artifactId>hapi-fhir-spring-boot-sample-client-apache</artifactId>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-spring-boot-samples</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-spring-boot-samples</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-spring-boot</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -16,6 +16,7 @@ import org.junit.jupiter.api.Test;
import javax.annotation.Nonnull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
class BaseJsonMessageTest {
FhirContext ourFhirContext = FhirContext.forR4Cached();
@ -23,49 +24,68 @@ class BaseJsonMessageTest {
static final String MESSAGE_KEY = "MY_TEST_KEY";
@Test
void test_messageKeyIsResourceId_ResourceOperationJsonMessage() {
void test_byDefaultMessageKeyIsResourceId_for_ResourceOperationJsonMessage(){
ResourceOperationJsonMessage message = new ResourceOperationJsonMessage();
IBaseResource patient = buildPatient();
ResourceOperationMessage payload = new ResourceOperationMessage(ourFhirContext, patient, ResourceOperationMessage.OperationTypeEnum.CREATE);
message.setPayload(payload);
assertEquals(RESOURCE_ID, message.getMessageKeyOrNull());
}
@Nonnull
private static IBaseResource buildPatient() {
IBaseResource patient = new Patient();
patient.setId(new IdDt("Patient", RESOURCE_ID, "1"));
return patient;
assertNull(message.getMessageKey());
assertEquals(RESOURCE_ID, message.getMessageKeyOrDefault());
}
@Test
void test_messageKeyIsResourceId_ResourceDeliveryJsonMessage() {
void test_messageKeyIsMessageKey_whenSpecificallySet_for_ResourceOperationJsonMessage(){
ResourceOperationJsonMessage message = new ResourceOperationJsonMessage();
IBaseResource patient = buildPatient();
ResourceOperationMessage payload = new ResourceOperationMessage(ourFhirContext, patient, ResourceOperationMessage.OperationTypeEnum.CREATE);
payload.setMessageKey(MESSAGE_KEY);
message.setPayload(payload);
assertEquals(MESSAGE_KEY, message.getMessageKey());
assertEquals(MESSAGE_KEY, message.getMessageKeyOrDefault());
}
@Test
void test_byDefaultMessageKeyIsResourceId_for_ResourceDeliveryJsonMessage() {
ResourceDeliveryJsonMessage message = new ResourceDeliveryJsonMessage();
IBaseResource patient = buildPatient();
ResourceDeliveryMessage payload = new ResourceDeliveryMessage();
payload.setPayload(ourFhirContext, patient, EncodingEnum.JSON);
message.setPayload(payload);
assertEquals(RESOURCE_ID, message.getMessageKeyOrNull());
assertNull(message.getMessageKey());
assertEquals(RESOURCE_ID, message.getMessageKeyOrDefault());
}
@Test
void test_messageKeyIsResourceId_MdmResourceDeliveryJsonMessage() {
void test_messageKeyIsMessageKey_whenSpecificallySet_MdmResourceDeliveryJsonMessage() {
ResourceDeliveryJsonMessage message = new ResourceDeliveryJsonMessage();
IBaseResource patient = buildPatient();
ResourceDeliveryMessage payload = new ResourceDeliveryMessage();
payload.setPayload(ourFhirContext, patient, EncodingEnum.JSON);
payload.setMessageKey(MESSAGE_KEY);
message.setPayload(payload);
assertEquals(MESSAGE_KEY, message.getMessageKeyOrNull());
assertEquals(MESSAGE_KEY, message.getMessageKey());
assertEquals(MESSAGE_KEY, message.getMessageKeyOrDefault());
}
@Test
void test_messageKeyIsResourceId_ResourceModifiedJsonMessage() {
void test_byDefaultMessageKeyIsResourceId_for_ResourceModifiedJsonMessage() {
ResourceModifiedJsonMessage message = new ResourceModifiedJsonMessage();
IBaseResource patient = buildPatient();
ResourceModifiedMessage payload = new ResourceModifiedMessage(ourFhirContext, patient, BaseResourceMessage.OperationTypeEnum.CREATE);
message.setPayload(payload);
assertEquals(RESOURCE_ID, message.getMessageKeyOrNull());
assertNull(message.getMessageKey());
assertEquals(RESOURCE_ID, message.getMessageKeyOrDefault());
}
@Test
void test_messageKeyIsMessageKey_whenSpecificallySet_for_ResourceModifiedJsonMessage() {
ResourceModifiedJsonMessage message = new ResourceModifiedJsonMessage();
IBaseResource patient = buildPatient();
ResourceModifiedMessage payload = new ResourceModifiedMessage(ourFhirContext, patient, BaseResourceMessage.OperationTypeEnum.CREATE);
payload.setMessageKey(MESSAGE_KEY);
message.setPayload(payload);
assertEquals(MESSAGE_KEY, message.getMessageKey());
assertEquals(MESSAGE_KEY, message.getMessageKeyOrDefault());
}
@Test
@ -78,4 +98,21 @@ class BaseJsonMessageTest {
// Then
assertEquals(0, headers.getRetryCount());
}
@Test
void test_getMessageKey_whenSetMessageKeyIsNotInvoked_willReturnNull(){
// given
IBaseResource patient = buildPatient();
// when
ResourceModifiedMessage payload = new ResourceModifiedMessage(ourFhirContext, patient, BaseResourceMessage.OperationTypeEnum.CREATE);
// then
assertNull(payload.getMessageKey());
}
@Nonnull
private static IBaseResource buildPatient() {
IBaseResource patient = new Patient();
patient.setId(new IdDt("Patient", RESOURCE_ID, "1"));
return patient;
}
}

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -58,11 +58,20 @@ public class ResourceDeliveryJsonMessage extends BaseJsonMessage<ResourceDeliver
@Override
@Nullable
public String getMessageKeyOrNull() {
public String getMessageKey() {
if (myPayload == null) {
return null;
}
return myPayload.getMessageKeyOrNull();
return myPayload.getMessageKey();
}
@Override
@Nullable
public String getMessageKeyOrDefault() {
if (myPayload == null) {
return null;
}
return myPayload.getMessageKeyOrDefault();
}
@Override

View File

@ -27,6 +27,7 @@ import ca.uhn.fhir.rest.server.messaging.BaseResourceMessage;
import ca.uhn.fhir.rest.server.messaging.IResourceMessage;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
@ -152,11 +153,7 @@ public class ResourceDeliveryMessage extends BaseResourceMessage implements IRes
@Nullable
@Override
public String getMessageKeyOrNull() {
if (super.getMessageKeyOrNull() != null) {
return super.getMessageKeyOrNull();
}
return myPayloadId;
public String getMessageKeyOrDefault() {
return StringUtils.defaultString(super.getMessageKey(), myPayloadId);
}
}

View File

@ -55,11 +55,20 @@ public class ResourceModifiedJsonMessage extends BaseJsonMessage<ResourceModifie
@Override
@Nullable
public String getMessageKeyOrNull() {
public String getMessageKey() {
if (myPayload == null) {
return null;
}
return myPayload.getMessageKeyOrNull();
return myPayload.getMessageKey();
}
@Override
@Nullable
public String getMessageKeyOrDefault() {
if (myPayload == null) {
return null;
}
return myPayload.getMessageKeyOrDefault();
}
@Override

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<packaging>pom</packaging>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<name>HAPI-FHIR</name>
<description>An open-source implementation of the FHIR specification in Java.</description>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<version>6.5.12-SNAPSHOT</version>
<version>6.5.13-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>