Since: API Level v2
public final class

BDTPlugin

com.webmbt.plugin.BDTPlugin

Class Overview

BDT (beta) plugin enables BDT style mscript editor. Used for BDT Edition or as an add-on plugin for ProMBT.

Copyright © 2017 TestOptimal LLC. All Rights Reserved.

Summary

Public Constructors
BDTPlugin()
Public Methods
String blockTokenByAnchors(String prefix_p, String suffix_p)
extracts a substring from current BDT block label that is enclosed by the specified text strings before and after the substring.
String blockTokenByCode(String tokenKey_p)
extracts first token from the current BDT block label.
String blockTokenByCode(String tokenKey_p, String idx_p)
extracts nth token from the current BDT block label.
String blockTokenByGroup(String regExpr_p, String groupIdx_p)
retrieve the specific group value from the current BDT block label that match the regular expression passed in.
String blockTokenByIdx(String idx_p)
extracts nth token from the current scenario label.
int countBlockToken()
returns count of tokens found in the current BDT block label.
int countBlockTokenByCode(String tokenKey_p)
return count of token found in the current scenario label.
int countFeatureToken()
returns count of tokens found in the current feature label.
int countFeatureTokenByCode(String tokenKey_p)
returns the count of tokens found in current feature label.
int countScenarioToken()
returns count of tokens found in the current scenario label.
int countScenarioTokenByCode(String tokenKey_p)
return count of token found in the current scenario label.
int countToken(String text_p)
returns the count of token found in parameter text_p.
int countTokenByCode(String text_p, String tokenKey_p)
returns the count of the specified token present in text_p.
String curBlockLabel()
returns the label of current BDT block label depending on where this function is called: FTR_PREP: FEATURE label, GIVEN: GIVEN label, WHEN: WHEN label, and THEN: THEN label.
String curFeature()
returns the name of the feature currently being executed.@return
String curGivenLabel()
returns the label of current BDT GIVEN block.
String curScenario()
returns the name of the scenario currently being executed.@return
String curThenLabel()
returns the label of current BDT THEN block.
String curWhenLabel()
returns the label of current BDT WHEN block.
String featureTokenByAnchors(String prefix_p, String suffix_p)
extracts a substring from current feature label that is enclosed by the specified text strings before and after the substring.
String featureTokenByCode(String tokenKey_p)
extracts first token from the current feature label.
String featureTokenByCode(String tokenKey_p, String idx_p)
extracts nth token from the current feature label.
String featureTokenByGroup(String regExpr_p, String groupIdx_p)
retrieve the specific group value from the current feature label that match the regular expression passed in.
String featureTokenByIdx(String idx_p)
extracts nth token from the current feature label.
String scenarioTokenByAnchors(String prefix_p, String suffix_p)
extracts a substring from current scenario label that is enclosed by the specified text strings before and after the substring.
String scenarioTokenByCode(String tokenKey_p, String idx_p)
extracts nth token from the current scenario label.
String scenarioTokenByCode(String tokenKey_p)
extracts first token from the current scenario label.
String scenarioTokenByGroup(String regExpr_p, String groupIdx_p)
retrieve the specific group value from the current feature label that match the regular expression passed in.
String scenarioTokenByIdx(String idx_p)
extracts nth token from the current scenario label.
String tokenByAnchors(String text_p, String prefix_p, String suffix_p)
extracts first token from text_p.
String tokenByCode(String text_p, String tokenKey_p)
extracts nth token present in parameter text_p.
String tokenByCode(String text_p, String tokenKey_p, String idx_p)
extracts the specified token from text_p.
String tokenByGroup(String text_p, String regExpr_p, String groupIdx_p)
retrieve the specific group string from the text_p that match the regular expression passed in.
String tokenByIdx(String text_p, String idx_p)
extracts nth token present in parameter text_p.

Public Constructors

public BDTPlugin ()

Since: API Level v2

Public Methods

public String blockTokenByAnchors (String prefix_p, String suffix_p)

Since: API Level v2

extracts a substring from current BDT block label that is enclosed by the specified text strings before and after the substring.

Example: Suppose the GIVEN label is 'This scenario is to test the substring extraction'

Then the following MScript will return "substring":
$blockTokenByAnchors ('test the ', ' extraction').

Returns
  • blank if not found

public String blockTokenByCode (String tokenKey_p)

Since: API Level v2

extracts first token from the current BDT block label.

Example: $blockTokenByCode ('X') to extract "abc" from 'Test message [abc:X] must be displayed and another [msg:X] should also be displayed'.

Returns
  • blank if not found

public String blockTokenByCode (String tokenKey_p, String idx_p)

Since: API Level v2

extracts nth token from the current BDT block label.

Example: $blockTokenByCode ('X','2') to extract "msg" from 'Test message [abc:X] must be displayed and another [msg:X] should also be displayed'.

