From 47a536f5a5aa95134eb427b2830edb45d78306d2 Mon Sep 17 00:00:00 2001 From: Simon Cockx Date: Mon, 26 Jan 2026 15:53:55 +0100 Subject: [PATCH] Added unit test --- .../RosettaBeanDeserializerModifier.java | 6 +-- .../RosettaDataValueObjectToStringTest.java | 22 +++++++++- .../xml/SubstitutionGroupTest.java | 40 +++++++++++++++++++ .../substitution-group/types.rosetta | 9 +++++ .../substitution-group/xml-config.json | 16 ++++++++ 5 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 common/src/test/java/com/regnosys/rosetta/common/serialisation/xml/SubstitutionGroupTest.java create mode 100644 common/src/test/resources/rosetta/xml-serialisation/substitution-group/types.rosetta create mode 100644 common/src/test/resources/rosetta/xml-serialisation/substitution-group/xml-config.json diff --git a/common/src/main/java/com/regnosys/rosetta/common/serialisation/xml/deserialization/RosettaBeanDeserializerModifier.java b/common/src/main/java/com/regnosys/rosetta/common/serialisation/xml/deserialization/RosettaBeanDeserializerModifier.java index 88095fcec..5baa2ab5c 100644 --- a/common/src/main/java/com/regnosys/rosetta/common/serialisation/xml/deserialization/RosettaBeanDeserializerModifier.java +++ b/common/src/main/java/com/regnosys/rosetta/common/serialisation/xml/deserialization/RosettaBeanDeserializerModifier.java @@ -52,9 +52,9 @@ public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, for (PropertyName propName : propNames) { SettableBeanProperty prop = builder.findProperty(propName); // Skip if already a SubstitutedMethodProperty to avoid double-processing - if (!(prop instanceof MethodProperty)) { - continue; - } +// if (!(prop instanceof MethodProperty)) { +// continue; +// } AnnotatedMember acc = prop.getMember(); SubstitutionMap substitutionMap = substitutionMapLoader.findSubstitutionMap(config, intr, acc); diff --git a/common/src/test/java/com/regnosys/rosetta/common/serialisation/RosettaDataValueObjectToStringTest.java b/common/src/test/java/com/regnosys/rosetta/common/serialisation/RosettaDataValueObjectToStringTest.java index 873abe749..5061a54e5 100644 --- a/common/src/test/java/com/regnosys/rosetta/common/serialisation/RosettaDataValueObjectToStringTest.java +++ b/common/src/test/java/com/regnosys/rosetta/common/serialisation/RosettaDataValueObjectToStringTest.java @@ -1,5 +1,25 @@ package com.regnosys.rosetta.common.serialisation; +/*- + * ============== + * Rune Common + * ============== + * Copyright (C) 2018 - 2026 REGnosys + * ============== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============== + */ + import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -52,4 +72,4 @@ public void testOtherObjectsToString() { Boolean bool = true; assertEquals("true", RosettaDataValueObjectToString.toValueString(bool)); } -} \ No newline at end of file +} diff --git a/common/src/test/java/com/regnosys/rosetta/common/serialisation/xml/SubstitutionGroupTest.java b/common/src/test/java/com/regnosys/rosetta/common/serialisation/xml/SubstitutionGroupTest.java new file mode 100644 index 000000000..f3a55b76a --- /dev/null +++ b/common/src/test/java/com/regnosys/rosetta/common/serialisation/xml/SubstitutionGroupTest.java @@ -0,0 +1,40 @@ +package com.regnosys.rosetta.common.serialisation.xml; + +/*- + * ============== + * Rune Common + * ============== + * Copyright (C) 2018 - 2026 REGnosys + * ============== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============== + */ + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.regnosys.rosetta.common.serialisation.RosettaObjectMapperCreator; +import org.junit.jupiter.api.Test; +import test.substitution.Root; + +import java.io.IOException; +import java.io.InputStream; + +public class SubstitutionGroupTest { + @Test + void testSubstitutedElementOverlapsWithExistingElement() throws JsonProcessingException, IOException { + try (InputStream configStream = getClass().getResourceAsStream("/rosetta/xml-serialisation/substitution-group/xml-config.json")) { + ObjectMapper mapper = RosettaObjectMapperCreator.forXML(configStream).create(); + Root root = mapper.readValue("", Root.class); + } + } +} diff --git a/common/src/test/resources/rosetta/xml-serialisation/substitution-group/types.rosetta b/common/src/test/resources/rosetta/xml-serialisation/substitution-group/types.rosetta new file mode 100644 index 000000000..eaa784552 --- /dev/null +++ b/common/src/test/resources/rosetta/xml-serialisation/substitution-group/types.rosetta @@ -0,0 +1,9 @@ +namespace test.substitution + +type Root: + substituted Parent (1..1) + foo Foo (1..1) + +type Parent: + +type Foo: diff --git a/common/src/test/resources/rosetta/xml-serialisation/substitution-group/xml-config.json b/common/src/test/resources/rosetta/xml-serialisation/substitution-group/xml-config.json new file mode 100644 index 000000000..3766fb7c3 --- /dev/null +++ b/common/src/test/resources/rosetta/xml-serialisation/substitution-group/xml-config.json @@ -0,0 +1,16 @@ +{ + "test.substitution.Root": { + "attributes": { + "substituted": { + "elementRef": "urn:schema/substituted", + "substitutionGroup": "urn:schema/substituted" + } + } + }, + "test.substitution.Foo": { + "substitutionGroup": "urn:schema/substituted", + "xmlElementName": "foo", + "xmlElementFullyQualifiedName": "urn:schema/foo", + "abstract": false + } +}