SymfonionSyntaxException.java

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

Mutations

32

1.1
Location : getProblemCausingJsonNode
Killed by : none
replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/SymfonionSyntaxException::getProblemCausingJsonNode → SURVIVED
Covering tests

36

1.1
Location : toJsonPathString
Killed by : com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:invalid_01()]
negated conditional → KILLED

2.2
Location : toJsonPathString
Killed by : com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:invalid_01()]
negated conditional → KILLED

37

1.1
Location : toJsonPathString
Killed by : none
replaced return value with "" for com/github/dakusui/symfonion/compat/exceptions/SymfonionSyntaxException::toJsonPathString → NO_COVERAGE

38

1.1
Location : toJsonPathString
Killed by : com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:invalid_01()]
replaced return value with "" for com/github/dakusui/symfonion/compat/exceptions/SymfonionSyntaxException::toJsonPathString → KILLED

45

1.1
Location : getMessage
Killed by : com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:invalid_01()]
negated conditional → KILLED

48

1.1
Location : getMessage
Killed by : com.github.dakusui.symfonion.tests.InvalidJsonErrorTest.[engine:junit-jupiter]/[class:com.github.dakusui.symfonion.tests.InvalidJsonErrorTest]/[method:invalid_01()]
replaced return value with "" for com/github/dakusui/symfonion/compat/exceptions/SymfonionSyntaxException::getMessage → KILLED

74

1.1
Location : summaryRootObjectNode
Killed by : none
replaced return value with null for com/github/dakusui/symfonion/compat/exceptions/SymfonionSyntaxException::summaryRootObjectNode → SURVIVED
Covering tests

Active mutators

Tests examined


Report generated by PIT 1.19.1