public class GeneralUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
createErrorMessageFromExceptionWithText(Exception e,
String errorText) |
static Calendar |
fromISO8601DateTime(String dateTime)
Creates
Calendar instance from an ISO 8601 formatted
string. |
static Date |
getDate(DateFormat format,
String date)
Gets date.
|
static boolean |
getDontCloseBatches() |
static String |
getEnvString(String applitools_env) |
static long |
getFullSecondsElapsedTimeMillis(long start,
long end)
Gets full seconds elapsed time millis.
|
static byte[] |
getGzipByteArrayOutputStream(String domJson)
Get gzip byte array output stream byte [ ].
|
static String |
getLastWordOfStringWithRegex(String charSequence,
String regex) |
static String |
getPropertyString(String property) |
static URI |
getServerUrl()
Gets default server url.
|
static String |
getSha256hash(byte[] content)
Gets sha 256 hash.
|
static String |
getSha256hash(Byte[] content)
Gets sha 256 hash.
|
static byte[] |
getUnGzipByteArrayOutputStream(byte[] gZippedString)
Get un gzip byte array output stream byte [ ].
|
static void |
logExceptionStackTrace(Logger logger,
Stage stage,
Throwable ex,
String... testIds) |
static void |
logExceptionStackTrace(Logger logger,
Stage stage,
Type type,
Throwable ex,
String... testIds) |
static <T> T |
parseJsonToObject(String jsonStr,
Class<T> tClass)
Parse json to object t.
|
static byte[] |
readInputStream(InputStream inputStream) |
static String |
readInputStreamAsString(InputStream inputStream) |
static String |
readTextFromResource(String resource)
Creates a
String from a file specified by resource. |
static String |
sanitizeURL(String urlToSanitize) |
static void |
sleep(long milliseconds)
Sleeps the input amount of milliseconds.
|
static String |
toISO8601DateTime(Calendar calendar)
Formats date and time as represented by a calendar instance to an ISO
8601 string.
|
static String |
toRfc1123(Calendar calendar)
Formats date and time as represented by a calendar instance to an TFC
1123 string.
|
static void |
tryRunTaskWithRetry(EyesRunnable task,
long retryTimeoutSeconds,
long sleepTimeBetweenRetiesMS,
String errorMessageOnTimeout,
Logger logger) |
public static byte[] readInputStream(InputStream inputStream) throws IOException
IOExceptionpublic static String readInputStreamAsString(InputStream inputStream) throws IOException
IOExceptionpublic static String toISO8601DateTime(Calendar calendar)
calendar - The date and time which we would like to format.public static String toRfc1123(Calendar calendar)
calendar - The date and time which we would like to format.public static Calendar fromISO8601DateTime(String dateTime) throws ParseException
Calendar instance from an ISO 8601 formatted
string.dateTime - An ISO 8601 formatted string.Calendar instance representing the given date and time.ParseException - the parse exceptionpublic static void sleep(long milliseconds)
milliseconds - The number of milliseconds to sleep.public static Date getDate(DateFormat format, String date)
format - The date format parser.date - The date string in a format matching format.Date represented by the input string.public static long getFullSecondsElapsedTimeMillis(long start,
long end)
start - The start time. (Milliseconds)end - The end time. (Milliseconds).public static String readTextFromResource(String resource)
String from a file specified by resource.resource - The resource path.EyesException - If there was a problem reading the resource.public static void logExceptionStackTrace(Logger logger, Stage stage, Throwable ex, String... testIds)
public static void logExceptionStackTrace(Logger logger, Stage stage, Type type, Throwable ex, String... testIds)
public static URI getServerUrl()
public static byte[] getGzipByteArrayOutputStream(String domJson)
domJson - JSON as string to be gzippedpublic static byte[] getUnGzipByteArrayOutputStream(byte[] gZippedString)
throws IOException
gZippedString - byte array gzipped encodedIOException - the io exceptionpublic static <T> T parseJsonToObject(String jsonStr, Class<T> tClass) throws IOException
T - The type parameterjsonStr - The JSON string to parsetClass - The Class object of Type TT, created by parsing of the given JSON stringIOException - An IO Exceptionpublic static String getSha256hash(Byte[] content)
content - the contentpublic static String getSha256hash(byte[] content)
content - the contentpublic static boolean getDontCloseBatches()
public static String getLastWordOfStringWithRegex(String charSequence, String regex)
public static void tryRunTaskWithRetry(EyesRunnable task, long retryTimeoutSeconds, long sleepTimeBetweenRetiesMS, String errorMessageOnTimeout, Logger logger) throws EyesException
EyesExceptionCopyright © 2023. All rights reserved.