Parameters
idx_p 1-based index of the token to be extracted.
Returns
  • blank if not found

public String blockTokenByGroup (String regExpr_p, String groupIdx_p)

Since: API Level v2

retrieve the specific group value from the current BDT block label that match the regular expression passed in. The regular expression must define the groups and the groupIdx_p refers to the group id of the matched groups to be returned.

Returns
  • blank if no match or specified group out of range.

public String blockTokenByIdx (String idx_p)

Since: API Level v2

extracts nth token from the current scenario label.

Example: $scenarioTokenByIdx ('2') to extract the second token.

Parameters
idx_p 1-based index of the token to be extracted.
Returns
  • blank if not found
See Also
  • tokenByIdx(String,String)

public int countBlockToken ()

Since: API Level v2

returns count of tokens found in the current BDT block label.

Example: $countBlockToken()

Returns
  • 0 if not found
See Also
  • countBlockTokenByCode(String)

public int countBlockTokenByCode (String tokenKey_p)

Since: API Level v2

return count of token found in the current scenario label.

Example: $countScenarioTokenByCode ('X') returns 2 given the following scenario label: 'Test message [abc:X] must be displayed and another [msg:X] should also be displayed'.

Returns
  • 0 if not found
See Also
  • countScenarioToken()

public int countFeatureToken ()

Since: API Level v2

returns count of tokens found in the current feature label. Tokens are enclosed in a pair of "[]".

Example: $countFeatureToken()

Returns
  • 0 if not found
See Also
  • countTokenByCode(String)

public int countFeatureTokenByCode (String tokenKey_p)

Since: API Level v2

returns the count of tokens found in current feature label.

Example: $countFeatureTokenByCode ('X') returns 2 given feature label of 'Test message [abc:X] must be displayed and another [msg:X] should also be displayed'.

Returns
  • 0 if not found
See Also
  • countFeatureToken()

public int countScenarioToken ()

Since: API Level v2

returns count of tokens found in the current scenario label.

Example: $countScenarioToken()

Returns
  • 0 if not found
See Also
  • countScenarioTokenByCode(String)

public int countScenarioTokenByCode (String tokenKey_p)

Since: API Level v2

return count of token found in the current scenario label.

Example: $countScenarioTokenByCode ('X') returns 2 given the following scenario label: 'Test message [abc:X] must be displayed and another [msg:X] should also be displayed'.

Returns
  • 0 if not found
See Also
  • countScenarioToken()

public int countToken (String text_p)

Since: API Level v2

returns the count of token found in parameter text_p. The token is identified by the enclosure with "[]".

Example: $countToken() to return the count of tokens enclosed by '[]'.

Returns
  • 0 if not found
See Also
  • countTokenByCode()

public int countTokenByCode (String text_p, String tokenKey_p)

Since: API Level v2

returns the count of the specified token present in text_p. The token is specified in this format: [tokenString:X].

Example: $countTokenByCode ('test message [token 1:X] more [token 2:X]', 'X', '2') which returns 2 as there are two 'X' tokens in the text passed in.

Parameters
text_p text string to search for matches
tokenKey_p character strings
Returns
  • 0 if no tokens are found
See Also
  • countToken()

public String curBlockLabel ()

Since: API Level v2

returns the label of current BDT block label depending on where this function is called: FTR_PREP: FEATURE label, GIVEN: GIVEN label, WHEN: WHEN label, and THEN: THEN label.

To get SCENARIO label, call $curScenario() in GIVEN, WHEN or THEN block.

For FEATURE label, you can also call $curFeature() in any BDT block.

Returns
  • block label

public String curFeature ()

Since: API Level v2

returns the name of the feature currently being executed.@return

Throws
Exception

public String curGivenLabel ()

Since: API Level v2

returns the label of current BDT GIVEN block.

Returns
  • current GIVEN block label

public String curScenario ()

Since: API Level v2

returns the name of the scenario currently being executed.@return

Throws
Exception

public String curThenLabel ()

Since: API Level v2

returns the label of current BDT THEN block.

Returns
  • current THEN block label

public String curWhenLabel ()

Since: API Level v2

returns the label of current BDT WHEN block.

Returns
  • current WHEN block label

public String featureTokenByAnchors (String prefix_p, String suffix_p)

Since: API Level v2

extracts a substring from current feature label that is enclosed by the specified text strings before and after the substring.

Example: Suppose the feature label is 'This feature is to test the substring extraction'

Then the following MScript will return "substring":
$featureTokeyByAnchors ('test the ', ' extraction').@return

See Also
  • tokenByAnchors(String, String,String)

public String featureTokenByCode (String tokenKey_p)

Since: API Level v2

extracts first token from the current feature label.

Example: $featureTokenByCode ('X') to extract "abc" from 'Test message [abc:X] must be displayed and another [msg:X] should also be displayed'.

Returns
  • blank if not found
