Add tests

This commit is contained in:
juan.marchionatto 2021-09-27 09:47:05 -04:00
parent d03f9cb35b
commit 00ceb3f35d
1 changed files with 102 additions and 0 deletions

View File

@ -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<String> result = TermReadSvcUtil.getValueSetId("http://boinc.org");
assertFalse(result.isPresent());
}
@Test
void doesntStartWithLoincGenericValuesetIdPluSlashReturnsEmpty() {
Optional<String> result = TermReadSvcUtil.getValueSetId("http://loinc.org/vs-something-else.ar");
assertFalse(result.isPresent());
}
@Test
void startWithLoincGenericValuesetIdPluSlashButNothingElseReturnsEmpty() {
Optional<String> result = TermReadSvcUtil.getValueSetId("http://loinc.org/vs/");
assertFalse(result.isPresent());
}
@Test
void startWithLoincGenericValuesetIdPluSlashPlusIdReturnsId() {
Optional<String> 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);
}
}
}