diff options
author | JJ | 2022-12-28 06:26:54 +0000 |
---|---|---|
committer | JJ | 2022-12-28 23:31:27 +0000 |
commit | 4d55ecb842fab83e25adfd2cac76bc6b1ba8d0da (patch) | |
tree | f42dc8d25856b1ea0a7decc95c9734842976b235 /src/test/model/html | |
parent | a1b9e8c5259472ab13b2fd4161d3df8825f52b86 (diff) |
encapsulation is evil
Diffstat (limited to 'src/test/model/html')
-rw-r--r-- | src/test/model/html/HtmlParserTest.java | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/test/model/html/HtmlParserTest.java b/src/test/model/html/HtmlParserTest.java index 879f316..4a35320 100644 --- a/src/test/model/html/HtmlParserTest.java +++ b/src/test/model/html/HtmlParserTest.java @@ -85,10 +85,12 @@ public class HtmlParserTest { */ private static void assertEqualsHtml(ArrayList<Node> html, ArrayList<Node> expected) { for (int i = 0; i < html.size(); i++) { - assertEquals(html.get(i).getData(), expected.get(i).getData()); + assertEquals(html.get(i).data(), expected.get(i).data()); // System.out.println(html.get(i).getData() + " " + expected.get(i).getData()); - if (html.get(i) instanceof ElementNode) { - assertEqualsHtml(((ElementNode) html.get(i)).getChildren(), ((ElementNode) expected.get(i)).getChildren()); + switch (html.get(i)) { + case ElementNode e -> + assertEqualsHtml(e.children, ((ElementNode) expected.get(i)).children); + default -> {} } } } @@ -99,15 +101,16 @@ public class HtmlParserTest { */ private void displayHtmlTree(ArrayList<Node> tree) { for (Node node : tree) { - if (node instanceof ElementNode) { - System.out.print(((ElementNode) node).getTag() + ": "); - for (Node n : ((ElementNode) node).getChildren()) { - System.out.print(n.getData() + " "); + switch (node) { + case ElementNode e -> { + System.out.print(e.tag + ": "); + for (Node n : e.children) { + System.out.print(n.data() + " "); + } + System.out.println(); + displayHtmlTree(e.children); } - System.out.println(); - displayHtmlTree(((ElementNode) node).getChildren()); - } else { - System.out.println("Text: " + node.getData()); + default -> System.out.println("Text: " + node.data()); } } } |