Skip to content

Commit da6efda

Browse files
author
Dennis Labordus
committed
Changed code for coverage.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent f680c49 commit da6efda

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

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+
var directoryPath = unCreatablePath;
57+
var exception = assertThrows(SclValidatorException.class,
58+
() -> new OclFileLoader(directoryPath, List.of()));
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+
var directoryPath = unWritablePath;
71+
var exception = assertThrows(SclValidatorException.class,
72+
() -> new OclFileLoader(directoryPath, List.of()));
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();

validator/src/main/java/org/lfenergy/compas/scl/validator/xsd/XSDValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private ValidationError createValidationError(SAXParseException exception, Strin
8080
validationError.setLinenumber(exception.getLineNumber());
8181
validationError.setColumnNumber(exception.getColumnNumber());
8282

83-
LOGGER.debug("XSD Validation - {}: '{}' (Linenumber {}, Columnnumber {})",
83+
LOGGER.debug("XSD Validation - {}: '{}' (Linenumber {}, Column number {})",
8484
type,
8585
validationError.getMessage(),
8686
validationError.getLinenumber(),

0 commit comments

Comments
 (0)