public final class TestHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
NULL_STRING
GUID to represent NUll string.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areHeadersProperSubsetOf(Map<String,String> leftTree,
Map<String,String> rightTree,
boolean checkValues)
Recursively check whether the left headers map is a proper subset of the right headers map.
|
static boolean |
containsBigDecimalList(List<BigDecimal> actual,
List<BigDecimal> expected)
Checks actual list against expected list, without considering order of elements and actual.
|
static String |
convertStreamToString(InputStream is)
Convert an InputStream to a String (utility function).
|
static boolean |
equalsBigDecimalList(List<BigDecimal> actual,
List<BigDecimal> expected)
Checks actual list against expected list to have same order and count and all corresponding
values must be equal.
|
static File |
getFile(String urlString)
Downloads a given url and return a path to its local version.
|
static boolean |
isArrayOfArrayOfJsonObjectsProperSubsetOf(String leftObject,
String rightObject,
boolean checkValues,
boolean allowExtra,
boolean isOrdered)
Check if left array of array of objects is a subset of right array of array of objects.
|
static boolean |
isArrayOfJsonObjectsProperSubsetOf(String leftObject,
String rightObject,
boolean checkValues,
boolean allowExtra,
boolean isOrdered)
Check if left array of objects is a subset of right array.
|
static boolean |
isJsonObjectProperSubsetOf(String leftObject,
String rightObject,
boolean checkValues,
boolean allowExtra,
boolean isOrdered)
Recursively check whether the left JSON object is a proper subset of the right JSON object.
|
static boolean |
isProperSubsetOf(String leftObject,
String rightObject,
boolean checkValues,
boolean allowExtra,
boolean isOrdered)
Utility to delegate call to suitable method.
|
static boolean |
isSameAsFile(String file,
InputStream input)
Compare the input stream to file byte-by-byte.
|
static <T> String |
prepareForComparison(String json,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
Modify a json String according to a given TypeReference, ensuring that inner fields are dealt
with properly.
|
public static final String NULL_STRING
public static <T> String prepareForComparison(String json, com.fasterxml.jackson.core.type.TypeReference<T> typeReference) throws com.fasterxml.jackson.core.JsonProcessingException, IOException
T - The extended type.json - The json String to modify.typeReference - The TypeReference to use.com.fasterxml.jackson.core.JsonProcessingException - when problems encountered when processing (parsing,
generating) JSON content.IOException - if comparison got failed.public static String convertStreamToString(InputStream is)
is - Input stream to read from.public static boolean isProperSubsetOf(String leftObject, String rightObject, boolean checkValues, boolean allowExtra, boolean isOrdered) throws IOException
leftObject - Left array as a JSON string.rightObject - Right array as a JSON string.checkValues - Check primitive values for equality?.allowExtra - Are extra elements allowed in right array?.isOrdered - Should elements in right be compared in order to left?.IOException - if deserialization got failed.public static boolean isJsonObjectProperSubsetOf(String leftObject, String rightObject, boolean checkValues, boolean allowExtra, boolean isOrdered) throws IOException
leftObject - Left JSON object as string.rightObject - Right JSON object as string.checkValues - Check primitive values for equality?.allowExtra - extra value is allowed?.isOrdered - object value is in order?.IOException - Signal that I/O errors occur.public static boolean isArrayOfArrayOfJsonObjectsProperSubsetOf(String leftObject, String rightObject, boolean checkValues, boolean allowExtra, boolean isOrdered) throws IOException
leftObject - Left array as a JSON string.rightObject - Right array as a JSON string.checkValues - Check primitive values for equality?.allowExtra - Are extra elements allowed in right array?.isOrdered - Should elements in right be compared in order to left?.IOException - if deserialization got failed.public static boolean isArrayOfJsonObjectsProperSubsetOf(String leftObject, String rightObject, boolean checkValues, boolean allowExtra, boolean isOrdered) throws IOException
leftObject - Left array as a JSON string.rightObject - Right array as a JSON string.checkValues - Check primitive values for equality?.allowExtra - Are extra elements allowed in right array?.isOrdered - Should elements in right be compared in order to left?.IOException - if deserialization got failed.public static boolean areHeadersProperSubsetOf(Map<String,String> leftTree, Map<String,String> rightTree, boolean checkValues)
leftTree - Left headers map.rightTree - Right headers map.checkValues - Check header values for equality?.public static boolean isSameAsFile(String file, InputStream input) throws FileNotFoundException, IOException
file - First input.input - Second input.IOException - If error reading either stream.FileNotFoundException - If file could not be opened.public static File getFile(String urlString) throws IOException
urlString - URL to download.IOException - Signals that I/O error occur.public static boolean equalsBigDecimalList(List<BigDecimal> actual, List<BigDecimal> expected)
actual - List of BigDecimal.expected - List of BigDecimal.public static boolean containsBigDecimalList(List<BigDecimal> actual, List<BigDecimal> expected)
actual - List of BigDecimal.expected - List of BigDecimal.Copyright © 2023. All rights reserved.