| 1 | package com.github.dakusui.symfonion.exceptions; | |
| 2 | ||
| 3 | import java.io.File; | |
| 4 | import java.io.Serial; | |
| 5 | import java.util.List; | |
| 6 | ||
| 7 | import com.github.dakusui.json.JsonUtils; | |
| 8 | import com.google.gson.GsonBuilder; | |
| 9 | import com.google.gson.JsonElement; | |
| 10 | import com.google.gson.JsonObject; | |
| 11 | ||
| 12 | import static com.github.dakusui.json.JsonUtils.createSummaryJsonObjectFromPaths; | |
| 13 | import static com.github.dakusui.json.JsonUtils.findPathOf; | |
| 14 | ||
| 15 | public class SymfonionSyntaxException extends SymfonionException { | |
| 16 | ||
| 17 | /** | |
| 18 | * Serial version UID | |
| 19 | */ | |
| 20 | @Serial | |
| 21 | private static final long serialVersionUID = 5992346365176153504L; | |
| 22 | ||
| 23 | protected final JsonElement problemCausingJsonNode; | |
| 24 | protected final JsonObject rootJsonObjectNode; | |
| 25 | ||
| 26 | public SymfonionSyntaxException(String message, JsonElement problemCausingJsonNode, JsonObject rootJsonObjectNode, File sourceFile) { | |
| 27 | super(message, sourceFile); | |
| 28 | this.problemCausingJsonNode = problemCausingJsonNode; | |
| 29 | this.rootJsonObjectNode = rootJsonObjectNode; | |
| 30 | } | |
| 31 | ||
| 32 | public JsonElement getProblemCausingJsonNode() { | |
| 33 |
1
1. getProblemCausingJsonNode : replaced return value with null for com/github/dakusui/symfonion/exceptions/SymfonionSyntaxException::getProblemCausingJsonNode → SURVIVED |
return this.problemCausingJsonNode; |
| 34 | } | |
| 35 | ||
| 36 | public String toJsonPathString() { | |
| 37 |
2
1. toJsonPathString : negated conditional → KILLED 2. toJsonPathString : negated conditional → KILLED |
if (rootJsonObjectNode == null || problemCausingJsonNode == null) |
| 38 |
1
1. toJsonPathString : replaced return value with "" for com/github/dakusui/symfonion/exceptions/SymfonionSyntaxException::toJsonPathString → NO_COVERAGE |
return "(n/a)"; |
| 39 |
1
1. toJsonPathString : replaced return value with "" for com/github/dakusui/symfonion/exceptions/SymfonionSyntaxException::toJsonPathString → KILLED |
return JsonUtils.findPathStringOf(this.problemCausingJsonNode, this.rootJsonObjectNode); |
| 40 | } | |
| 41 | ||
| 42 | @Override | |
| 43 | public String getMessage() { | |
| 44 | String msg = "jsonpath: " + this.toJsonPathString() + ": error: " + super.getMessage(); | |
| 45 | File src = this.getSourceFile(); | |
| 46 |
1
1. getMessage : negated conditional → KILLED |
if (src != null) { |
| 47 | msg = src.getPath() + ": " + msg; | |
| 48 | } | |
| 49 |
1
1. getMessage : replaced return value with "" for com/github/dakusui/symfonion/exceptions/SymfonionSyntaxException::getMessage → KILLED |
return String.format( |
| 50 | """ | |
| 51 | %s | |
| 52 | | |
| 53 | .Path to the problem causing node: | |
| 54 | ---- | |
| 55 | %s | |
| 56 | ---- | |
| 57 | ||
| 58 | .Problem causing node: | |
| 59 | ---- | |
| 60 | %s | |
| 61 | ---- | |
| 62 | | |
| 63 | .Whole JSON: | |
| 64 | ---- | |
| 65 | %s | |
| 66 | ---- | |
| 67 | """, | |
| 68 | msg, | |
| 69 | this.toJsonPathString(), | |
| 70 | this.getProblemCausingJsonNode(), | |
| 71 | new GsonBuilder().setPrettyPrinting().create().toJson(summaryRootObjectNode())); | |
| 72 | } | |
| 73 | ||
| 74 | protected JsonObject summaryRootObjectNode() { | |
| 75 |
1
1. summaryRootObjectNode : replaced return value with null for com/github/dakusui/symfonion/exceptions/SymfonionSyntaxException::summaryRootObjectNode → SURVIVED |
return createSummaryJsonObjectFromPaths(this.rootJsonObjectNode, findPathOf(this.problemCausingJsonNode, this.rootJsonObjectNode)); |
| 76 | } | |
| 77 | } | |
Mutations | ||
| 33 |
1.1 |
|
| 37 |
1.1 2.2 |
|
| 38 |
1.1 |
|
| 39 |
1.1 |
|
| 46 |
1.1 |
|
| 49 |
1.1 |
|
| 75 |
1.1 |