From 3570796384e1a48304692c9706bf1faf28e01029 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 14 Mar 2020 17:46:20 +0100 Subject: [PATCH] [plsql] Enhance test for XMLFOREST --- .../pmd/lang/plsql/ast/XMLTableTest.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/ast/XMLTableTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/ast/XMLTableTest.java index 25d129b1fd..ced763b904 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/ast/XMLTableTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/ast/XMLTableTest.java @@ -4,14 +4,30 @@ package net.sourceforge.pmd.lang.plsql.ast; +import java.util.List; + +import org.junit.Assert; import org.junit.Test; import net.sourceforge.pmd.lang.plsql.AbstractPLSQLParserTst; + public class XMLTableTest extends AbstractPLSQLParserTst { @Test public void testParseXMLTable() { - plsql.parseResource("XMLTable.pls"); + ASTInput node = plsql.parseResource("XMLTable.pls"); + + List functions = node.findDescendantsOfType(ASTFunctionCall.class); + ASTFunctionCall xmlforest = functions.get(functions.size() - 1); + Assert.assertEquals("XMLFOREST", xmlforest.getImage()); + Assert.assertEquals("e.employee_id", xmlforest.getChild(1).getImage()); + Assert.assertEquals("foo", xmlforest.getChild(2).getImage()); + Assert.assertTrue(xmlforest.getChild(2) instanceof ASTID); + Assert.assertEquals("e.last_name", xmlforest.getChild(3).getImage()); + Assert.assertEquals("last_name", xmlforest.getChild(4).getImage()); + Assert.assertTrue(xmlforest.getChild(4) instanceof ASTID); + Assert.assertEquals("e.salary", xmlforest.getChild(5).getImage()); + Assert.assertEquals(6, xmlforest.getNumChildren()); } }