Move test out of IT
This commit is contained in:
parent
416a52c679
commit
d5fe1eeef7
|
@ -76,19 +76,19 @@ public final class MdmResourceUtil {
|
||||||
return theBaseResource.getMeta().getTag(theSystem, theCode) != null;
|
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) {
|
if (theBaseResource == null) {
|
||||||
return false;
|
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) {
|
private static Optional<? extends IBaseCoding> getTagWithSystem(IBaseResource theResource, @Nonnull String theSystem) {
|
||||||
return theResource.getMeta().getTag().stream().filter(tag -> tag.getSystem().equalsIgnoreCase(theSystem)).findFirst();
|
return theResource.getMeta().getTag().stream().filter(tag -> theSystem.equalsIgnoreCase(tag.getSystem())).findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeTagWithSystem(IBaseResource theResource, String theSystem) {
|
public static void removeTagWithSystem(IBaseResource theResource, @Nonnull String theSystem) {
|
||||||
theResource.getMeta().getTag().removeIf(tag -> tag.getSystem().equalsIgnoreCase(theSystem));
|
theResource.getMeta().getTag().removeIf(tag -> theSystem.equalsIgnoreCase(tag.getSystem()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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)));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue