Merge pull request #1272 from pnewhook/getLink-enum-bug
Bundle.getLink(String) comparing string to enum
This commit is contained in:
commit
a7026ca51d
|
@ -13,7 +13,7 @@
|
||||||
public BundleLinkComponent getLink(String theRelation) {
|
public BundleLinkComponent getLink(String theRelation) {
|
||||||
org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
|
org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
|
||||||
for (BundleLinkComponent next : getLink()) {
|
for (BundleLinkComponent next : getLink()) {
|
||||||
if (theRelation.equals(next.getRelation())) {
|
if (theRelation.equals(next.getRelation().toCode())) {
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5307,7 +5307,7 @@ public class Bundle extends Resource implements IBaseBundle {
|
||||||
public BundleLinkComponent getLink(String theRelation) {
|
public BundleLinkComponent getLink(String theRelation) {
|
||||||
org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
|
org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
|
||||||
for (BundleLinkComponent next : getLink()) {
|
for (BundleLinkComponent next : getLink()) {
|
||||||
if (theRelation.equals(next.getRelation())) {
|
if (theRelation.equals(next.getRelation().toCode())) {
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package org.hl7.fhir.r5.model;
|
||||||
|
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class BundleTypeTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Test getLink by string when present")
|
||||||
|
public void getLinkShouldFindWhenPresent() {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
Bundle.BundleLinkComponent link = new Bundle.BundleLinkComponent();
|
||||||
|
link.setRelation(Bundle.LinkRelationTypes.NEXT);
|
||||||
|
bundle.getLink().add(link);
|
||||||
|
Bundle.BundleLinkComponent returnedLink = bundle.getLink(IBaseBundle.LINK_NEXT);
|
||||||
|
Assertions.assertNotNull(returnedLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Test getLink by string when not present")
|
||||||
|
public void getLinkStringShouldReturnNullWhenNoLinksMatch() {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
Bundle.BundleLinkComponent previousLink = new Bundle.BundleLinkComponent();
|
||||||
|
previousLink.setRelation(Bundle.LinkRelationTypes.PREV);
|
||||||
|
bundle.getLink().add(previousLink);
|
||||||
|
Bundle.BundleLinkComponent returnedLink = bundle.getLink(IBaseBundle.LINK_NEXT);
|
||||||
|
Assertions.assertNull(returnedLink);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue