Move test out of IT

This commit is contained in:
Tadgh 2021-08-09 16:13:47 -04:00
parent 416a52c679
commit d5fe1eeef7
2 changed files with 29 additions and 6 deletions

View File

@ -76,19 +76,19 @@ public final class MdmResourceUtil {
return theBaseResource.getMeta().getTag(theSystem, theCode) != null;
}
private static boolean resourceHasTagWithSystem(IBaseResource theBaseResource, String theSystem) {
private static boolean resourceHasTagWithSystem(IBaseResource theBaseResource, @Nonnull String theSystem) {
if (theBaseResource == null) {
return false;
}
return theBaseResource.getMeta().getTag().stream().anyMatch(tag -> tag.getSystem().equalsIgnoreCase(theSystem));
return theBaseResource.getMeta().getTag().stream().anyMatch(tag -> theSystem.equalsIgnoreCase(tag.getSystem()));
}
private static Optional<? extends IBaseCoding> getTagWithSystem(IBaseResource theResource, String theSystem) {
return theResource.getMeta().getTag().stream().filter(tag -> tag.getSystem().equalsIgnoreCase(theSystem)).findFirst();
private static Optional<? extends IBaseCoding> getTagWithSystem(IBaseResource theResource, @Nonnull String theSystem) {
return theResource.getMeta().getTag().stream().filter(tag -> theSystem.equalsIgnoreCase(tag.getSystem())).findFirst();
}
public static void removeTagWithSystem(IBaseResource theResource, String theSystem) {
theResource.getMeta().getTag().removeIf(tag -> tag.getSystem().equalsIgnoreCase(theSystem));
public static void removeTagWithSystem(IBaseResource theResource, @Nonnull String theSystem) {
theResource.getMeta().getTag().removeIf(tag -> theSystem.equalsIgnoreCase(tag.getSystem()));
}
/**

View File

@ -0,0 +1,23 @@
package ca.uhn.fhir.mdm.util;
import org.hl7.fhir.r4.model.Organization;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
class MdmResourceUtilTest {
//See https://github.com/hapifhir/hapi-fhir/issues/2876
@Test
public void testNoNpeOnTagWithNoSystem() {
//Given
Organization organization = new Organization();
organization.getMeta().addTag(null, "Some Code", "Some Display");
boolean hasGoldenRecordTag = MdmResourceUtil.hasGoldenRecordSystemTag(organization);
assertThat(hasGoldenRecordTag, is(equalTo(false)));
}
}