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 |
TEST_DATA_TEMPLATE_DATA_PATH |
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 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 String |
getTime(String parameter,
String timeString)
get time based time modification, format or fixed time eg.
|
static String |
getTimeSubstring(String parameter,
String finalTime)
get substring of time based on time string length format _TIME_STRING_17-72h.
|
static String |
getTimeWithModification(String parameter,
String timeString)
time: _TIME_STRING_17-72h or _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 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 |
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 List<String> |
removeEmptyElements(List<String> list)
removes empty elements from list
|
static String[] |
removeEmptyElements(String[] array) |
static String |
removeFirstAndLastChars(String value,
String... toRemove)
removes surrounding character from string
|
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 String |
setDay(String dayName,
String timeString)
set day based on format setDay:Day
|
static String |
setInitialDate(String parameter)
set time to time
overwrites the TestObject.START_TIME_STRING value
|
static String |
setMonth(String monthName,
String timeString)
set month based on format setMonth:Month
|
static String |
setTime(String parameter,
String timeString)
sets time based on format: setTime:hh:mm:ss eg: 14:42:33 any combination will
work uses utc zone to set time
|
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)
validates response against expected values
|
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 String replaceParameters(String source, String tagPattern, String openingTag, String closingTag)
source - public static int getIncrementalValue(String parameter)
parameter - public static String getTimeSubstring(String parameter, String finalTime)
parameter - maxLength - finalTime - public static String getTime(String parameter, String timeString)
parameter - timeString - public static String setInitialDate(String parameter)
parameter - public static String setTime(String parameter, String timeString)
parameter - timeString - public static String setDay(String dayName, String timeString)
parameter - timeString - public static String setMonth(String monthName, String timeString)
monthName - timeString - public static String removeFirstAndLastChars(String value, String... toRemove)
value - toRemove - public static String getTimeWithModification(String parameter, String timeString)
parameter: - time parameter with modification. eg. _TIME_STRING_17-72htimeString - 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)
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 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 © 2020. All rights reserved.