See Also
  • tokenByCode(String, String)

public String featureTokenByCode (String tokenKey_p, String idx_p)

Since: API Level v2

extracts nth token from the current feature label.

Example: $featureTokenByCode ('X','2') to extract "msg" from 'Test message [abc:X] must be displayed and another [msg:X] should also be displayed'.

Parameters
idx_p 1-based index of the token to be extracted.
Returns
  • blank if not found
See Also
  • tokenByCode(String, String, String)

public String featureTokenByGroup (String regExpr_p, String groupIdx_p)

Since: API Level v2

retrieve the specific group value from the current feature label that match the regular expression passed in. The regular expression must define the groups and the groupIdx_p refers to the group id of the matched groups to be returned.

Returns
  • blank if no match or specified group out of range.
See Also
  • tokenByGroup(String, String,String)

public String featureTokenByIdx (String idx_p)

Since: API Level v2

extracts nth token from the current feature label.

Example: $featureTokenByIdx ('2') to extract the second token.

Parameters
idx_p 1-based index of the token to be extracted.
Returns
  • blank if not found
See Also
  • tokenByIdx(String,String)

public String scenarioTokenByAnchors (String prefix_p, String suffix_p)

Since: API Level v2

extracts a substring from current scenario label that is enclosed by the specified text strings before and after the substring.

Example: Suppose the scenario label is 'This scenario is to test the substring extraction'

Then the following MScript will return "substring":
$scenarioTokenByAnchors ('test the ', ' extraction').

Returns
  • blank if not found
See Also
  • tokenByAnchors(String, String,String)

public String scenarioTokenByCode (String tokenKey_p, String idx_p)

Since: API Level v2

extracts nth token from the current scenario label.

Example: $scenarioTokenByCode ('X','2') to extract "msg" from 'Test message [abc:X] must be displayed and another [msg:X] should also be displayed'.

Parameters
idx_p 1-based index of the token to be extracted.
Returns
  • blank if not found
See Also
  • tokenByCode(String, String, String)

public String scenarioTokenByCode (String tokenKey_p)

Since: API Level v2

extracts first token from the current scenario label.

Example: $scenarioTokenByCode ('X') to extract "abc" from 'Test message [abc:X] must be displayed and another [msg:X] should also be displayed'.

Returns
  • blank if not found
See Also
  • tokenByCode(String, String)

public String scenarioTokenByGroup (String regExpr_p, String groupIdx_p)

Since: API Level v2

retrieve the specific group value from the current feature label that match the regular expression passed in. The regular expression must define the groups and the groupIdx_p refers to the group id of the matched groups to be returned.

Returns
  • blank if no match or specified group out of range.
See Also
  • tokenByGroup (String,String,String)

public String scenarioTokenByIdx (String idx_p)

Since: API Level v2

extracts nth token from the current scenario label.

Example: $scenarioTokenByIdx ('2') to extract the second token.

Parameters
idx_p 1-based index of the token to be extracted.
Returns
  • blank if not found
See Also
  • tokenByIdx(String,String)

public String tokenByAnchors (String text_p, String prefix_p, String suffix_p)

Since: API Level v2

extracts first token from text_p. The token is specified in this format: [tokenString:X].

Example: $tokenByAnchors ('We accept quarters and half-dallar coins', 'accept', 'and') to extract "quarters".

Parameters
text_p text string to search for matches
Returns
  • blank if not found

public String tokenByCode (String text_p, String tokenKey_p)

Since: API Level v2

extracts nth token present in parameter text_p. The token is identified by a prefix character specified and followed by a space character or end of the line.

Example: $tokenByCode ('Test message [abc:X] must be displayed and another [msg:A] should also be displayed', 'X') to extract "abc"

Parameters
text_p text string to search for matches
tokenKey_p charater strings.
Returns
  • blank if not found

public String tokenByCode (String text_p, String tokenKey_p, String idx_p)

Since: API Level v2

extracts the specified token from text_p. The token is specified in this format: [tokenString:X].

Example: $tokenByCode ('test message [token 1:X] more [token 2:X]', 'X', '2') to extract "token 2".

Parameters
text_p text string to search for matches
tokenKey_p character strings
Returns
  • blank if not found

public String tokenByGroup (String text_p, String regExpr_p, String groupIdx_p)

Since: API Level v2

retrieve the specific group string from the text_p that match the regular expression passed in. The regular expression must define the capturing groups and the groupIdx_p refers to the group id of the matched groups to be returned.

Returns
  • blank if no match or specified group out of range.

public String tokenByIdx (String text_p, String idx_p)

Since: API Level v2

extracts nth token present in parameter text_p. The token is identified by the enclosure with "[]".

Example: $tokenByIdx ('2') to extract the second token enclosed by "[]".

Parameters
idx_p 1-based index of the token to be extracted.
Returns
  • blank if not found