Package org.qubership.atp.mia.utils
Class Utils
java.lang.Object
org.qubership.atp.mia.utils.Utils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longcalculateDuration(long startDateTimestamp) Calculates difference between startDateTimestamp and current timestamp.static booleancheckCondition(String erValue, String arValue) Check Condition expected result and actual result.static voidcloseQuietly(AutoCloseable closeable) Behaves like a apache IOUtils.static intcorrectPlaceInList(List<?> list, int place) Bounds check place for List.static MiaExceptionerror(org.slf4j.Logger log, ErrorCodes errorCode, Object... params) Throws an exception and adds an error to the log.static DbTypeThis method takes a type of database from environment and returns it as an enum.static StringgetFileNameFromPath(String path) static StringgetFileNameWithoutExtension(String fileName) Gets file name without extension.static StringgetFileNameWithTimestamp(String fileName) Add timestamp to file name.static StringgetFirstGroupFromStringByRegexp(String string, String regex) Get variables from log.static StringgetHeaderValue(org.apache.http.HttpResponse httpResponse, String headerName) Get header value from the response header by passing header name as input.getPathToFileOutOfLog(String outputFilePath, String regex) Get paths to files from log.static StringgetPrettyStringFromXml(String xmlData) Transforms xml response to pretty string.static SwitchergetSystemSwitcherByName(Constants.SystemSwitcherNames name, List<Switcher> systemSwitchers) static Stringstatic Stringstatic ExceptionNeed to fill empty exception before return to client side.static booleanisHeaderNamePresent(org.apache.http.HttpResponse httpResponse, String headerName) check content-disposition is present in http response header.static LinkedHashSet<String> static LinkedHashSet<String> static StringmaxExcelString(String stringForCell) Excel cell have a limit for length of cell.static voidnameProcessValidator(String name) Check process name for valid value.static longparseLongValueOrDefault(String valueToParse, long defaultValue, String valueName) Parses long value from string.static StringprepareRestHeaders(Map<String, String> headers) Get header in form of supported by MIA .static voidsleepForTimeInMillSeconds(long millSeconds) Wait for provided number of milliSecondsTime.static <T> Stream<T> static StringurlEvaluator(String url, Map<String, String> parameters) evaluate url using query params.
-
Field Details
-
GSON
public static final com.google.gson.Gson GSON
-
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
nameProcessValidator
Check process name for valid value.- Parameters:
name- name of Process
-
correctPlaceInList
Bounds check place for List.- Parameters:
list- the listplace- desired position- Returns:
- bounded position
-
getDbType
This method takes a type of database from environment and returns it as an enum.- Parameters:
server- - class which allows us to manipulate with environment.- Returns:
- database type, defined in enum in SqlExecutor.class.
-
closeQuietly
Behaves like a apache IOUtils. -
streamOf
-
getPathToFileOutOfLog
Get paths to files from log. -
getFileNameFromPath
-
getTimestampFile
-
getTimestamp
-
getFileNameWithoutExtension
Gets file name without extension.- Parameters:
fileName- fileName- Returns:
- file name without extension
-
getFileNameWithTimestamp
Add timestamp to file name. -
isHeaderNamePresent
public static boolean isHeaderNamePresent(org.apache.http.HttpResponse httpResponse, String headerName) check content-disposition is present in http response header. -
getHeaderValue
Get header value from the response header by passing header name as input. -
urlEvaluator
evaluate url using query params. -
prepareRestHeaders
Get header in form of supported by MIA . -
getFirstGroupFromStringByRegexp
Get variables from log. -
checkCondition
Check Condition expected result and actual result. -
error
Throws an exception and adds an error to the log. -
listToSet
-
listToSet
-
getSystemSwitcherByName
public static Switcher getSystemSwitcherByName(Constants.SystemSwitcherNames name, List<Switcher> systemSwitchers) -
getPrettyStringFromXml
Transforms xml response to pretty string. -
maxExcelString
Excel cell have a limit for length of cell.- Parameters:
stringForCell- string for cell- Returns:
- string
-
parseLongValueOrDefault
public static long parseLongValueOrDefault(String valueToParse, long defaultValue, String valueName) Parses long value from string. IfNumberFormatExceptionoccur, then default value is used. Default use while parsing@Valueannotation.- Parameters:
valueToParse- string value to parse.defaultValue- ifvalueToParseincorrect use this one.valueName- field name to show in logs.- Returns:
- parsed value.
-
handleException
Need to fill empty exception before return to client side.- Parameters:
e- source exception- Returns:
- the source exception or filled with message in case if the source one was empty.
-
sleepForTimeInMillSeconds
public static void sleepForTimeInMillSeconds(long millSeconds) Wait for provided number of milliSecondsTime. -
calculateDuration
public static long calculateDuration(long startDateTimestamp) Calculates difference between startDateTimestamp and current timestamp.- Parameters:
startDateTimestamp- input parameter, timestamp in ms- Returns:
- difference between startDateTimestamp and current timestamp.
-