@@ -105,10 +105,10 @@ private void loadAndConvertDroolsRulesToAssertions() {
105
105
private void convertDroolsRuleToAssertion (File droolsRulesSubfile ) throws IOException {
106
106
try (final BufferedReader reader = Files .newBufferedReader (droolsRulesSubfile .toPath ())) {
107
107
String line ;
108
+ UUID uuid ;
108
109
Assertion assertion = null ;
109
110
boolean severityWarning = false ;
110
111
boolean severityError = false ;
111
- UUID uuid = null ;
112
112
String group = getAssertionGroup (droolsRulesSubfile .getAbsolutePath ());
113
113
while ((line = reader .readLine ()) != null ) {
114
114
if (line .startsWith ("rule" ) && !line .contains ("Always passes" )) {
@@ -125,20 +125,16 @@ private void convertDroolsRuleToAssertion(File droolsRulesSubfile) throws IOExce
125
125
assertions .add (assertion );
126
126
}
127
127
}
128
- if (line .contains ("new InvalidContent" )) {
128
+ if (assertion != null && line .contains ("new InvalidContent" )) {
129
129
uuid = extractUuid (line );
130
+ assertion .setUuid (uuid );
130
131
}
131
132
// check for severity
132
- if (line .contains ("Severity.WARNING" )) {
133
- severityWarning = true ;
133
+ severityWarning = severityWarning || detectSeverity (line , "Severity.WARNING" );
134
+ severityError = severityError || detectSeverity (line , "Severity.ERROR" );
135
+ if (assertion != null && "end" .equals (line .trim ())) {
136
+ assertion .setSeverity (buildSeverity (severityWarning , severityError ));
134
137
}
135
- if (line .contains ("Severity.ERROR" )) {
136
- severityError = true ;
137
- }
138
- }
139
- if (assertion != null ) {
140
- assertion .setUuid (uuid );
141
- assertion .setSeverity (buildSeverity (severityWarning , severityError ));
142
138
}
143
139
}
144
140
}
@@ -151,6 +147,10 @@ private static UUID extractUuid(String line) {
151
147
return null ;
152
148
}
153
149
150
+ private static boolean detectSeverity (String line , String type ) {
151
+ return line .contains (type );
152
+ }
153
+
154
154
@ NotNull
155
155
private static String buildSeverity (boolean severityWarning , boolean severityError ) {
156
156
Set <String > severities = new HashSet <>();
0 commit comments