Skip to content

Commit

Permalink
Implement parent support for tests in Xpp3DoomBuilder (asciidoctor#723)
Browse files Browse the repository at this point in the history
The underlying Xpp3Doom implementation removes
'getParent' support in latest version, so we need
to do keep track of the parent for our tests

Fixes asciidoctor#638
  • Loading branch information
abelsromero authored Jan 1, 2024
1 parent 030a1f7 commit d7713e0
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class Xpp3DoomBuilder {

private Xpp3Dom rootNode;
private Xpp3Dom currentNode;
private Xpp3Dom parentNode;

private Xpp3DoomBuilder(String name) {
rootNode = currentNode = new Xpp3Dom(name);
Expand All @@ -26,6 +27,7 @@ public static Xpp3DoomBuilder logHandler() {
public Xpp3DoomBuilder addChild(String name) {
final Xpp3Dom newNode = new Xpp3Dom(name);
currentNode.addChild(newNode);
parentNode = currentNode;
currentNode = newNode;
return this;
}
Expand All @@ -42,12 +44,13 @@ public Xpp3DoomBuilder addChild(String name, String... values) {
currentNode.addChild(newNode);
}
}
parentNode = currentNode;
currentNode = newNode;
return this;
}

public Xpp3DoomBuilder parent() {
currentNode = currentNode.getParent();
currentNode = parentNode;
return this;
}

Expand Down

0 comments on commit d7713e0

Please sign in to comment.