Class VariableExpressionSegmentMatcher

java.lang.Object
org.citrusframework.variable.VariableExpressionSegmentMatcher

public class VariableExpressionSegmentMatcher extends Object
Matcher that matches segments of variable expressions. The matcher is capable to match the following segments:

  • indexed variables/properties segments of the form: 'var[1]'
  • jsonPath segments of the form: 'jsonPath($.person.name)'
  • xpath segments of the form: 'xpath(//person/name)'

Note that jsonPath and xpath segments must terminate the expression, i.e. they cannot be followed by further expressions. If a variable expression is used to access a variable from the test context it must start with a variable segment which extracts the first variable from the test context.

Sample for valid variable expressions:

  • var1
  • var1.var2
  • var1[1]
  • var1[1].var2[2]
  • var1[1].var2[2].var3
  • var1.jsonPath($.person.name)
  • var1[1].jsonPath($.person.name)
  • var1.xpath(//title[@lang='en'])
  • var1[1].xpath(//title[@lang='en'])

  • Constructor Details

    • VariableExpressionSegmentMatcher

      public VariableExpressionSegmentMatcher(String variableExpression)
  • Method Details

    • getTotalSegmentCount

      public int getTotalSegmentCount()
      Obtain the total number of segments in the variable expression of this matcher
      Returns:
    • nextMatch

      public boolean nextMatch()
      Attempts to find the next segment in the variable expression and sets the current segment expression as well as the current segment index.
      Returns:
    • getVariableExpression

      public String getVariableExpression()
      Obtain the variable expression which backs the matcher.
      Returns:
    • getSegmentExpression

      public String getSegmentExpression()
      Obtain the segment expression ot the current match. Null if the matcher has run out of matches.
      Returns:
    • getSegmentIndex

      public int getSegmentIndex()
      Obtain the segment index of the current match. -1 if match is not indexed of matcher has run out of matches.
      Returns: