From ed9f6c24bacd4504825e1a98e23ef25d6e995d63 Mon Sep 17 00:00:00 2001 From: Robert Csakany Date: Sat, 2 Nov 2024 04:06:51 +0100 Subject: [PATCH 1/6] JNG-5995 Initial feature commit [ci skip] From 5af20bceaac150698355f1abfa77ecf3a3b015cc Mon Sep 17 00:00:00 2001 From: Robert Csakany Date: Sat, 2 Nov 2024 11:35:02 +0100 Subject: [PATCH 2/6] Versions updated --- pom.xml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 768402f1..ffcaef8e 100644 --- a/pom.xml +++ b/pom.xml @@ -76,8 +76,9 @@ 17 ${maven.multiModuleProjectDirectory}/logback-test.xml + 1.5.12 - 4.0.7 + 4.0.9 1.1.1.20240410_065331_3400dfa6_develop 1.1.2.20240410_075618_a6090f79_develop @@ -89,9 +90,9 @@ 2.32.0 2.15.0 - 2.0.7 + 2.0.16 - 3.0.0 + 3.5.1 ${maven.multiModuleProjectDirectory}/logback-test.xml @@ -101,7 +102,7 @@ 1.1.1.20240410_085121_bdac833a_develop 2.0.2.20240410_083849_8b6fbfb2_develop - 4.13.4 + 4.13.5 @@ -115,7 +116,7 @@ jacoco java ${java.version} - 0.8.8 + 0.8.12 1.0.0.20230826_231644_c0933832_develop @@ -870,7 +871,7 @@ ch.qos.logback logback-classic - 1.4.11 + ${logback-version} From 9f34e357e9ae4e1758ef6899942bf5e1924ce932 Mon Sep 17 00:00:00 2001 From: Robert Csakany Date: Mon, 4 Nov 2024 01:03:49 +0100 Subject: [PATCH 3/6] Fixing dependencies [ci skip] --- generator-engine/pom.xml | 4 ++-- .../plugin/JslDslProjectGenerateMojo.java | 3 +++ osgi/pom.xml | 2 +- pom.xml | 22 +++---------------- 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/generator-engine/pom.xml b/generator-engine/pom.xml index 0db627ac..7eb8177d 100644 --- a/generator-engine/pom.xml +++ b/generator-engine/pom.xml @@ -106,12 +106,12 @@ com.fasterxml.jackson.dataformat jackson-dataformat-yaml - 2.10.3 + ${jackson-version} com.fasterxml.jackson.core jackson-databind - 2.10.3 + ${jackson-version} diff --git a/generator-maven-plugin/src/main/java/hu/blackbelt/judo/meta/jsl/generator/maven/plugin/JslDslProjectGenerateMojo.java b/generator-maven-plugin/src/main/java/hu/blackbelt/judo/meta/jsl/generator/maven/plugin/JslDslProjectGenerateMojo.java index 8e8ae8d4..6963c923 100644 --- a/generator-maven-plugin/src/main/java/hu/blackbelt/judo/meta/jsl/generator/maven/plugin/JslDslProjectGenerateMojo.java +++ b/generator-maven-plugin/src/main/java/hu/blackbelt/judo/meta/jsl/generator/maven/plugin/JslDslProjectGenerateMojo.java @@ -146,6 +146,9 @@ public void performExecutionOnJslDslParameters(JslDslGeneratorParameter.JslDslGe Map extras = new LinkedHashMap<>(); + if (variablePrecedence == null) { + variablePrecedence = Arrays.stream("projectProperties,templateVariables,propertiesFiles,environmentVariables,systemProperties".split(",")).toList(); + } for (String precedence : variablePrecedence) { diff --git a/osgi/pom.xml b/osgi/pom.xml index 973a4206..3582bd28 100644 --- a/osgi/pom.xml +++ b/osgi/pom.xml @@ -75,7 +75,7 @@ org.projectlombok lombok - 1.18.24 + ${lombok-version} diff --git a/pom.xml b/pom.xml index ffcaef8e..a87dbb59 100644 --- a/pom.xml +++ b/pom.xml @@ -77,8 +77,10 @@ ${maven.multiModuleProjectDirectory}/logback-test.xml 1.5.12 + 1.18.34 4.0.9 + 2.17.2 1.1.1.20240410_065331_3400dfa6_develop 1.1.2.20240410_075618_a6090f79_develop @@ -508,24 +510,6 @@ - - org.projectlombok - lombok-maven-plugin - 1.18.24.0 - - ${project.basedir}/src/main/java - ${project.basedir}/target/delombok - false - - - - generate-sources - - delombok - - - - @@ -910,7 +894,7 @@ org.projectlombok lombok - 1.18.24 + ${lombok-version} From 29171db6bb97f6076181b46c9dd3455b42f5b9a0 Mon Sep 17 00:00:00 2001 From: Robert Csakany Date: Mon, 25 Nov 2024 04:25:39 +0100 Subject: [PATCH 4/6] Add model selector --- .../meta/jsl/runtime/JslDslParserTest.java | 172 ++++++++++++++++++ .../judo/meta/jsl/runtime/JslParser.java | 43 +++++ 2 files changed, 215 insertions(+) diff --git a/model-test/src/test/java/hu/blackbelt/judo/meta/jsl/runtime/JslDslParserTest.java b/model-test/src/test/java/hu/blackbelt/judo/meta/jsl/runtime/JslDslParserTest.java index d188f7ec..e5396083 100644 --- a/model-test/src/test/java/hu/blackbelt/judo/meta/jsl/runtime/JslDslParserTest.java +++ b/model-test/src/test/java/hu/blackbelt/judo/meta/jsl/runtime/JslDslParserTest.java @@ -336,5 +336,177 @@ public void testGetModelFromStrings() { assertEquals("SampleModel2", model.getName()); } + /// ////////////////////////////////// + + + @Test + @Requirement(reqs = { + "REQ-SYNT-001", + "REQ-SYNT-002", + "REQ-SYNT-003", + "REQ-SYNT-004", + "REQ-MDL-001", + "REQ-TYPE-001", + "REQ-TYPE-002", + "REQ-TYPE-004", + "REQ-TYPE-005", + "REQ-TYPE-006", + "REQ-TYPE-007", + "REQ-TYPE-009", + "REQ-TYPE-010", + "REQ-ENT-001", + "REQ-ENT-012", + "REQ-ENT-002", + "REQ-ENT-003", + "REQ-ENT-004", + "REQ-ENT-006", + "REQ-ENT-008", + "REQ-ENT-009", + "REQ-ENT-010", // this test is unnecessary, the new JSL syntax does not allow primitives with cardinality + + "REQ-EXPR-001", + "REQ-EXPR-002", + "REQ-EXPR-003", + "REQ-EXPR-004", + "REQ-EXPR-005", + "REQ-EXPR-006", + "REQ-EXPR-008", + "REQ-EXPR-022" + //TODO: JNG-4398 + }) + public void testGetModelDeclarationFromFilesWithoutName() { + Optional model = JslParser.getModelDeclarationFromFiles( + Arrays.asList(new File("src/test/resources/sample.jsl"))); + assertTrue(model.isPresent()); + assertEquals("SampleModel", model.get().getName()); + } + + @Test + @Requirement(reqs = { + "REQ-SYNT-001", + "REQ-SYNT-002", + "REQ-SYNT-003", + "REQ-SYNT-004", + "REQ-MDL-001", + "REQ-TYPE-001", + "REQ-TYPE-004", + "REQ-TYPE-005" + }) + public void testGetModelDeclarationFromStreamSourcesWithoutName() throws UnsupportedEncodingException { + Optional model = JslParser.getModelDeclarationFromStreamSources( + Arrays.asList(new JslStreamSource(new ByteArrayInputStream(TEST_MODEL.getBytes("UTF-8")), URI.createURI("urn:testLoadFromByteArrayInputStream")))); + assertTrue(model.isPresent()); + assertEquals("SampleModel", model.get().getName()); + } + + @Test + @Requirement(reqs = { + "REQ-SYNT-001", + "REQ-SYNT-002", + "REQ-SYNT-003", + "REQ-SYNT-004", + "REQ-MDL-001", + "REQ-MDL-003", + "REQ-TYPE-001", + "REQ-TYPE-004", + "REQ-TYPE-005", + "REQ-ENT-001", + "REQ-ENT-002" + }) + public void testGetModelDeclarationFromStringsWithoutName() { + Optional model = JslParser.getModelDeclarationFromStrings( + Arrays.asList(TEST_MODEL, TEST_MODEL2)); + assertTrue(model.isPresent()); + assertEquals("SampleModel2", model.get().getName()); + } + + @Test + @Requirement(reqs = { + "REQ-SYNT-001", + "REQ-SYNT-002", + "REQ-SYNT-003", + "REQ-SYNT-004", + "REQ-MDL-001", + "REQ-TYPE-001", + "REQ-TYPE-002", + "REQ-TYPE-004", + "REQ-TYPE-005", + "REQ-TYPE-006", + "REQ-TYPE-007", + "REQ-TYPE-009", + "REQ-TYPE-010", + "REQ-ENT-001", + "REQ-ENT-012", + "REQ-ENT-002", + "REQ-ENT-003", + "REQ-ENT-004", + "REQ-ENT-006", + "REQ-ENT-008", + "REQ-ENT-009", + "REQ-ENT-010", + "REQ-EXPR-001", + "REQ-EXPR-002", + "REQ-EXPR-003", + "REQ-EXPR-004", + "REQ-EXPR-005", + "REQ-EXPR-006", + "REQ-EXPR-008", + "REQ-EXPR-022" + //TODO: JNG-4398 + //TODO: JNG-4394 The sample2.jsl needs to be change if the tickedt is done. + }) + public void testGetModelFromFilesWithoutName() { + JslDslModel model = JslParser.getModelFromFiles( + Arrays.asList( + new File("src/test/resources/sample.jsl"), + new File("src/test/resources/sample2.jsl") + )); + assertEquals("SampleModel2", model.getName()); + } + + @Test + @Requirement(reqs = { + "REQ-SYNT-001", + "REQ-SYNT-002", + "REQ-SYNT-003", + "REQ-SYNT-004", + "REQ-MDL-001", + "REQ-MDL-003", + "REQ-TYPE-001", + "REQ-TYPE-004", + "REQ-TYPE-005", + "REQ-ENT-001", + "REQ-ENT-002" + }) + public void testGetModelFromStreamSourcesWithoutName() throws UnsupportedEncodingException { + JslDslModel model = JslParser.getModelFromStreamSources( + Arrays.asList( + new JslStreamSource(new ByteArrayInputStream(TEST_MODEL.getBytes("UTF-8")), + URI.createURI("platform:/testLoadFromByteArrayInputStream.jsl")), + new JslStreamSource(new ByteArrayInputStream(TEST_MODEL2.getBytes("UTF-8")), + URI.createURI("platform:/testLoadFromByteArrayInputStream2.jsl")) + )); + assertEquals("SampleModel2", model.getName()); + } + + @Test + @Requirement(reqs = { + "REQ-SYNT-001", + "REQ-SYNT-002", + "REQ-SYNT-003", + "REQ-SYNT-004", + "REQ-MDL-001", + "REQ-MDL-003", + "REQ-TYPE-001", + "REQ-TYPE-004", + "REQ-TYPE-005", + "REQ-ENT-001", + "REQ-ENT-002" + }) + public void testGetModelFromStringsWithoutName() { + JslDslModel model = JslParser.getModelFromStrings( + Arrays.asList(TEST_MODEL, TEST_MODEL2)); + assertEquals("SampleModel2", model.getName()); + } } diff --git a/model/src/main/java/hu/blackbelt/judo/meta/jsl/runtime/JslParser.java b/model/src/main/java/hu/blackbelt/judo/meta/jsl/runtime/JslParser.java index 01b93497..e9e94afd 100644 --- a/model/src/main/java/hu/blackbelt/judo/meta/jsl/runtime/JslParser.java +++ b/model/src/main/java/hu/blackbelt/judo/meta/jsl/runtime/JslParser.java @@ -144,6 +144,18 @@ public static Optional getModelDeclarationFromStrings(String m return getModelDeclarationFromXtextResourceSet(modelName, loadJslFromString(jslStrings)); } + public static Optional getModelDeclarationFromStreamSources(final Collection jslStreams) { + return getRootModelDeclarationFromXtextResourceSet(loadJslFromStream(jslStreams)); + } + + public static Optional getModelDeclarationFromFiles(final Collection jslFiles) { + return getRootModelDeclarationFromXtextResourceSet(loadJslFromFile(jslFiles)); + } + + public static Optional getModelDeclarationFromStrings(final Collection jslStrings) { + return getRootModelDeclarationFromXtextResourceSet(loadJslFromString(jslStrings)); + } + public static Optional getModelDeclarationFromXtextResourceSet(String modelName, XtextResourceSet resourceSet) { Iterator iter = resourceSet.getAllContents(); ModelDeclaration found = null; @@ -183,6 +195,27 @@ public static JslDslModel getModelFromStrings(String modelName, final Collection return getModelFromXtextResourceSet(modelName, loadJslFromString(jslStrings)); } + public static Optional getRootModelDeclarationFromXtextResourceSet(XtextResourceSet xtextResourceSet) { + Collection modelDeclarations = getAllModelDeclarationFromXtextResourceSet(xtextResourceSet); + Set rootModelDeclarations = getRootModelDeclarations(modelDeclarations); + if (rootModelDeclarations.size() != 1) { + return Optional.empty(); + } + return Optional.of(rootModelDeclarations.iterator().next()); + } + + public static JslDslModel getModelFromStreamSources(final Collection jslStreams) { + return getModelFromXtextResourceSet(loadJslFromStream(jslStreams)); + } + + public static JslDslModel getModelFromFiles(final Collection jslFiles) { + return getModelFromXtextResourceSet(loadJslFromFile(jslFiles)); + } + + public static JslDslModel getModelFromStrings(final Collection jslStrings) { + return getModelFromXtextResourceSet(loadJslFromString(jslStrings)); + } + public static JslDslModel getModelFromXtextResourceSet(String modelName, XtextResourceSet resourceSet) { ModelDeclaration defaultModel = getModelDeclarationFromXtextResourceSet(modelName, resourceSet) .orElseThrow(() -> new IllegalArgumentException("Model with name '" + modelName + "' not found")); @@ -195,6 +228,16 @@ public static JslDslModel getModelFromXtextResourceSet(String modelName, XtextRe return model; } + public static JslDslModel getModelFromXtextResourceSet(XtextResourceSet resourceSet) { + ModelDeclaration defaultModel = getRootModelDeclarationFromXtextResourceSet(resourceSet).orElseThrow(() -> new IllegalArgumentException("Could not determinate root model")); + JslDslModel model = createModel(defaultModel.getName().replaceAll("::", "_")); + for (Resource res : resourceSet.getResources()) { + ModelDeclaration modelDecl = (ModelDeclaration) res.getContents().get(0); + model.addContent(modelDecl); + } + return model; + } + private static JslDslModel createModel(String name) { return buildJslDslModel().uri(URI.createURI("urn:" + name + ".jsl")).name(name).build(); From 3282abba8714c6c61c7bf209f63d8cad1544604f Mon Sep 17 00:00:00 2001 From: Robert Csakany Date: Tue, 26 Nov 2024 02:38:24 +0100 Subject: [PATCH 5/6] JNG-5995 [Release] Updating versions --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a87dbb59..f39a3027 100644 --- a/pom.xml +++ b/pom.xml @@ -84,7 +84,7 @@ 1.1.1.20240410_065331_3400dfa6_develop 1.1.2.20240410_075618_a6090f79_develop - 4.29.0.20240410_065423_a90724bb_develop + 4.33.0.20241102_103326_c584a408_feature_JNG_5995_UpdateEclipse 1.0.0 1.0.0.20230816_144910_bc235fc6_develop 1.0.0.20240923_095240_119ac3cd_develop @@ -102,8 +102,8 @@ 4.4.5 3.5.1 - 1.1.1.20240410_085121_bdac833a_develop - 2.0.2.20240410_083849_8b6fbfb2_develop + 1.1.1.20241126_013611_9413e9b2_feature_JNG_5995_UpdateEclipse + 2.0.2.20241126_010802_125d5050_feature_JNG_5995_UpdateEclipse 4.13.5 From 5db743926771caca163723e7b94cd49d9debb94b Mon Sep 17 00:00:00 2001 From: Robert Csakany Date: Tue, 26 Nov 2024 22:51:58 +0100 Subject: [PATCH 6/6] JNG-5995 [Release] Updating versions --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f39a3027..cb295fe8 100644 --- a/pom.xml +++ b/pom.xml @@ -102,8 +102,8 @@ 4.4.5 3.5.1 - 1.1.1.20241126_013611_9413e9b2_feature_JNG_5995_UpdateEclipse - 2.0.2.20241126_010802_125d5050_feature_JNG_5995_UpdateEclipse + 1.1.1.20241126_214402_3d785a59_feature_JNG_5995_UpdateEclipse + 2.0.2.20241126_153048_85d3e09c_feature_JNG_5995_UpdateEclipse 4.13.5