Skip to content

Commit 38851af

Browse files
author
Dennis Labordus
authored
Merge pull request #114 from com-pas/develop
New release
2 parents d6e7ecf + 64931fb commit 38851af

File tree

19 files changed

+380
-116
lines changed

19 files changed

+380
-116
lines changed

.github/workflows/release-project.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,10 @@ jobs:
5858
output_file: custom_maven_settings.xml
5959
servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
6060
- name: Set version with Maven
61-
# Only set the version for the CoMPAS Modules, excluding the RiseClipse Modules.
62-
run: ./mvnw -B versions:set -DgroupId=org.lfenergy.compas.scl.validator -DnewVersion=${{ steps.extract_tagname.outputs.tagname }}
61+
run: ./mvnw -B versions:set -DprocessAllModules=true -DnewVersion=${{ steps.extract_tagname.outputs.tagname }}
6362
env:
6463
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6564
- name: Deploy with Maven to GitHub Packages and Docker Hub
66-
# We need to pass the Repository information, because these are missing/need to be overwritten for the
67-
# RiseClipse Submodules for which we can't update the POM files.
68-
run: |
69-
./mvnw -B -s custom_maven_settings.xml \
70-
-DaltDeploymentRepository=github-packages-compas::default::https://maven.pkg.github.com/com-pas/compas-scl-validator \
71-
-Dmaven.deploy.skip=snapshots \
72-
-Pjvm-image,release clean deploy
65+
run: ./mvnw -B -s custom_maven_settings.xml -Pjvm-image,release clean deploy
7366
env:
7467
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

app/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ SPDX-License-Identifier: Apache-2.0
127127
<artifactId>openpojo</artifactId>
128128
<scope>test</scope>
129129
</dependency>
130+
<dependency>
131+
<groupId>org.slf4j</groupId>
132+
<artifactId>slf4j-simple</artifactId>
133+
<scope>test</scope>
134+
</dependency>
130135
</dependencies>
131136

132137
<build>

