Package com.applitools.utils
Class GeneralUtils
java.lang.Object
com.applitools.utils.GeneralUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateErrorMessageFromExceptionWithText(Exception e, String errorText) static StringcreateEyesMessageWithLevel(String message, String level) static CalendarfromISO8601DateTime(String dateTime) CreatesCalendarinstance from an ISO 8601 formatted string.static DategetDate(DateFormat format, String date) Gets date.static booleanstatic StringgetEnvString(String applitools_env) static longgetFullSecondsElapsedTimeMillis(long start, long end) Gets full seconds elapsed time millis.static byte[]getGzipByteArrayOutputStream(String domJson) Get gzip byte array output stream byte [ ].static StringgetLastWordOfStringWithRegex(String charSequence, String regex) static StringgetPropertyString(String property) static URIGets default server url.static StringgetSha256hash(byte[] content) Gets sha 256 hash.static StringgetSha256hash(Byte[] content) Gets sha 256 hash.static byte[]getUnGzipByteArrayOutputStream(byte[] gZippedString) Get un gzip byte array output stream byte [ ].static voidstatic voidlogExceptionStackTrace(Logger logger, Stage stage, Throwable ex, String... testIds) static <T> TparseJsonToObject(String jsonStr, Class<T> tClass) Parse json to object t.static byte[]readInputStream(InputStream inputStream) static StringreadInputStreamAsString(InputStream inputStream) static StringreadTextFromResource(String resource) Creates aStringfrom a file specified byresource.static StringsanitizeURL(String urlToSanitize) static voidsleep(long milliseconds) Sleeps the input amount of milliseconds.static StringtoISO8601DateTime(Calendar calendar) Formats date and time as represented by a calendar instance to an ISO 8601 string.static StringFormats date and time as represented by a calendar instance to an TFC 1123 string.static voidtryRunTaskWithRetry(EyesRunnable task, long retryTimeoutSeconds, long sleepTimeBetweenRetiesMS, String errorMessageOnTimeout, Logger logger)
-
Method Details
-
readInputStream
- Throws:
IOException
-
readInputStreamAsString
- Throws:
IOException
-
toISO8601DateTime
-
toRfc1123
-
fromISO8601DateTime
CreatesCalendarinstance from an ISO 8601 formatted string.- Parameters:
dateTime- An ISO 8601 formatted string.- Returns:
- A
Calendarinstance representing the given date and time. - Throws:
ParseException- the parse exception
-
sleep
public static void sleep(long milliseconds) Sleeps the input amount of milliseconds.- Parameters:
milliseconds- The number of milliseconds to sleep.
-
getDate
Gets date.- Parameters:
format- The date format parser.date- The date string in a format matchingformat.- Returns:
- The
Daterepresented by the input string.
-
getFullSecondsElapsedTimeMillis
public static long getFullSecondsElapsedTimeMillis(long start, long end) Gets full seconds elapsed time millis.- Parameters:
start- The start time. (Milliseconds)end- The end time. (Milliseconds).- Returns:
- The elapsed time between the start and end times, rounded up to a full second, in milliseconds.
-
readTextFromResource
Creates aStringfrom a file specified byresource.- Parameters:
resource- The resource path.- Returns:
- The resource's text.
- Throws:
EyesException- If there was a problem reading the resource.
-
logExceptionStackTrace
-
logExceptionStackTrace
-
getServerUrl
-
getGzipByteArrayOutputStream
Get gzip byte array output stream byte [ ].- Parameters:
domJson- JSON as string to be gzipped- Returns:
- byte[] of the gzipped string
-
getUnGzipByteArrayOutputStream
Get un gzip byte array output stream byte [ ].- Parameters:
gZippedString- byte array gzipped encoded- Returns:
- byte[] of the ungzipped byte array
- Throws:
IOException- the io exception
-
parseJsonToObject
Parse json to object t.- Type Parameters:
T- The type parameter- Parameters:
jsonStr- The JSON string to parsetClass- The Class object of TypeT- Returns:
- An instance of Class
T, created by parsing of the given JSON string - Throws:
IOException- An IO Exception
-
getSha256hash
-
getSha256hash
Gets sha 256 hash.- Parameters:
content- the content- Returns:
- the sha 256 hash
-
sanitizeURL
-
getEnvString
-
getDontCloseBatches
public static boolean getDontCloseBatches() -
getPropertyString
-
getLastWordOfStringWithRegex
-
tryRunTaskWithRetry
public static void tryRunTaskWithRetry(EyesRunnable task, long retryTimeoutSeconds, long sleepTimeBetweenRetiesMS, String errorMessageOnTimeout, Logger logger) throws EyesException - Throws:
EyesException
-
createErrorMessageFromExceptionWithText
-
createEyesMessageWithLevel
-