diff --git a/sdmx30-infomodel/src/main/java/com/epam/jsdmx/infomodel/sdmx30/SdmxUrn.java b/sdmx30-infomodel/src/main/java/com/epam/jsdmx/infomodel/sdmx30/SdmxUrn.java index 9da143a..40a4c65 100644 --- a/sdmx30-infomodel/src/main/java/com/epam/jsdmx/infomodel/sdmx30/SdmxUrn.java +++ b/sdmx30-infomodel/src/main/java/com/epam/jsdmx/infomodel/sdmx30/SdmxUrn.java @@ -20,10 +20,10 @@ public class SdmxUrn { private static final Pattern FULL_URN_PATTERN = Pattern.compile( "^" + URN_SDMX - + "(?\\w+(\\.\\w+)*)=" + + "(?[\\w.]+)=" + "(?[\\w.-]+):(?[\\w@$-]+)" - + "\\((?(\\d+\\.\\d+)|(\\d+\\.\\d+\\.\\d+(-[\\w-]+)?)|(\\d+\\+\\.\\d+\\.\\d+)|(\\d+\\.\\d+\\+\\.\\d+)|(\\d+\\.\\d+\\.\\d+\\+))\\)" - + "(\\.(?([\\w@$-]+)+(\\.[\\w@$-]+)*))?$" + + "\\((?(\\d+\\+?)(\\.\\d+\\+?){1,2}(-[\\w-]+)?)\\)" + + "(\\.(?[\\w@$-]+(\\.[\\w@$-]+)*))?$" ); private static final Pattern SHORT_URN_PATTERN = Pattern.compile( diff --git a/sdmx30-infomodel/src/test/java/com/epam/jsdmx/infomodel/sdmx30/SdmxUrnTest.java b/sdmx30-infomodel/src/test/java/com/epam/jsdmx/infomodel/sdmx30/SdmxUrnTest.java index 147970c..60dcd78 100644 --- a/sdmx30-infomodel/src/test/java/com/epam/jsdmx/infomodel/sdmx30/SdmxUrnTest.java +++ b/sdmx30-infomodel/src/test/java/com/epam/jsdmx/infomodel/sdmx30/SdmxUrnTest.java @@ -139,6 +139,13 @@ void testGetUrnComponents(String urn, UrnComponents expected) { assertThat(SdmxUrn.getUrnComponents(urn)).isEqualTo(expected); } + @Test + void testGetUrnComponents_notValidUrn() { + var t = assertThrows(IllegalArgumentException.class, () -> SdmxUrn.getUrnComponents("urn:sdmx:org.sdmx.infomodel.conceptscheme.Concept=IMF_RES:CS_CSD_CPA(3.0+.0).CPA_RA_330_OTHER_RISKS_(PLEASE_SPECIFY)")); + + assertThat(t).hasMessage("Invalid urn: urn:sdmx:org.sdmx.infomodel.conceptscheme.Concept=IMF_RES:CS_CSD_CPA(3.0+.0).CPA_RA_330_OTHER_RISKS_(PLEASE_SPECIFY)"); + } + private static Stream testGetUrnComponents() { return Stream.of( Arguments.of("urn:sdmx:org.sdmx.infomodel.datastructure.DataStructure=ECB:ECB_EXR12(1.0)", UrnComponents.builder()