Skip to content

Commit

Permalink
Merge 5db7439 into 18faac2
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcsakany authored Nov 26, 2024
2 parents 18faac2 + 5db7439 commit d68c033
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 31 deletions.
4 changes: 2 additions & 2 deletions generator-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.10.3</version>
<version>${jackson-version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.3</version>
<version>${jackson-version}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ public void performExecutionOnJslDslParameters(JslDslGeneratorParameter.JslDslGe

Map<String, Object> extras = new LinkedHashMap<>();

if (variablePrecedence == null) {
variablePrecedence = Arrays.stream("projectProperties,templateVariables,propertiesFiles,environmentVariables,systemProperties".split(",")).toList();
}

for (String precedence : variablePrecedence) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModelDeclaration> 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<ModelDeclaration> 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<ModelDeclaration> 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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ public static Optional<ModelDeclaration> getModelDeclarationFromStrings(String m
return getModelDeclarationFromXtextResourceSet(modelName, loadJslFromString(jslStrings));
}

public static Optional<ModelDeclaration> getModelDeclarationFromStreamSources(final Collection<JslStreamSource> jslStreams) {
return getRootModelDeclarationFromXtextResourceSet(loadJslFromStream(jslStreams));
}

public static Optional<ModelDeclaration> getModelDeclarationFromFiles(final Collection<File> jslFiles) {
return getRootModelDeclarationFromXtextResourceSet(loadJslFromFile(jslFiles));
}

public static Optional<ModelDeclaration> getModelDeclarationFromStrings(final Collection<String> jslStrings) {
return getRootModelDeclarationFromXtextResourceSet(loadJslFromString(jslStrings));
}

public static Optional<ModelDeclaration> getModelDeclarationFromXtextResourceSet(String modelName, XtextResourceSet resourceSet) {
Iterator<Notifier> iter = resourceSet.getAllContents();
ModelDeclaration found = null;
Expand Down Expand Up @@ -183,6 +195,27 @@ public static JslDslModel getModelFromStrings(String modelName, final Collection
return getModelFromXtextResourceSet(modelName, loadJslFromString(jslStrings));
}

public static Optional<ModelDeclaration> getRootModelDeclarationFromXtextResourceSet(XtextResourceSet xtextResourceSet) {
Collection<ModelDeclaration> modelDeclarations = getAllModelDeclarationFromXtextResourceSet(xtextResourceSet);
Set<ModelDeclaration> rootModelDeclarations = getRootModelDeclarations(modelDeclarations);
if (rootModelDeclarations.size() != 1) {
return Optional.empty();
}
return Optional.of(rootModelDeclarations.iterator().next());
}

public static JslDslModel getModelFromStreamSources(final Collection<JslStreamSource> jslStreams) {
return getModelFromXtextResourceSet(loadJslFromStream(jslStreams));
}

public static JslDslModel getModelFromFiles(final Collection<File> jslFiles) {
return getModelFromXtextResourceSet(loadJslFromFile(jslFiles));
}

public static JslDslModel getModelFromStrings(final Collection<String> 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"));
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion osgi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<version>${lombok-version}</version>
</dependency>

<dependency>
Expand Down
41 changes: 13 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,35 @@
<maven.compiler.target>17</maven.compiler.target>
<!--suppress UnresolvedMavenProperty -->
<logback-test-config>${maven.multiModuleProjectDirectory}/logback-test.xml</logback-test-config>
<logback-version>1.5.12</logback-version>
<lombok-version>1.18.34</lombok-version>

<tycho-version>4.0.7</tycho-version>
<tycho-version>4.0.9</tycho-version>
<jackson-version>2.17.2</jackson-version>

<emf-genmodel-generator-version>1.1.1.20240410_065331_3400dfa6_develop</emf-genmodel-generator-version>
<judo-genmodel-generator-version>1.1.2.20240410_075618_a6090f79_develop</judo-genmodel-generator-version>
<judo-epp-common-version>4.29.0.20240410_065423_a90724bb_develop</judo-epp-common-version>
<judo-epp-common-version>4.33.0.20241102_103326_c584a408_feature_JNG_5995_UpdateEclipse</judo-epp-common-version>
<judo-misc-p2-version>1.0.0</judo-misc-p2-version>
<judo-jsl-tmbundle-version>1.0.0.20230816_144910_bc235fc6_develop</judo-jsl-tmbundle-version>
<judo-generator-commons-version>1.0.0.20240923_095240_119ac3cd_develop</judo-generator-commons-version>
<judo-version-updater-maven-plugin-version>1.0.0.20240904_153753_942f0b2d_develop</judo-version-updater-maven-plugin-version>

<xtext-version>2.32.0</xtext-version>
<emf-mwe2-launch-version>2.15.0</emf-mwe2-launch-version>
<slf4j-version>2.0.7</slf4j-version>
<slf4j-version>2.0.16</slf4j-version>

<surefire-version>3.0.0</surefire-version>
<surefire-version>3.5.1</surefire-version>
<!--suppress UnresolvedMavenProperty -->
<logback-test-config>${maven.multiModuleProjectDirectory}/logback-test.xml</logback-test-config>

<!-- Pax exam dependencies -->
<karaf-version>4.4.5</karaf-version>
<cxf-version>3.5.1</cxf-version>

<osgi-utils-version>1.1.1.20240410_085121_bdac833a_develop</osgi-utils-version>
<karaf-features-version>2.0.2.20240410_083849_8b6fbfb2_develop</karaf-features-version>
<pax-exam-version>4.13.4</pax-exam-version>
<osgi-utils-version>1.1.1.20241126_214402_3d785a59_feature_JNG_5995_UpdateEclipse</osgi-utils-version>
<karaf-features-version>2.0.2.20241126_153048_85d3e09c_feature_JNG_5995_UpdateEclipse</karaf-features-version>
<pax-exam-version>4.13.5</pax-exam-version>

<!-- Define overridable properties for tycho-surefire-plugin -->
<platformSystemProperties />
Expand All @@ -115,7 +118,7 @@
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.language>java</sonar.language>
<sonar.java.source>${java.version}</sonar.java.source>
<jacoco.version>0.8.8</jacoco.version>
<jacoco.version>0.8.12</jacoco.version>
<judo-requirement-report-version>1.0.0.20230826_231644_c0933832_develop</judo-requirement-report-version>
</properties>

Expand Down Expand Up @@ -507,24 +510,6 @@
</configuration>
</plugin>

<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.24.0</version>
<configuration>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<outputDirectory>${project.basedir}/target/delombok</outputDirectory>
<addOutputDirectory>false</addOutputDirectory>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
</plugin>

<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
Expand Down Expand Up @@ -870,7 +855,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.11</version>
<version>${logback-version}</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -909,7 +894,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<version>${lombok-version}</version>
</dependency>
</dependencies>
<profiles>
Expand Down

0 comments on commit d68c033

Please sign in to comment.