Skip to content

Commit

Permalink
of-Methode berücksichtigt display-Attribut
Browse files Browse the repository at this point in the history
  • Loading branch information
oboehm committed Dec 30, 2023
1 parent 3e21cb2 commit 358ce71
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/main/kotlin/de/jfachwert/med/SNOMED.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ open class SNOMED

@JvmStatic
fun of(code: String, display: String): SNOMED {
return WEAK_CACHE.computeIfAbsent(code) { c: String -> SNOMED(c, display) }
var s = WEAK_CACHE.computeIfAbsent(code) { c: String -> SNOMED(c, display) }
if (!display.equals(s.display)) {
s = SNOMED(code, display)
WEAK_CACHE.put(code, s)
}
return s
}
}

Expand Down
14 changes: 11 additions & 3 deletions src/test/java/de/jfachwert/med/SNOMEDTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

import de.jfachwert.AbstractFachwertTest;
import org.junit.jupiter.api.Test;
import patterntesting.runtime.junit.ObjectTester;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertSame;
import static patterntesting.runtime.junit.ObjectTester.assertEquals;

/**
* Unit-Tests fuer {@link SNOMED}.
Expand Down Expand Up @@ -54,7 +54,7 @@ void testWithSameCode() {
SNOMED codeOnly = new SNOMED("373873005:860781008=362943005");
SNOMED withDisplay = new SNOMED("373873005:860781008=362943005",
"Pharmaceutical / biologic product (product) : Has product characteristic (attribute) = Manual method (qualifier value)");
ObjectTester.assertEquals(codeOnly, withDisplay);
assertEquals(codeOnly, withDisplay);
}

@Test
Expand All @@ -67,8 +67,16 @@ void getDisplay() {
void ofWithDisplay() {
SNOMED s1 = SNOMED.of("373873005", "Pharmaceutical / biologic product");
SNOMED s2 = SNOMED.of("373873005");
ObjectTester.assertEquals(s1, s2);
assertEquals(s1, s2);
assertSame(s1, s2);
}

@Test
void ofWithDisplay2nd() {
SNOMED s1 = SNOMED.of("362943005");
SNOMED s2 = SNOMED.of("362943005", "Manual method");
assertEquals(s1, s2);
assertEquals("Manual method", s2.getDisplay());
}

}

0 comments on commit 358ce71

Please sign in to comment.