diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/dictionary/Concept.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/dictionary/Concept.java index 6fe4f706..cef0fcf8 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/dictionary/Concept.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/dictionary/Concept.java @@ -1,6 +1,9 @@ package edu.harvard.hms.dbmi.avillach.hpds.processing.dictionary; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + import java.util.Map; +@JsonIgnoreProperties(ignoreUnknown = true) public record Concept(String type, String conceptPath, String name, String display, String dataset, String description, Map meta) { } diff --git a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/dictionary/ConceptTest.java b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/dictionary/ConceptTest.java new file mode 100644 index 00000000..733f46fa --- /dev/null +++ b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/dictionary/ConceptTest.java @@ -0,0 +1,25 @@ +package edu.harvard.hms.dbmi.avillach.hpds.processing.dictionary; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; + +public class ConceptTest { + + @Test + public void jsonSerialization() throws JsonProcessingException { + Concept[] concepts = new Concept[]{new Concept("Categorical", "\\demographics\\age\\", "age", "AGE", null, "patient age", Map.of("drs_uri", "[\"a-drs.uri\", \"another-drs.uri\"]"))}; + ObjectMapper objectMapper = new ObjectMapper(); + + String serialized = objectMapper.writeValueAsString(concepts); + + Concept[] deserialized = objectMapper.readValue(serialized, Concept[].class); + + assertEquals(List.of(concepts), List.of(deserialized)); + } +} \ No newline at end of file