From acd3d78f38e877ade7a6be7c5049c5031815429a Mon Sep 17 00:00:00 2001 From: "payal.khanna" Date: Wed, 8 Apr 2026 10:47:36 +0100 Subject: [PATCH 1/4] fix path for multi-platform --- .../com/regnosys/testing/GeneratedCode.java | 2 +- .../pipeline/PipelineTestPackWriter.java | 5 +++-- .../SchemeImporterTestHelper.java | 21 +++++++++++-------- .../schemeimport/LatestSchemesImportTest.java | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/regnosys/testing/GeneratedCode.java b/src/main/java/com/regnosys/testing/GeneratedCode.java index f9f97cac..e60ad5af 100644 --- a/src/main/java/com/regnosys/testing/GeneratedCode.java +++ b/src/main/java/com/regnosys/testing/GeneratedCode.java @@ -63,7 +63,7 @@ public void writeClasses(String directory) throws IOException { } private String toJavaFile(String className) { - return className.replace(".", File.separator) + ".java"; + return className.replace(".", "/") + ".java"; } } diff --git a/src/main/java/com/regnosys/testing/pipeline/PipelineTestPackWriter.java b/src/main/java/com/regnosys/testing/pipeline/PipelineTestPackWriter.java index 49a009ee..2c6f67cc 100644 --- a/src/main/java/com/regnosys/testing/pipeline/PipelineTestPackWriter.java +++ b/src/main/java/com/regnosys/testing/pipeline/PipelineTestPackWriter.java @@ -43,6 +43,7 @@ import org.xml.sax.SAXException; import jakarta.inject.Inject; + import javax.xml.XMLConstants; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; @@ -207,7 +208,7 @@ private TestPackModel writeTestPackSamples(Path resourcesPath, String baseFileName = getBaseFileName(inputSample.toUri().toURL()); String displayName = baseFileName.replace("-", " "); - TestPackModel.SampleModel sampleModel = new TestPackModel.SampleModel(baseFileName.toLowerCase(), displayName, inputSample.toString(), outputPath.toString(), assertions); + TestPackModel.SampleModel sampleModel = new TestPackModel.SampleModel(baseFileName.toLowerCase(), displayName, inputSample.toString().replace('\\', '/'), outputPath.toString().replace('\\', '/'), assertions); sampleModels.add(sampleModel); Files.createDirectories(resourcesPath.resolve(outputPath).getParent()); @@ -279,7 +280,7 @@ private Map> filterAndGroupingByTestPackId(Path resourcesPath private String testPackId(Path resourcesPath, Path inputPath, Path samplePath) { Path parent = samplePath.getParent(); Path relativePath = resourcesPath.relativize(inputPath).relativize(parent); - return relativePath.toString().replace(File.separatorChar, '-'); + return relativePath.toString().replace('\\', '/').replace('/', '-'); } private @NotNull Map> filterTestPacks(PipelineNode pipelineNode, PipelineTestPackFilter pipelineTestPackFilter, Map> testPackToSamples) { diff --git a/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java b/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java index 9f5111f8..f3e2418c 100644 --- a/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java +++ b/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java @@ -9,9 +9,9 @@ * 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. @@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory; import jakarta.inject.Inject; + import java.io.IOException; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -58,6 +59,7 @@ public enum EnumComparison { */ AdditiveMatch } + private static final Logger LOGGER = LoggerFactory.getLogger(SchemeImporterTestHelper.class); @Inject private SchemeImporter schemeImporter; @@ -72,7 +74,7 @@ public void checkEnumsAreValid(String rosettaPathRoot, String body, String codin List models = modelLoader.loadRosettaModels(rosettaPaths); List rosettaEnumsFromModel = schemeImporter.getRosettaEnumsFromModel(models, body, codingScheme); - if(writeTestOutput) { + if (writeTestOutput) { persistEnumValues(rosettaEnumsFromModel, schemeEnumReader, enumComparison); } @@ -81,7 +83,7 @@ public void checkEnumsAreValid(String rosettaPathRoot, String body, String codin private void persistEnumValues(List rosettaEnumsFromModel, SchemeEnumReader schemeEnumReader, EnumComparison enumComparison) throws IOException { Map generatedFromScheme = null; - switch (enumComparison){ + switch (enumComparison) { case ExactMatch: { for (RosettaEnumeration rosettaEnumeration : rosettaEnumsFromModel) { List codingSchemeEnumValues = schemeImporter.getEnumValuesFromCodingScheme(rosettaEnumeration, schemeEnumReader); @@ -98,7 +100,8 @@ private void persistEnumValues(List rosettaEnumsFromModel, S generatedFromScheme = schemeImporter.generateRosettaEnums(rosettaEnumsFromModel); break; } - default: throw new IllegalArgumentException("Unknown enum value " + enumComparison); + default: + throw new IllegalArgumentException("Unknown enum value " + enumComparison); } assertNotNull(generatedFromScheme); writeTestOutput(generatedFromScheme); @@ -108,7 +111,7 @@ private void persistEnumValues(List rosettaEnumsFromModel, S boolean compareEnumValues(List modelEnumValues, List codingSchemeEnumValues, EnumComparison enumComparison) { if (enumComparison == EnumComparison.ExactMatch) { return CollectionUtils.listMatch(codingSchemeEnumValues, modelEnumValues, (a, b) -> enumValueComparator.compare(a, b) == 0); - } else if(enumComparison == EnumComparison.AdditiveMatch){ + } else if (enumComparison == EnumComparison.AdditiveMatch) { return CollectionUtils.collectionContains(codingSchemeEnumValues, modelEnumValues, (a, b) -> enumValueComparator.compare(a, b) == 0); } return false; @@ -140,7 +143,7 @@ protected String getContents(URL[] rosettaPaths, String fileName) throws IOExcep } protected String getFileName(String path) { - return path.substring(path.lastIndexOf('/') + 1); + return path.substring(Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')) + 1); } protected void writeTestOutput(Map rosettaExpected) throws IOException { @@ -174,8 +177,8 @@ private void overwriteEnums(RosettaEnumeration rosettaEnumeration, List newEnumValues) { List newEnumNamesList = newEnumValues.stream().map(n -> n.getName()).collect(Collectors.toList()); List removedEnums = rosettaEnumeration.getEnumValues().stream() - .filter(e-> !newEnumNamesList.contains(e.getName())) - .collect(Collectors.toList()); + .filter(e -> !newEnumNamesList.contains(e.getName())) + .collect(Collectors.toList()); //add any items removed in the latest Coding Scheme at the end newEnumValues.addAll(removedEnums); diff --git a/src/test/java/com/regnosys/testing/schemeimport/LatestSchemesImportTest.java b/src/test/java/com/regnosys/testing/schemeimport/LatestSchemesImportTest.java index 20f9ca59..4e12ed56 100644 --- a/src/test/java/com/regnosys/testing/schemeimport/LatestSchemesImportTest.java +++ b/src/test/java/com/regnosys/testing/schemeimport/LatestSchemesImportTest.java @@ -84,7 +84,7 @@ private static void unzip() { boolean isDirectory = false; //check for files or directory - if (zipEntry.getName().endsWith(File.separator)) { + if (zipEntry.getName().endsWith("/") || zipEntry.getName().endsWith("\\")) { isDirectory = true; } From 00f341be92b5e9cfc6ce6dca25ae5bf9f52d7670 Mon Sep 17 00:00:00 2001 From: "payal.khanna" Date: Mon, 13 Apr 2026 15:57:58 +0100 Subject: [PATCH 2/4] use UrlUtils.toPortableString for make it compatible for multi-platform --- .../regnosys/testing/pipeline/PipelineTestPackWriter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/regnosys/testing/pipeline/PipelineTestPackWriter.java b/src/main/java/com/regnosys/testing/pipeline/PipelineTestPackWriter.java index 2c6f67cc..0ff610c4 100644 --- a/src/main/java/com/regnosys/testing/pipeline/PipelineTestPackWriter.java +++ b/src/main/java/com/regnosys/testing/pipeline/PipelineTestPackWriter.java @@ -34,6 +34,7 @@ import com.regnosys.rosetta.common.transform.PipelineModel; import com.regnosys.rosetta.common.transform.TestPackModel; import com.regnosys.rosetta.common.transform.TransformType; +import com.regnosys.rosetta.common.util.UrlUtils; import com.regnosys.rosetta.common.validation.ValidationReport; import com.regnosys.testing.reports.ObjectMapperGenerator; import com.regnosys.testing.validation.ValidationSummariser; @@ -43,7 +44,6 @@ import org.xml.sax.SAXException; import jakarta.inject.Inject; - import javax.xml.XMLConstants; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; @@ -208,7 +208,7 @@ private TestPackModel writeTestPackSamples(Path resourcesPath, String baseFileName = getBaseFileName(inputSample.toUri().toURL()); String displayName = baseFileName.replace("-", " "); - TestPackModel.SampleModel sampleModel = new TestPackModel.SampleModel(baseFileName.toLowerCase(), displayName, inputSample.toString().replace('\\', '/'), outputPath.toString().replace('\\', '/'), assertions); + TestPackModel.SampleModel sampleModel = new TestPackModel.SampleModel(baseFileName.toLowerCase(), displayName, UrlUtils.toPortableString(inputSample), UrlUtils.toPortableString(outputPath), assertions); sampleModels.add(sampleModel); Files.createDirectories(resourcesPath.resolve(outputPath).getParent()); @@ -280,7 +280,7 @@ private Map> filterAndGroupingByTestPackId(Path resourcesPath private String testPackId(Path resourcesPath, Path inputPath, Path samplePath) { Path parent = samplePath.getParent(); Path relativePath = resourcesPath.relativize(inputPath).relativize(parent); - return relativePath.toString().replace('\\', '/').replace('/', '-'); + return UrlUtils.toPortableString(relativePath).replace(File.separatorChar, '-'); } private @NotNull Map> filterTestPacks(PipelineNode pipelineNode, PipelineTestPackFilter pipelineTestPackFilter, Map> testPackToSamples) { From 992cc55fedae703a8069dbf38c9234b6e820e335 Mon Sep 17 00:00:00 2001 From: "payal.khanna" Date: Mon, 13 Apr 2026 15:59:06 +0100 Subject: [PATCH 3/4] revert changes --- src/main/java/com/regnosys/testing/GeneratedCode.java | 2 +- .../regnosys/testing/schemeimport/SchemeImporterTestHelper.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/regnosys/testing/GeneratedCode.java b/src/main/java/com/regnosys/testing/GeneratedCode.java index e60ad5af..f9f97cac 100644 --- a/src/main/java/com/regnosys/testing/GeneratedCode.java +++ b/src/main/java/com/regnosys/testing/GeneratedCode.java @@ -63,7 +63,7 @@ public void writeClasses(String directory) throws IOException { } private String toJavaFile(String className) { - return className.replace(".", "/") + ".java"; + return className.replace(".", File.separator) + ".java"; } } diff --git a/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java b/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java index f3e2418c..340b1afa 100644 --- a/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java +++ b/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java @@ -143,7 +143,7 @@ protected String getContents(URL[] rosettaPaths, String fileName) throws IOExcep } protected String getFileName(String path) { - return path.substring(Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\')) + 1); + return path.substring(path.lastIndexOf('/') + 1); } protected void writeTestOutput(Map rosettaExpected) throws IOException { From cb7d2358de166ec236159907db4bb4dd782f097b Mon Sep 17 00:00:00 2001 From: "payal.khanna" Date: Mon, 13 Apr 2026 16:02:07 +0100 Subject: [PATCH 4/4] revert changes --- .../schemeimport/SchemeImporterTestHelper.java | 15 ++++++--------- .../schemeimport/LatestSchemesImportTest.java | 7 ++++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java b/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java index 340b1afa..0f71c5e0 100644 --- a/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java +++ b/src/main/java/com/regnosys/testing/schemeimport/SchemeImporterTestHelper.java @@ -33,7 +33,6 @@ import org.slf4j.LoggerFactory; import jakarta.inject.Inject; - import java.io.IOException; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -59,7 +58,6 @@ public enum EnumComparison { */ AdditiveMatch } - private static final Logger LOGGER = LoggerFactory.getLogger(SchemeImporterTestHelper.class); @Inject private SchemeImporter schemeImporter; @@ -74,7 +72,7 @@ public void checkEnumsAreValid(String rosettaPathRoot, String body, String codin List models = modelLoader.loadRosettaModels(rosettaPaths); List rosettaEnumsFromModel = schemeImporter.getRosettaEnumsFromModel(models, body, codingScheme); - if (writeTestOutput) { + if(writeTestOutput) { persistEnumValues(rosettaEnumsFromModel, schemeEnumReader, enumComparison); } @@ -83,7 +81,7 @@ public void checkEnumsAreValid(String rosettaPathRoot, String body, String codin private void persistEnumValues(List rosettaEnumsFromModel, SchemeEnumReader schemeEnumReader, EnumComparison enumComparison) throws IOException { Map generatedFromScheme = null; - switch (enumComparison) { + switch (enumComparison){ case ExactMatch: { for (RosettaEnumeration rosettaEnumeration : rosettaEnumsFromModel) { List codingSchemeEnumValues = schemeImporter.getEnumValuesFromCodingScheme(rosettaEnumeration, schemeEnumReader); @@ -100,8 +98,7 @@ private void persistEnumValues(List rosettaEnumsFromModel, S generatedFromScheme = schemeImporter.generateRosettaEnums(rosettaEnumsFromModel); break; } - default: - throw new IllegalArgumentException("Unknown enum value " + enumComparison); + default: throw new IllegalArgumentException("Unknown enum value " + enumComparison); } assertNotNull(generatedFromScheme); writeTestOutput(generatedFromScheme); @@ -111,7 +108,7 @@ private void persistEnumValues(List rosettaEnumsFromModel, S boolean compareEnumValues(List modelEnumValues, List codingSchemeEnumValues, EnumComparison enumComparison) { if (enumComparison == EnumComparison.ExactMatch) { return CollectionUtils.listMatch(codingSchemeEnumValues, modelEnumValues, (a, b) -> enumValueComparator.compare(a, b) == 0); - } else if (enumComparison == EnumComparison.AdditiveMatch) { + } else if(enumComparison == EnumComparison.AdditiveMatch){ return CollectionUtils.collectionContains(codingSchemeEnumValues, modelEnumValues, (a, b) -> enumValueComparator.compare(a, b) == 0); } return false; @@ -177,8 +174,8 @@ private void overwriteEnums(RosettaEnumeration rosettaEnumeration, List newEnumValues) { List newEnumNamesList = newEnumValues.stream().map(n -> n.getName()).collect(Collectors.toList()); List removedEnums = rosettaEnumeration.getEnumValues().stream() - .filter(e -> !newEnumNamesList.contains(e.getName())) - .collect(Collectors.toList()); + .filter(e-> !newEnumNamesList.contains(e.getName())) + .collect(Collectors.toList()); //add any items removed in the latest Coding Scheme at the end newEnumValues.addAll(removedEnums); diff --git a/src/test/java/com/regnosys/testing/schemeimport/LatestSchemesImportTest.java b/src/test/java/com/regnosys/testing/schemeimport/LatestSchemesImportTest.java index 798b1b04..20f9ca59 100644 --- a/src/test/java/com/regnosys/testing/schemeimport/LatestSchemesImportTest.java +++ b/src/test/java/com/regnosys/testing/schemeimport/LatestSchemesImportTest.java @@ -62,7 +62,7 @@ public void downloadLatestVersions() throws IOException, NoSuchAlgorithmExceptio deleteFileFolder(new File(LatestSchemesImportTest.CODE_LIST_ZIP)); deleteFileFolder(new File(LatestSchemesImportTest.CODE_LIST)); } - assertEquals("39a7fdb456d6c5b38272bd973fd0203a", checksum, "CodeList zip has been updated, run again with WRITE_EXPECTATIONS enabled then update expected checksum"); + assertEquals("c8d253d3d7ef86d2c88e10cf8a2ce50a", checksum, "CodeList zip has been updated, run again with WRITE_EXPECTATIONS enabled then update expected checksum"); } } @@ -84,7 +84,7 @@ private static void unzip() { boolean isDirectory = false; //check for files or directory - if (zipEntry.getName().endsWith("/") || zipEntry.getName().endsWith("\\")) { + if (zipEntry.getName().endsWith(File.separator)) { isDirectory = true; } @@ -142,7 +142,8 @@ private void moveFilesToFpml() { System.out.println("copying " + path.toString()); Path d2 = destinationDir.resolve(path.getFileName()); System.out.println("destination File=" + d2); - Files.move(path, d2, StandardCopyOption.REPLACE_EXISTING); + if (Files.notExists(d2)) + Files.move(path, d2, StandardCopyOption.REPLACE_EXISTING); } } catch (IOException ex) { ex.printStackTrace();