use of org.drools.compiler.rule.builder.XpathAnalysis in project drools by kiegroup.
the class XpathAnalysisTest method testConditionIterate.
@Test
public void testConditionIterate() {
final String xpath = "/address/street[name == \"Elm\"]/";
final XpathAnalysis result = XpathAnalysis.analyze(xpath);
assertEquals("The XPath should be valid.", false, result.hasError());
assertNull(result.getError());
final Iterator<XpathAnalysis.XpathPart> iterator = getNonEmptyIterator(result);
verifyXpathPart(new XpathAnalysis.XpathPart("address", true, false, new ArrayList<String>(), null, -1, 0), iterator.next());
verifyXpathPart(new XpathAnalysis.XpathPart("street", true, false, new ArrayList<String>(Arrays.asList("name == \"Elm\"")), null, -1, 0), iterator.next());
verifyXpathPart(new XpathAnalysis.XpathPart("", true, false, new ArrayList<String>(), null, -1, 0), iterator.next());
assertEquals(false, iterator.hasNext());
}
use of org.drools.compiler.rule.builder.XpathAnalysis in project drools by kiegroup.
the class XpathAnalysisTest method testAttributeDereferenceMixedIterate.
@Test
public void testAttributeDereferenceMixedIterate() {
final String xpath = "/address.street/name/";
final XpathAnalysis result = XpathAnalysis.analyze(xpath);
assertEquals("The XPath should be valid.", false, result.hasError());
assertNull(result.getError());
final Iterator<XpathAnalysis.XpathPart> iterator = getNonEmptyIterator(result);
verifyXpathPart(new XpathAnalysis.XpathPart("address", true, false, new ArrayList<String>(), null, -1, 0), iterator.next());
verifyXpathPart(new XpathAnalysis.XpathPart("street", false, false, new ArrayList<String>(), null, -1, 0), iterator.next());
verifyXpathPart(new XpathAnalysis.XpathPart("name", true, false, new ArrayList<String>(), null, -1, 0), iterator.next());
verifyXpathPart(new XpathAnalysis.XpathPart("", true, false, new ArrayList<String>(), null, -1, 0), iterator.next());
assertEquals(false, iterator.hasNext());
}
use of org.drools.compiler.rule.builder.XpathAnalysis in project drools by kiegroup.
the class XpathAnalysisTest method testEmptyXPath.
@Test
public void testEmptyXPath() {
final String xpath = "/";
final XpathAnalysis result = XpathAnalysis.analyze(xpath);
assertEquals("The empty XPath should be valid.", false, result.hasError());
assertNull(result.getError());
final Iterator<XpathAnalysis.XpathPart> iterator = getNonEmptyIterator(result);
verifyXpathPart(new XpathAnalysis.XpathPart("", true, false, new ArrayList<String>(), null, -1, 0), iterator.next());
assertEquals(false, iterator.hasNext());
}
use of org.drools.compiler.rule.builder.XpathAnalysis in project drools by kiegroup.
the class XpathAnalysisTest method testCondition.
@Test
public void testCondition() {
final String xpath = "/address/street[name == \"Elm\"]";
final XpathAnalysis result = XpathAnalysis.analyze(xpath);
assertEquals("The XPath should be valid.", false, result.hasError());
assertNull(result.getError());
final Iterator<XpathAnalysis.XpathPart> iterator = getNonEmptyIterator(result);
verifyXpathPart(new XpathAnalysis.XpathPart("address", true, false, new ArrayList<String>(), null, -1, 0), iterator.next());
verifyXpathPart(new XpathAnalysis.XpathPart("street", true, false, new ArrayList<String>(Arrays.asList("name == \"Elm\"")), null, -1, 0), iterator.next());
assertEquals(false, iterator.hasNext());
}
use of org.drools.compiler.rule.builder.XpathAnalysis in project drools by kiegroup.
the class XpathAnalysisTest method testAttribute.
@Test
public void testAttribute() {
final String xpath = "/address";
final XpathAnalysis result = XpathAnalysis.analyze(xpath);
assertEquals("The XPath should be valid.", false, result.hasError());
assertNull(result.getError());
final Iterator<XpathAnalysis.XpathPart> iterator = getNonEmptyIterator(result);
verifyXpathPart(new XpathAnalysis.XpathPart("address", true, false, new ArrayList<String>(), null, -1, 0), iterator.next());
assertEquals(false, iterator.hasNext());
}
Aggregations