forked from MeasureAuthoringTool/madie-qdm-elm-translation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAT-7208: change equals and hashcode for ElementLookup to exclude ID,…
… so uniqueness is more accurate
- Loading branch information
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
9 changes: 8 additions & 1 deletion
9
src/main/java/gov/cms/mat/cql_elm_translation/dto/ElementLookup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/test/java/gov/cms/mat/cql_elm_translation/dto/ElementLookupTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package gov.cms.mat.cql_elm_translation.dto; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.equalTo; | ||
|
||
class ElementLookupTest { | ||
|
||
@Test | ||
void testHashSetUniqueness() { | ||
ElementLookup elementLookup1 = ElementLookup.builder() | ||
.id("ID1") | ||
.oid("111.222.333") | ||
.name("TestCode") | ||
.codeName("TestCodeName") | ||
.codeSystemName("Amazing Code System") | ||
.release("Release1") | ||
.displayName("Test Code") | ||
.datatype("Code") | ||
.build(); | ||
|
||
ElementLookup elementLookup2 = elementLookup1.toBuilder().id("ID2").build(); | ||
|
||
Set<ElementLookup> set = new HashSet<>(); | ||
set.add(elementLookup1); | ||
set.add(elementLookup2); | ||
assertThat(set.size(), is(equalTo(1))); | ||
} | ||
} |