public class DataHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
DataHelper.JSON_COMMAND |
| Modifier and Type | Field and Description |
|---|---|
static String |
EXPECTED_MESSAGE_COUNT |
static String |
IS_IGNORE_XML_NAMESPACE |
static String |
REQUEST_BODY_UPDATE_INDICATOR |
static String |
TEST_DATA_TEMPLATE_DATA_PATH |
static String |
VALIDATION_AND_CONDITION |
static String |
VALIDATION_OR_CONDITION |
static String |
VALIDATION_OR_CONDITION_ECODE |
static String |
VERIFY_HEADER_PART_INDICATOR |
static String |
VERIFY_JSON_PART_INDICATOR |
static String |
VERIFY_JSON_PART_INDICATOR_UNDERSCORE |
static String |
VERIFY_RESPONSE_BODY_INDICATOR |
static String |
VERIFY_RESPONSE_NO_EMPTY |
static String |
VERIFY_TOPIC_PART_INDICATOR |
| Constructor and Description |
|---|
DataHelper() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
compareNumbers(double value1,
double value2,
String comparator)
compare integer values
|
static boolean |
compareNumbers(String value1,
String value2,
String comparator)
compare string integer values based on comparator value
|
static String |
convertFileToString(Path templatePath)
get file content as text replaces parameters using syntax <@variable> from
value in config
|
static boolean |
evaluateLogic(String logicString)
evaluates string logic.
|
static File |
getFile(String filename) |
static int |
getIncrementalValue(String parameter)
incremental keyword value setter starting value + current run count by
default: starting value = 1 eg.
|
static String |
getRequestBodyIncludingTemplate(ServiceObject serviceObject)
get request body from template file: json, xml, other json template: - if
request body is set, replace value in template with format: - request body:
json path:position:value or json path:vlaue - eg.
|
static List<String> |
getResponseArray(String array)
converts string separated by "," to array[] trims each value and removes
quotes or array brackets
|
static int |
getResponseArrayLength(List<String> actualArray,
String responseString) |
static String |
getSectionFromExpectedResponse(String section,
String expectedResponse)
get section from expected response separated by && the section will start
with the identifier.
|
static String |
getServiceObjectTemplateString(ServiceObject serviceObject)
returns service object template file as string Template file name is from
Template column in csv
|
static String |
getTemplateFileLocation(String file) |
static Path |
getTemplateFilePath(String file) |
static Instant |
getTimeInstance(String timeString) |
static String |
getTimeSubstring(String parameter,
String finalTime)
get substring of time based on time string length format _TIME_STRING_17-72h.
|
static List<KeyValue> |
getValidationMap(String expected)
gets the map of the validation requirements split by ";"
|
static List<KeyValue> |
getValidationMap(String expected,
String separator)
gets the map of the validation requirements split by ";"
|
static String |
getValidationPattern(String criterion)
converts response validation to proper logic pattern
|
static boolean |
isEmpty(String value) |
static boolean |
isEmptyResponseExpected(String expected)
returns true if empty response is expected.
|
static boolean |
isGreaterThan(String value1,
String value2) |
static boolean |
isLessThan(String value1,
String value2) |
static Set<String> |
isListContain(String actual,
List<String> expectedValues)
verifies actual string contains list of expected values
|
static boolean |
isObjectEmpty(Object value) |
static boolean |
isValidExpectation(String expectedValue)
validates if expected value is valid: json, xml or starts with valid
indicator
|
static String |
listToString(List<String> values)
converts list to string separated by ","
|
static void |
loadDataFile(ServiceObject serviceObject)
loads template data info based on value set on request body format:
DataFile:file:dataId
|
static void |
logJsonResponse(List<String> responseValues) |
static String |
objectToString(Object values)
convert object to string object can be array
|
static String |
removeAndOrIndicator(String value)
removes && or || identifiers at the beginning of logic string
used for getting the actual expression to evaluate
format: eg.
|
static List<String> |
removeEmptyElements(List<String> list)
removes empty elements from list
|
static String[] |
removeEmptyElements(String[] array) |
static String |
removeLogicIdentifiers(String criterion)
remove logic values if criteria starts with "(", &&, "||" or end with ")"
|
static String |
removeSectionFromExpectedResponse(String section,
String expectedResponse)
remove section from expected response separated by && the section will start
with the identifier.
|
static String |
replaceParameters(String source) |
static String |
replaceParameters(String source,
String tagPattern,
String openingTag,
String closingTag)
replaces placeholder values with values from config properties replaces only
string values
|
static void |
saveDataToConfig(String source)
stores value in config format: value:<$key> separated by colon ';'
|
static List<String> |
splitRight(String value,
String regex,
int limit) |
static List<String> |
splitToKeyPositionValue(String keyvalue,
String regex,
int limit)
split based on key position value
|
static String |
validateCommand(String command,
String responseString,
String expectedString)
validates response against expected values
|
static String |
validateCommand(String command,
String responseString,
String expectedString,
String position,
boolean skipValidation)
validates response against expected values
if skipValidation = false -> response variable contains error
|
static List<String> |
validateEmptyResponse(List<String> responseValues,
String expected)
validates if empty response is expected and received
|
static String |
validateExpectedCommand(String command,
String responseString,
String expectedString,
String position)
validates response against expected values
|
static List<String> |
validateExpectedResponse(String criterion,
List<String> responseString)
validates expected requirement against response strings
|
static List<String> |
validateExpectedValues(List<String> responseValues,
String expectedResponse)
validates expected values (xml, json, text, or jsonpath keywords
|
public static final String VERIFY_JSON_PART_INDICATOR
public static final String VERIFY_JSON_PART_INDICATOR_UNDERSCORE
public static final String VERIFY_RESPONSE_BODY_INDICATOR
public static final String VERIFY_RESPONSE_NO_EMPTY
public static final String VERIFY_HEADER_PART_INDICATOR
public static final String VERIFY_TOPIC_PART_INDICATOR
public static final String EXPECTED_MESSAGE_COUNT
public static final String IS_IGNORE_XML_NAMESPACE
public static final String TEST_DATA_TEMPLATE_DATA_PATH
public static final String VALIDATION_OR_CONDITION_ECODE
public static final String VALIDATION_OR_CONDITION
public static final String VALIDATION_AND_CONDITION
public static final String REQUEST_BODY_UPDATE_INDICATOR
public static String replaceParameters(String source, String tagPattern, String openingTag, String closingTag)
source - public static boolean isObjectEmpty(Object value)
public static int getIncrementalValue(String parameter)
parameter - public static String getTimeSubstring(String parameter, String finalTime)
parameter - maxLength - finalTime - public static List<KeyValue> getValidationMap(String expected)
expected - public static List<KeyValue> getValidationMap(String expected, String separator)
expected - public static String getServiceObjectTemplateString(ServiceObject serviceObject)
apiObject - IOExceptionpublic static String validateCommand(String command, String responseString, String expectedString)
command - responseString - expectedString - public static String validateCommand(String command, String responseString, String expectedString, String position, boolean skipValidation)
command - responseString - expectedString - position - public static String validateExpectedCommand(String command, String responseString, String expectedString, String position)
command - responseString - expectedString - position - public static List<String> getResponseArray(String array)
array - public static int getResponseArrayLength(List<String> actualArray, String responseString)
public static boolean compareNumbers(String value1, String value2, String comparator)
value1 - value2 - comparator - public static boolean compareNumbers(double value1,
double value2,
String comparator)
value1 - value2 - comparator - public static String listToString(List<String> values)
values - public static String objectToString(Object values)
values - public static List<String> splitToKeyPositionValue(String keyvalue, String regex, int limit)
keyvalue - regex - limit - public static boolean isEmpty(String value)
public static String getRequestBodyIncludingTemplate(ServiceObject serviceObject)
serviceObject - public static void loadDataFile(ServiceObject serviceObject)
serviceObject - public static void saveDataToConfig(String source)
source - public static String convertFileToString(Path templatePath)
templatePath - public static String removeSectionFromExpectedResponse(String section, String expectedResponse)
section - expectedResponse - public static String getSectionFromExpectedResponse(String section, String expectedResponse)
section - expectedResponse - public static List<String> validateExpectedValues(List<String> responseValues, String expectedResponse)
responseValues - expectedResponse - public static String removeAndOrIndicator(String value)
value - public static boolean evaluateLogic(String logicString)
logicString - public static String removeLogicIdentifiers(String criterion)
criterion - public static String getValidationPattern(String criterion)
criterion - public static List<String> validateEmptyResponse(List<String> responseValues, String expected)
responseValues - expected - public static boolean isEmptyResponseExpected(String expected)
expected - public static List<String> validateExpectedResponse(String criterion, List<String> responseString)
criterion - responseString - public static boolean isValidExpectation(String expectedValue)
expectedValue - public static List<String> removeEmptyElements(List<String> list)
list - Copyright © 2022. All rights reserved.