File tree Expand file tree Collapse file tree 3 files changed +26
-13
lines changed
framework/codemodder-testutils/src/main/java/io/codemodder/testutils
plugins/codemodder-plugin-defectdojo/src/main/java/io/codemodder/providers/defectdojo Expand file tree Collapse file tree 3 files changed +26
-13
lines changed Original file line number Diff line number Diff line change 1313import io .codemodder .javaparser .JavaParserFacade ;
1414import io .codemodder .javaparser .JavaParserFactory ;
1515import java .io .IOException ;
16+ import java .io .UncheckedIOException ;
1617import java .nio .file .Files ;
1718import java .nio .file .Path ;
1819import java .nio .file .StandardCopyOption ;
@@ -153,7 +154,7 @@ private void verifyCodemod(
153154 try {
154155 return factory .create (List .of (dir ));
155156 } catch (IOException e ) {
156- throw new RuntimeException (e );
157+ throw new UncheckedIOException (e );
157158 }
158159 }),
159160 EncodingDetector .create ());
@@ -210,8 +211,8 @@ private void verifyCodemod(
210211 List .of (pathToJavaFile ),
211212 map ,
212213 List .of (),
213- Files . exists ( sonarJson ) ? sonarJson : null ,
214- Files . exists ( defectDojo ) ? defectDojo : null );
214+ null ,
215+ null );
215216 CodemodIdPair codemod2 = loader2 .getCodemods ().get (0 );
216217 CodemodExecutor executor2 =
217218 CodemodExecutorFactory .from (
Original file line number Diff line number Diff line change @@ -31,18 +31,21 @@ final class DefectDojoModule extends AbstractModule {
3131
3232 @ Override
3333 protected void configure () {
34- if (defectDojoFindingsJsonFile == null ) {
35- return ;
36- }
3734
3835 Findings findings ;
39- try {
40- findings =
41- new ObjectMapper ()
42- .configure (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES , false )
43- .readValue (defectDojoFindingsJsonFile .toFile (), Findings .class );
44- } catch (IOException e ) {
45- throw new UncheckedIOException ("can't read defectdojo JSON" , e );
36+
37+ // if there was no file, we still have to bind an empty result
38+ if (defectDojoFindingsJsonFile == null ) {
39+ findings = new Findings (List .of ());
40+ } else {
41+ try {
42+ findings =
43+ new ObjectMapper ()
44+ .configure (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES , false )
45+ .readValue (defectDojoFindingsJsonFile .toFile (), Findings .class );
46+ } catch (IOException e ) {
47+ throw new UncheckedIOException ("can't read defectdojo JSON" , e );
48+ }
4649 }
4750
4851 // create a RuleFindings instance for every rule id we come across in the findings object
Original file line number Diff line number Diff line change 22
33import com .fasterxml .jackson .annotation .JsonProperty ;
44import java .util .List ;
5+ import java .util .Objects ;
56
67/** Represents the top level object in a DefectDojo findings API response. */
78public class Findings {
89
10+ public Findings () {
11+ // needed for deserialization
12+ }
13+
14+ public Findings (final List <Finding > results ) {
15+ this .results = Objects .requireNonNull (results );
16+ }
17+
918 @ JsonProperty ("results" )
1019 private List <Finding > results ;
1120
You can’t perform that action at this time.
0 commit comments