app/src/test/java/org/lfenergy/compas/scl/validator/rest/v1/websocket/SclValidateResponseDecoderTest.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,30 @@ void willDecode_WhenCalledWithNull_ThenFalseReturned() {
3737
@Test
3838
void decode_WhenCalledWithCorrectRequestXML_ThenStringConvertedToObject() {
3939
var validationMessage = "Some validation error";
40+
var ruleName = "Rule Name 1";
41+
var lineNumber = 15;
42+
var columnNumber = 34;
43+
4044
var message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
4145
+ "<svs:SclValidateResponse xmlns:svs=\"" + SCL_VALIDATOR_SERVICE_V1_NS_URI + "\">"
42-
+ "<svs:ValidationErrors><svs:Message>" + validationMessage + "</svs:Message></svs:ValidationErrors>"
46+
+ "<svs:ValidationErrors>"
47+
+ "<svs:Message>" + validationMessage + "</svs:Message>"
48+
+ "<svs:RuleName>" + ruleName + "</svs:RuleName>"
49+
+ "<svs:LineNumber>" + lineNumber + "</svs:LineNumber>"
50+
+ "<svs:ColumnNumber>" + columnNumber + "</svs:ColumnNumber>"
51+
+ "</svs:ValidationErrors>"
4352
+ "</svs:SclValidateResponse>";
4453

4554
var result = decoder.decode(message);
4655

4756
assertNotNull(result);
4857
assertEquals(1, result.getValidationErrorList().size());
49-
assertEquals(validationMessage, result.getValidationErrorList().get(0).getMessage());
58+
59+
var validationError = result.getValidationErrorList().get(0);
60+
assertEquals(validationMessage, validationError.getMessage());
61+
assertEquals(ruleName, validationError.getRuleName());
62+
assertEquals(lineNumber, validationError.getLineNumber());
63+
assertEquals(columnNumber, validationError.getColumnNumber());
5064
}
5165

5266
@Test

app/src/test/java/org/lfenergy/compas/scl/validator/rest/v1/websocket/SclValidateResponseEncoderTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ void init() {
2929
void encode_WhenCalledWithRequest_ThenRequestConvertedToString() {
3030
var validationMessage = "Some Validation Message";
3131
var ruleName = "Rule Name 1";
32-
var linenumber = 15;
32+
var lineNumber = 15;
33+
var columnNumber = 34;
3334

3435
var request = new SclValidateResponse();
3536
request.setValidationErrorList(new ArrayList<>());
3637
var validationError = new ValidationError();
3738
validationError.setMessage(validationMessage);
3839
validationError.setRuleName(ruleName);
39-
validationError.setLinenumber(linenumber);
40+
validationError.setLineNumber(lineNumber);
41+
validationError.setColumnNumber(columnNumber);
4042
request.getValidationErrorList().add(validationError);
4143

4244
var result = encoder.encode(request);
@@ -46,7 +48,8 @@ void encode_WhenCalledWithRequest_ThenRequestConvertedToString() {
4648
"<svs:ValidationErrors>" +
4749
"<svs:Message>" + validationMessage + "</svs:Message>" +
4850
"<svs:RuleName>" + ruleName + "</svs:RuleName>" +
49-
"<svs:Linenumber>" + linenumber + "</svs:Linenumber>" +
51+
"<svs:LineNumber>" + lineNumber + "</svs:LineNumber>" +
52+
"<svs:ColumnNumber>" + columnNumber + "</svs:ColumnNumber>" +
5053
"</svs:ValidationErrors>" +
5154
"</svs:SclValidateResponse>";
5255
assertNotNull(result);

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ SPDX-License-Identifier: Apache-2.0
111111
<version>3.0</version>
112112
</dependency>
113113

114+
<dependency>
115+
<groupId>org.slf4j</groupId>
116+
<artifactId>slf4j-api</artifactId>
117+
<version>${slf4j.version}</version>
118+
</dependency>
114119
<dependency>
115120
<groupId>org.slf4j</groupId>
116121
<artifactId>slf4j-simple</artifactId>

riseclipse/riseclipse-p2-to-m2/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ SPDX-License-Identifier: Apache-2.0
2929
<plugin>
3030
<groupId>org.eclipse.tycho.extras</groupId>
3131
<artifactId>tycho-eclipserun-plugin</artifactId>
32-
<version>2.7.4</version>
32+
<version>2.7.5</version>
3333
<configuration>
3434
<work>${project.build.directory}/maven/tmp/cbi</work>
35+
<executionEnvironment>JavaSE-17</executionEnvironment>
3536

3637
<repositories>
3738
<repository>

riseclipse/validator-riseclipse/src/main/java/org/lfenergy/compas/scl/validator/impl/OclFileLoader.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public OclFileLoader(Path tempDirectoryPath, List<URI> oclFiles) {
4040
// Create an OCL that creates a ResourceSet using the minimal EPackage.Registry
4141
this.ocl = OCL.newInstance(registry);
4242

43-
// First make sure the directory for temporary file exists.
43+
// First make sure the directory for temporary file exists and if not will be created.
4444
var tempDirectory = tempDirectoryPath.toFile();
4545
if (!tempDirectory.exists() && !tempDirectory.mkdirs()) {
4646
throw new SclValidatorException(CREATE_OCL_TEMP_DIR_FAILED, "Unable to create temporary directory");
@@ -54,8 +54,7 @@ public OclFileLoader(Path tempDirectoryPath, List<URI> oclFiles) {
5454
}
5555

5656
public void loadOCLDocuments() {
57-
oclFiles.stream()
58-
.forEach(this::addOCLDocument);
57+
oclFiles.forEach(this::addOCLDocument);
5958
}
6059

6160
public void addOCLDocument(URI oclUri) {

riseclipse/validator-riseclipse/src/main/java/org/lfenergy/compas/scl/validator/impl/SclRiseClipseValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ private void processDiagnostic(Diagnostic diagnostic, List<ValidationError> vali
8181
if (validationError.isPresent()) {
8282
validationErrors.add(validationError.get());
8383
if (LOGGER.isDebugEnabled()) {
84-
LOGGER.debug("SCL Validation Error '{}' from Rule '{}' (Linenumber {})",
84+
LOGGER.debug("SCL Validation Error '{}' from Rule '{}' (Line number {})",
8585
validationError.get().getMessage(),
8686
validationError.get().getRuleName(),
87-
validationError.get().getLinenumber());
87+
validationError.get().getLineNumber());
8888
}
8989
}
9090

riseclipse/validator-riseclipse/src/main/java/org/lfenergy/compas/scl/validator/util/MessageUtil.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ public static Optional<ValidationError> createValidationError(String message) {
2424
var validationError = new ValidationError();
2525
var messageParts = message.split(";");
2626
if (messageParts.length == 5) {
27-
// The expected number of parts is found, the message and rule are set as-is, the linenumber is converted
28-
// to a Long value,
27+
// The expected number of parts is found, the message and rule are set as-is, the line number
28+
// is converted to a Integer value,
2929
validationError.setRuleName(messageParts[1]);
3030
validationError.setMessage(messageParts[4]);
3131

3232
try {
33-
validationError.setLinenumber(Long.parseLong(messageParts[3]));
33+
validationError.setLineNumber(Integer.parseInt(messageParts[3]));
3434
} catch (NumberFormatException exp) {
35-
validationError.setLinenumber(-1);
36-
LOGGER.debug("Invalid linenumber '{}' found", messageParts[3], exp);
35+
validationError.setLineNumber(-1);
36+
LOGGER.debug("Invalid line number '{}' found", messageParts[3], exp);
3737
}
3838
} else if (messageParts.length == 2) {
3939
// It seems like an old message that starts with 'ERROR;', so only set the second part as Message

riseclipse/validator-riseclipse/src/test/java/org/lfenergy/compas/scl/validator/impl/OclFileLoaderTest.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import static org.junit.jupiter.api.Assertions.assertEquals;
2424
import static org.junit.jupiter.api.Assertions.assertThrows;
25-
import static org.lfenergy.compas.scl.validator.exception.SclValidatorErrorCode.NO_URI_PASSED;
25+
import static org.lfenergy.compas.scl.validator.exception.SclValidatorErrorCode.*;
2626
import static org.mockito.Mockito.*;
2727

2828
@ExtendWith(MockitoExtension.class)
@@ -46,6 +46,38 @@ void setup() throws IOException {
4646
.orElseThrow();
4747
}
4848

49+
@Test
50+
void constructor_WhenCalledWithUnCreatableDirectory_ThenExceptionThrown() {
51+
var unCreatablePath = Path.of("/some-directory");
52+
if (isWindows()) {
53+
unCreatablePath = Path.of("C:/Windows/some-directory");
54+
}
55+
56+
List<URI> fileList = List.of();
57+
var directoryPath = unCreatablePath;
58+
var exception = assertThrows(SclValidatorException.class, () -> new OclFileLoader(directoryPath, fileList));
59+
60+
assertEquals(CREATE_OCL_TEMP_DIR_FAILED, exception.getErrorCode());
61+
}
62+
63+
@Test
64+
void constructor_WhenCalledWithUnCreatableTempFile_ThenExceptionThrown() {
65+
var unWritablePath = Path.of("/");
66+
if (isWindows()) {
67+
unWritablePath = Path.of("C:/Windows");
68+
}
69+
70+
List<URI> fileList = List.of();
71+
var directoryPath = unWritablePath;
72+
var exception = assertThrows(SclValidatorException.class, () -> new OclFileLoader(directoryPath, fileList));
73+
74+
assertEquals(CREATE_OCL_TEMP_FILES_FAILED, exception.getErrorCode());
75+
}
76+
77+
private boolean isWindows() {
78+
return System.getProperty("os.name").contains("win");
79+
}
80+
4981
@Test
5082
void loadOCLDocuments_WhenCalled_ThenFilesFromListAreLoaded() throws IOException {
5183
loader.loadOCLDocuments();

0 commit comments

Comments
 (0)