Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*******************************************************************************
* QMetry Automation Framework provides a powerful and versatile platform to author
* Automated Test Cases in Behavior Driven, Keyword Driven or Code Driven approach
*
* Copyright 2016 Infostretch Corporation
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
* OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
*
* You should have received a copy of the GNU General Public License along with this program in the name of LICENSE.txt in the root folder of the distribution. If not, see https://opensource.org/licenses/gpl-3.0.html
*
* See the NOTICE.TXT file in root folder of this source files distribution
* for additional information regarding copyright ownership and licenses
* of other open source software / files used by QMetry Automation Framework.
*
* For any inquiry or need additional information, please contact [email protected]
*******************************************************************************/
package com.qmetry.qaf.automation.step.client.text;
import static com.qmetry.qaf.automation.core.ConfigurationManager.getBundle;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.qmetry.qaf.automation.util.StringMatcher;
import com.qmetry.qaf.automation.util.StringUtil;
/**
* @author chirag.jayswal
*/
public class BDDDefinitionHelper {
/**
* This enumeration specifies BDD keywords used while BDD step mapping. You
* can specify synonyms for keyword in properties file by using keyword name
* as key.
*
* For example to specify Synonyms for "Given" keyword provide property:
*
* Given=Provided;GivenThat;Assume
*
* Above property enable "Provided", "GivenThat" and "Assume" as synonym of
* "Given"
*
* @author chirag.jayswal
*/
public enum BDDKeyword {
Given, When, Then, And, Using, Having, With;
/**
* all keywords including synonyms
*
* @return
*/
public static List getAllKeyWords() {
List keywords = new ArrayList();
for (BDDKeyword keyword : BDDKeyword.values()) {
keywords.add(keyword.name());
// add all synonyms for this keyword
for (String synonym : keyword.getSynonyms()) {
keywords.add(synonym);
}
}
return keywords;
}
public static String getKeyWordRegEx() {
StringBuilder sb = new StringBuilder("^(");
for (String keyword : getAllKeyWords()) {
sb.append(keyword);
sb.append("|");
}
sb.deleteCharAt(sb.length() - 1); // remove last |
sb.append(")");
return sb.toString();
}
/**
* @return Synonyms for keyword defined in properties using
* {@link BDDKeyword} name as key.
*/
public List getSynonyms() {
List synonyms = new ArrayList();
for (Object object : getBundle().getList(name())) {
if (null != object && StringUtil.isNotBlank(object.toString()))
synonyms.add(object.toString());
}
return synonyms;
}
public static String getKeywordFrom(String behavior) {
String regx = getKeyWordRegEx();
Pattern p = Pattern.compile(regx, Pattern.CASE_INSENSITIVE);
Matcher matcher = p.matcher(behavior);
if (matcher.find())
return matcher.group();
return "";
}
}
public enum ParamType {
STRING(
// "('[^(\\\\')*]*((\\\\')*(\\*|\\!|\\(|\\))*[^(\\\\')*]*)*')|(\"[^(\\\\\")*]*((\\\\\")*(\\*|\\!|\\(|\\))*[^(\\\\\")*]*)*\")"),
"('([^\\\\']|\\\\\\\\|\\\\')*')|(\"([^\\\\\"]|\\\\\\\\|\\\\\")*\")","String str"), MAP("(\\{.*})","Map