From a494e2a9d1a70e25fdedc19d50d03d847b42d618 Mon Sep 17 00:00:00 2001 From: Matthew Horridge Date: Wed, 3 Jul 2024 16:44:53 -0700 Subject: [PATCH] Use standard "@type" instead of "type" --- .../webprotege/forms/field/ChoiceListSourceDescriptor.java | 2 +- .../forms/field/DynamicChoiceListSourceDescriptorTest.java | 4 ++-- .../forms/field/FixedChoiceListSourceDescriptorTest.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/stanford/protege/webprotege/forms/field/ChoiceListSourceDescriptor.java b/src/main/java/edu/stanford/protege/webprotege/forms/field/ChoiceListSourceDescriptor.java index 006e3dd..6b7e106 100644 --- a/src/main/java/edu/stanford/protege/webprotege/forms/field/ChoiceListSourceDescriptor.java +++ b/src/main/java/edu/stanford/protege/webprotege/forms/field/ChoiceListSourceDescriptor.java @@ -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 { diff --git a/src/test/java/edu/stanford/protege/webprotege/forms/field/DynamicChoiceListSourceDescriptorTest.java b/src/test/java/edu/stanford/protege/webprotege/forms/field/DynamicChoiceListSourceDescriptorTest.java index 891b2b0..fea3b59 100644 --- a/src/test/java/edu/stanford/protege/webprotege/forms/field/DynamicChoiceListSourceDescriptorTest.java +++ b/src/test/java/edu/stanford/protege/webprotege/forms/field/DynamicChoiceListSourceDescriptorTest.java @@ -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); diff --git a/src/test/java/edu/stanford/protege/webprotege/forms/field/FixedChoiceListSourceDescriptorTest.java b/src/test/java/edu/stanford/protege/webprotege/forms/field/FixedChoiceListSourceDescriptorTest.java index 129add8..36e9c16 100644 --- a/src/test/java/edu/stanford/protege/webprotege/forms/field/FixedChoiceListSourceDescriptorTest.java +++ b/src/test/java/edu/stanford/protege/webprotege/forms/field/FixedChoiceListSourceDescriptorTest.java @@ -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);