Skip to content

Commit

Permalink
Use standard "@type" instead of "type"
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhorridge committed Jul 3, 2024
1 parent 79bba83 commit a494e2a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Stanford Center for Biomedical Informatics Research
* 2020-01-11
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
@JsonSubTypes({@JsonSubTypes.Type(value = FixedChoiceListSourceDescriptor.class, name = FixedChoiceListSourceDescriptor.TYPE), @JsonSubTypes.Type(value = DynamicChoiceListSourceDescriptor.class, name = DynamicChoiceListSourceDescriptor.TYPE)})
public interface ChoiceListSourceDescriptor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class DynamicChoiceListSourceDescriptorTest {
void shouldSerialize() throws IOException {
var written = tester.write(DynamicChoiceListSourceDescriptor.get(CompositeRootCriteria.get(List.of(), MultiMatchType.ALL)));
System.out.println(written.getJson());
assertThat(written).hasJsonPathStringValue("type", "Dynamic");
assertThat(written).hasJsonPathStringValue("['@type']", "Dynamic");
assertThat(written).hasJsonPathValue("criteria");
}

@Test
void shouldDeserialize() throws IOException {
var json = """
{"type":"Dynamic","criteria":{"match":"CompositeCriteria","criteria":[],"matchType":"ALL"}}
{"@type":"Dynamic","criteria":{"match":"CompositeCriteria","criteria":[],"matchType":"ALL"}}
""";
var read = tester.read(new StringReader(json));
assertThat(read).isInstanceOf(DynamicChoiceListSourceDescriptor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class FixedChoiceListSourceDescriptorTest {
void shouldSerialize() throws IOException {
var written = tester.write(FixedChoiceListSourceDescriptor.get(ImmutableList.of()));
System.out.println(written.getJson());
assertThat(written).hasJsonPathStringValue("type", "Dynamic");
assertThat(written).hasJsonPathStringValue("['@type']", "Fixed");
assertThat(written).hasJsonPathValue("choices");
}

@Test
void shouldDeserialize() throws IOException {
var json = """
{"type":"Fixed","choices":[]}
{"@type":"Fixed","choices":[]}
""";
var read = tester.read(new StringReader(json));
assertThat(read).isInstanceOf(FixedChoiceListSourceDescriptor.class);
Expand Down

0 comments on commit a494e2a

Please sign in to comment.