Merge branch 'master' into gg-202304-more-snapshot

This commit is contained in:
Grahame Grieve 2023-05-24 06:52:50 +10:00 committed by GitHub
commit 87d8323c91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 16 deletions

View File

@ -13,7 +13,7 @@
public BundleLinkComponent getLink(String theRelation) {
org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
for (BundleLinkComponent next : getLink()) {
if (theRelation.equals(next.getRelation())) {
if (theRelation.equals(next.getRelation().toCode())) {
return next;
}
}

View File

@ -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);
}
}