Class ParameterValidator
- java.lang.Object
-
- org.uitnet.testing.smartfwk.validator.ParameterValidator
-
public class ParameterValidator extends Object
Used to validate parameter values from JSON, YAML, XML documents.- Author:
- Madhav Krishna
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidfail(String message)Used to fail the step.static voidvalidateParamContainsExactlySameElementsAsExpected(String paramName, Collection<String> actualElements, Collection<String> expectedElements)Validate field contains exactly same elements as in expected elements.static voidvalidateParamContainsExactlySameElementsInOrderAsExpected(String paramName, List<String> actualElements, List<String> expectedElements)Validate field contains exactly same elements as in expected elements and in the same order.static voidvalidateParamLengthAsOfExpectedLength(String paramName, Collection<String> actualElements, Collection<String> expectedElements)This checks the actualElements length is same as expectedElements length.static voidvalidateParamValueAsEmail(String paramName, String actualValue)Validate field value as a valid email.static voidvalidateParamValueAsEmpty(String paramName, Object actualValue)Considers null and empty value as empty.static voidvalidateParamValueAsExpectedDateTimeFormat(String paramName, String actualValue, String expectedDateFormat)Validates Date Time format for the Date Time field.static voidvalidateParamValueAsExpectedInfo(boolean isField, ParamPath param, Object actualValue, String operator, ExpectedInfo expectedInfo)static voidvalidateParamValueAsExpectedValue(String paramName, Object actualValue, Object expectedValue)Validates field value as expected value.static voidvalidateParamValueAsExpectedValue(String paramName, Object actualValue, Object expectedValue, TextMatchMechanism textMatchMechanism)Validates field value should match with expected value based on text match mechanism.static voidvalidateParamValueAsNonEmpty(String paramName, Object actualValue)Considers null and empty value as empty.static voidvalidateParamValueAsNonNumeric(String paramName, String actualValue, boolean removeComma)Validates field value as non-numeric.static voidvalidateParamValueAsNotExpectedValue(String paramName, Object actualValue, Object expectedValue)Validates field value as not expected value.static voidvalidateParamValueAsNotNull(String paramName, Object actualValue)Validates field value as not null.static voidvalidateParamValueAsNull(String paramName, Object actualValue)Validates field value as null.static voidvalidateParamValueAsNumeric(String paramName, String actualValue, boolean removeComma)Validates field value as numeric.static voidvalidateParamValueAsNumericButNotDecimal(String paramName, String actualValue, boolean removeComma)Validates field value as numeric but not decimal.static voidvalidateParamValueAsOfExpectedLength(String paramName, Object actualValue, int expectedLength)Validates field value contains the same number of characters as expected count.static voidvalidateParamValueInExpectedRange(String paramName, Double value, double min, double max)Validate field value in expected range.static voidvalidateParamValueInExpectedRange(String paramName, Integer value, int min, int max)Validate field value in expected range.static voidvalidateParamValueInExpectedRange(String paramName, Long value, long min, long max)Validate field value in expected range.
-
-
-
Method Detail
-
validateParamValueAsNull
public static void validateParamValueAsNull(String paramName, Object actualValue)
Validates field value as null.- Parameters:
paramName-actualValue-
-
validateParamValueAsNotNull
public static void validateParamValueAsNotNull(String paramName, Object actualValue)
Validates field value as not null.- Parameters:
paramName-actualValue-
-
validateParamValueAsEmpty
public static void validateParamValueAsEmpty(String paramName, Object actualValue)
Considers null and empty value as empty. It removes all leading and trailing whitespaces to check empty.- Parameters:
paramName-actualValue-
-
validateParamValueAsNonEmpty
public static void validateParamValueAsNonEmpty(String paramName, Object actualValue)
Considers null and empty value as empty. It removes all leading and trailing whitespaces to check empty.- Parameters:
paramName-actualValue-
-
validateParamValueAsNumeric
public static void validateParamValueAsNumeric(String paramName, String actualValue, boolean removeComma)
Validates field value as numeric.- Parameters:
paramName-actualValue-removeComma-
-
validateParamValueAsNumericButNotDecimal
public static void validateParamValueAsNumericButNotDecimal(String paramName, String actualValue, boolean removeComma)
Validates field value as numeric but not decimal.- Parameters:
paramName-actualValue-removeComma-
-
validateParamValueAsNonNumeric
public static void validateParamValueAsNonNumeric(String paramName, String actualValue, boolean removeComma)
Validates field value as non-numeric.- Parameters:
paramName-actualValue-removeComma-
-
validateParamValueAsExpectedValue
public static void validateParamValueAsExpectedValue(String paramName, Object actualValue, Object expectedValue)
Validates field value as expected value. Only numeric and String arguments are allowed.- Parameters:
paramName-actualValue-expectedValue-
-
validateParamValueAsExpectedValue
public static void validateParamValueAsExpectedValue(String paramName, Object actualValue, Object expectedValue, TextMatchMechanism textMatchMechanism)
Validates field value should match with expected value based on text match mechanism. Only numeric and String arguments are allowed.- Parameters:
paramName-actualValue-expectedValue-validationMechanism-
-
validateParamValueAsNotExpectedValue
public static void validateParamValueAsNotExpectedValue(String paramName, Object actualValue, Object expectedValue)
Validates field value as not expected value. Only numeric and String arguments are allowed.- Parameters:
paramName-actualValue-expectedValue-
-
validateParamValueAsExpectedDateTimeFormat
public static void validateParamValueAsExpectedDateTimeFormat(String paramName, String actualValue, String expectedDateFormat)
Validates Date Time format for the Date Time field. Date time format examples: 1. MM/dd/yyyy 2. MM/dd/yyyy HH:mm:ss 3. MM/dd/yyyy HH:mm:ss.SSS z- Parameters:
paramName-actualValue-expectedDateFormat-
-
validateParamValueAsOfExpectedLength
public static void validateParamValueAsOfExpectedLength(String paramName, Object actualValue, int expectedLength)
Validates field value contains the same number of characters as expected count.- Parameters:
paramName- - field nameactualValue- - field valueexpectedLength- - expected char count.
-
validateParamValueAsEmail
public static void validateParamValueAsEmail(String paramName, String actualValue)
Validate field value as a valid email.- Parameters:
paramName-actualValue-
-
validateParamValueInExpectedRange
public static void validateParamValueInExpectedRange(String paramName, Double value, double min, double max)
Validate field value in expected range.- Parameters:
paramName-value-min-max-
-
validateParamValueInExpectedRange
public static void validateParamValueInExpectedRange(String paramName, Integer value, int min, int max)
Validate field value in expected range.- Parameters:
paramName-value-min-max-
-
validateParamValueInExpectedRange
public static void validateParamValueInExpectedRange(String paramName, Long value, long min, long max)
Validate field value in expected range.- Parameters:
paramName-value-min-max-
-
validateParamLengthAsOfExpectedLength
public static void validateParamLengthAsOfExpectedLength(String paramName, Collection<String> actualElements, Collection<String> expectedElements)
This checks the actualElements length is same as expectedElements length. If not then throw error with differential information.- Parameters:
paramName-actualElements-expectedElements-
-
validateParamContainsExactlySameElementsAsExpected
public static void validateParamContainsExactlySameElementsAsExpected(String paramName, Collection<String> actualElements, Collection<String> expectedElements)
Validate field contains exactly same elements as in expected elements. Order does not match. Also removes leading and trailing spaces.- Parameters:
paramName-actualElements-expectedElements-
-
validateParamContainsExactlySameElementsInOrderAsExpected
public static void validateParamContainsExactlySameElementsInOrderAsExpected(String paramName, List<String> actualElements, List<String> expectedElements)
Validate field contains exactly same elements as in expected elements and in the same order. Also removes leading and trailing spaces.- Parameters:
paramName-actualElements-expectedElements-
-
validateParamValueAsExpectedInfo
public static void validateParamValueAsExpectedInfo(boolean isField, ParamPath param, Object actualValue, String operator, ExpectedInfo expectedInfo)
-
fail
public static void fail(String message)
Used to fail the step.- Parameters:
message-
-
-