Skip to content

Commit aebf26f

Browse files
committed
fix(test): not failing tests upon throwing DecitaExceptions
1 parent 4cc3229 commit aebf26f

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

src/main/java/ru/ewc/checklogic/testing/CheckFile.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import lombok.Getter;
3030
import ru.ewc.checklogic.ServerContextFactory;
3131
import ru.ewc.decisions.api.ComputationContext;
32+
import ru.ewc.decisions.api.DecitaException;
3233
import ru.ewc.decisions.api.OutputTracker;
3334
import ru.ewc.decisions.api.RuleFragment;
3435
import ru.ewc.decisions.api.RuleFragments;
@@ -88,11 +89,24 @@ private TestResult getTestResult(final RuleFragments rule, final ComputationCont
8889
for (final RuleFragment fragment : rule.getFragments()) {
8990
if (fragment.nonEmptyOfType("CND")) {
9091
final Condition check = Condition.from(fragment);
91-
if (!check.evaluate(ctx)) {
92-
failures.add(new CheckFailure(check.asString(), check.result()));
92+
try {
93+
if (!check.evaluate(ctx)) {
94+
failures.add(new CheckFailure(check.asString(), check.result()));
95+
}
96+
} catch (final DecitaException exception) {
97+
failures.add(
98+
new CheckFailure(
99+
check.asString(),
100+
"Exception: %s".formatted(exception.getMessage())
101+
)
102+
);
93103
}
94104
} else {
95-
this.perform(fragment, ctx);
105+
try {
106+
this.perform(fragment, ctx);
107+
} catch (DecitaException exception) {
108+
failures.add(new CheckFailure("", exception.getMessage()));
109+
}
96110
}
97111
}
98112
logCheckpoint(ctx, "%s - %s".formatted(rule.header(), CheckFile.desc(failures)));

src/main/resources/templates/state.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ <h1>State entities</h1>
4646
</div>
4747
</div>
4848
<div class="col">
49+
<h1>Context</h1>
50+
<form class="mb-3" hx-post="/context" hx-target="#commands" hx-swap="innerHTML"
51+
hx-trigger="submit, load">
52+
<div class="mb-3">
53+
<label class="col-form-label" for="reqValues">Request values:</label>
54+
<textarea class="form-control" id="reqValues" name="reqValues" rows="3"
55+
placeholder="Enter request parameters, one per line, in 'key: value' format"></textarea>
56+
</div>
57+
<button class="btn btn-primary" type="submit">Update context</button>
58+
</form>
4959
<h1>Tables</h1>
5060
<form class="mb-3" hx-post="/state" hx-target="#table-details">
5161
<div class="input-group">
@@ -57,16 +67,6 @@ <h1>Tables</h1>
5767
</div>
5868
<div id="table-details"></div>
5969
</form>
60-
<h1>Context</h1>
61-
<form class="mb-3" hx-post="/context" hx-target="#commands" hx-swap="innerHTML"
62-
hx-trigger="submit, load">
63-
<div class="mb-3">
64-
<label class="col-form-label" for="reqValues">Request values:</label>
65-
<textarea class="form-control" id="reqValues" name="reqValues" rows="3"
66-
placeholder="Enter request parameters, one per line, in 'key: value' format"></textarea>
67-
</div>
68-
<button class="btn btn-primary" type="submit">Update commands</button>
69-
</form>
7070
<h1>Commands</h1>
7171
<div id="commands" class="row g-2"></div>
7272
</div>

0 commit comments

Comments
 (0)