From 00ceb3f35da5e40ca8bba3982174d5d2d02342d2 Mon Sep 17 00:00:00 2001 From: "juan.marchionatto" Date: Mon, 27 Sep 2021 09:47:05 -0400 Subject: [PATCH] Add tests --- .../fhir/jpa/term/TermReadSvcUtilTest.java | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermReadSvcUtilTest.java diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermReadSvcUtilTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermReadSvcUtilTest.java new file mode 100644 index 00000000000..4927edca0f6 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermReadSvcUtilTest.java @@ -0,0 +1,102 @@ +package ca.uhn.fhir.jpa.term; + +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class TermReadSvcUtilTest { + + @Nested + public class GetValueSetId { + + @Test + void doesntStartWithLoincGenericValuesetIdReturnsEmpty() { + Optional result = TermReadSvcUtil.getValueSetId("http://boinc.org"); + assertFalse(result.isPresent()); + } + + @Test + void doesntStartWithLoincGenericValuesetIdPluSlashReturnsEmpty() { + Optional result = TermReadSvcUtil.getValueSetId("http://loinc.org/vs-something-else.ar"); + assertFalse(result.isPresent()); + } + + @Test + void startWithLoincGenericValuesetIdPluSlashButNothingElseReturnsEmpty() { + Optional result = TermReadSvcUtil.getValueSetId("http://loinc.org/vs/"); + assertFalse(result.isPresent()); + } + + @Test + void startWithLoincGenericValuesetIdPluSlashPlusIdReturnsId() { + Optional result = TermReadSvcUtil.getValueSetId("http://loinc.org/vs/radiology-playbook"); + assertTrue(result.isPresent()); + } + } + + + @Nested + public class IsLoincNotGenericUnversionedValueSet { + + @Test + void doesntContainLoincReturnsFalse() { + boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet( + "http://l-oinc.org/vs/radiology-playbook"); + assertFalse(result); + } + + @Test + void containsVersionDelimiterReturnsFalse() { + boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet( + "http://loinc.org/vs/radiology-playbook|v2.68"); + assertFalse(result); + } + + @Test + void isLoincGenericValueSetUrlReturnsFalse() { + boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet( + "http://loinc.org/vs"); + assertFalse(result); + } + + @Test + void isLoincWithoutVersionAndNotGenericValuesetUrlReturnsTrue() { + boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet( + "http://loinc.org/vs/radiology-playbook"); + assertTrue(result); + } + + } + + + @Nested + public class IsLoincNotGenericUnversionedCodeSystem { + + @Test + void doesntContainLoincReturnsFalse() { + boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem( + "http://loin-c.org"); + assertFalse(result); + } + + @Test + void hasVersionDelimiterReturnsFalse() { + boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem( + "http://loinc.org|v2.68"); + assertFalse(result); + } + + @Test + void containsLoincNadNoVersionDelimiterReturnsTrue() { + boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem( + "http://loinc.org"); + assertTrue(result); + } + + } + +}