|
| 1 | +package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.validation; |
| 2 | + |
| 3 | +import static org.junit.Assert.assertEquals; |
| 4 | +import static org.junit.Assert.assertNull; |
| 5 | +import static org.junit.Assert.assertTrue; |
| 6 | + |
| 7 | +import java.io.InputStream; |
| 8 | +import java.nio.file.Files; |
| 9 | +import java.nio.file.Paths; |
| 10 | + |
| 11 | +import org.fhir.ucum.UcumEssenceService; |
| 12 | +import org.junit.Test; |
| 13 | + |
| 14 | +public class UcumLearningTest |
| 15 | +{ |
| 16 | + @Test |
| 17 | + public void test() throws Exception |
| 18 | + { |
| 19 | + String theCode = "{beats}/min"; |
| 20 | + try (InputStream input = Files.newInputStream(Paths.get("src/test/resources/fhir/ucum/ucum-essence.xml"))) |
| 21 | + { |
| 22 | + UcumEssenceService svc = new UcumEssenceService(input); |
| 23 | + assertEquals("1 / (minute)", svc.analyse(theCode)); |
| 24 | + assertEquals("s-1", svc.getCanonicalUnits(theCode)); |
| 25 | + assertTrue(svc.getDefinedForms(theCode).isEmpty()); |
| 26 | + assertNull(svc.validate(theCode)); |
| 27 | + assertEquals("{beats}/min", svc.getCommonDisplay(theCode)); |
| 28 | + assertTrue(svc.isComparable(theCode, "/min")); |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + @Test |
| 33 | + public void test1() throws Exception |
| 34 | + { |
| 35 | + String theCode = "/min"; |
| 36 | + try (InputStream input = Files.newInputStream(Paths.get("src/test/resources/fhir/ucum/ucum-essence.xml"))) |
| 37 | + { |
| 38 | + UcumEssenceService svc = new UcumEssenceService(input); |
| 39 | + assertEquals(" / (minute)", svc.analyse(theCode)); |
| 40 | + assertEquals("s-1", svc.getCanonicalUnits(theCode)); |
| 41 | + assertTrue(svc.getDefinedForms(theCode).isEmpty()); |
| 42 | + assertNull(svc.validate(theCode)); |
| 43 | + assertEquals("/min", svc.getCommonDisplay(theCode)); |
| 44 | + assertTrue(svc.isComparable(theCode, "/min")); |
| 45 | + } |
| 46 | + } |
| 47 | +} |
0 commit comments