Skip to content

Commit

Permalink
Add Concept json tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 committed Nov 20, 2024
1 parent 67b1b77 commit c2203d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<String, String> meta) {
}
Original file line number Diff line number Diff line change
@@ -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));
}
}

0 comments on commit c2203d1

Please sign in to comment.