33
33
import ru .ewc .decisions .commands .Assignment ;
34
34
import ru .ewc .decisions .conditions .Condition ;
35
35
36
- public class CheckRuleFragments {
36
+ public class CheckFile {
37
37
private final List <RuleFragments > rules ;
38
38
39
- public CheckRuleFragments (List <RuleFragments > rules ) {
39
+ public CheckFile (List <RuleFragments > rules ) {
40
40
this .rules = rules ;
41
41
}
42
42
43
- public List <TestResult > perform (ComputationContext context ) {
43
+ public List <TestResult > performChecks (ComputationContext context , String locator ) {
44
44
return this .rules .stream ()
45
- .map (rule -> CheckRuleFragments .performAndLog (context , rule ))
45
+ .map (rule -> CheckFile .performAndLog (context , rule , locator ))
46
46
.toList ();
47
47
}
48
48
49
- private static TestResult performAndLog (final ComputationContext ctx , final RuleFragments rule ) {
49
+ private static TestResult performAndLog (final ComputationContext ctx , final RuleFragments rule , String locator ) {
50
50
logCheckpoint (ctx , "%s - started" .formatted (rule .header ()));
51
51
final OutputTracker <String > tracker = ctx .startTracking ();
52
52
List <CheckFailure > failures = new ArrayList <>(1 );
@@ -57,10 +57,10 @@ private static TestResult performAndLog(final ComputationContext ctx, final Rule
57
57
failures .add (new CheckFailure (check .asString (), check .result ()));
58
58
}
59
59
} else {
60
- CheckRuleFragments .perform (fragment , ctx );
60
+ CheckFile .perform (fragment , ctx , locator );
61
61
}
62
62
}
63
- logCheckpoint (ctx , "%s - %s" .formatted (rule .header (), CheckRuleFragments .desc (failures )));
63
+ logCheckpoint (ctx , "%s - %s" .formatted (rule .header (), CheckFile .desc (failures )));
64
64
return new TestResult (
65
65
rule .header (),
66
66
failures .isEmpty (),
@@ -69,19 +69,18 @@ private static TestResult performAndLog(final ComputationContext ctx, final Rule
69
69
);
70
70
}
71
71
72
- private static void perform (RuleFragment fragment , ComputationContext ctx ) {
72
+ private static void perform (RuleFragment fragment , ComputationContext ctx , String locator ) {
73
73
switch (fragment .type ()) {
74
74
case "ASG" -> new Assignment (fragment .left (), fragment .right ()).performIn (ctx );
75
75
case "OUT" -> {
76
76
if ("execute" .equals (fragment .left ())) {
77
77
ctx .perform (fragment .right ());
78
+ ctx .resetComputationState (locator );
78
79
}
79
80
}
80
- case "HDR" -> {
81
- // do nothing
81
+ default -> {
82
+ // do nothing, because we don't know what to do with such a fragment type
82
83
}
83
- default ->
84
- throw new IllegalArgumentException ("Unknown fragment type: %s" .formatted (fragment .type ()));
85
84
}
86
85
}
87
86
@@ -105,7 +104,7 @@ private static String resultAsUnorderedList(final List<CheckFailure> failures) {
105
104
106
105
private static String checkFailureAsHtml (final List <CheckFailure > failures ) {
107
106
return failures .stream ()
108
- .map (CheckRuleFragments ::formattedDescriptionFor )
107
+ .map (CheckFile ::formattedDescriptionFor )
109
108
.collect (Collectors .joining ());
110
109
}
111
110
0 commit comments