1313
1414class ErrorCodeReportWriterTest {
1515
16+ private static final ErrorMessageDeclaration AN_ERROR_CODE = ErrorMessageDeclaration .builder ().identifier (//
17+ "E-Test-1" )//
18+ .prependMessage ("My message." )//
19+ .addParameter ("TEST" , "A parameter" )//
20+ .setPosition ("test.java" , 2 ).build ();
21+
1622 @ Test
1723 void testWriteReport (@ TempDir final Path tempDir ) throws IOException {
18- final ErrorCodeReport report = new ErrorCodeReport ("my-demo-project" , "1.2.3" ,
19- List .of (ErrorMessageDeclaration .builder ().identifier (//
20- "E-Test-1" )//
21- .prependMessage ("My message." )//
22- .addParameter ("TEST" , "A parameter" )//
23- .setPosition ("test.java" , 2 ).build ()));
24+ final ErrorCodeReport report = new ErrorCodeReport ("my-demo-project" , "1.2.3" , List .of (AN_ERROR_CODE ));
2425 final Path reportFile = tempDir .resolve ("error_code_report.json" );
2526 new ErrorCodeReportWriter ().writeReport (report , reportFile );
2627 assertThat (Files .readString (reportFile ), equalTo (
2728 "{\" $schema\" :\" https://schemas.exasol.com/error_code_report-1.0.0.json\" ,\" projectName\" :\" my-demo-project\" ,\" projectVersion\" :\" 1.2.3\" ,\" errorCodes\" :[{\" identifier\" :\" E-Test-1\" ,\" message\" :\" My message.\" ,\" messagePlaceholders\" :[{\" placeholder\" :\" TEST\" ,\" description\" :\" A parameter\" }],\" sourceFile\" :\" test.java\" ,\" sourceLine\" :2,\" mitigations\" :[]}]}" ));
2829 }
30+
31+ @ Test
32+ void testWriteWithoutNameAndVersion (@ TempDir final Path tempDir ) throws IOException {
33+ final ErrorCodeReport report = new ErrorCodeReport (null , null , List .of (AN_ERROR_CODE ));
34+ final Path reportFile = tempDir .resolve ("error_code_report.json" );
35+ new ErrorCodeReportWriter ().writeReport (report , reportFile );
36+ assertThat (Files .readString (reportFile ), equalTo (
37+ "{\" $schema\" :\" https://schemas.exasol.com/error_code_report-1.0.0.json\" ,\" errorCodes\" :[{\" identifier\" :\" E-Test-1\" ,\" message\" :\" My message.\" ,\" messagePlaceholders\" :[{\" placeholder\" :\" TEST\" ,\" description\" :\" A parameter\" }],\" sourceFile\" :\" test.java\" ,\" sourceLine\" :2,\" mitigations\" :[]}]}" ));
38+ }
2939}
0 commit comments