Package org.alfresco.utility
Class Utility
java.lang.Object
org.alfresco.utility.Utility
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FileassertFileDoesNotExist(String filePath) Verify file from specified filePath doesn't existstatic FileassertFileExists(String filePath) Verify file from specified filePath existsstatic voidassertIsEmpty(File folder) Asserting folder/File is empty based on its sizestatic StringHelper for building strings of the resource passed as parameterstatic FilecheckFileInPath(String fileName, String path) Search recursively in pathstatic voidcheckObjectIsInitialized(Object model, String message) Check if the model object is null or not.static StringcmisDocTypeToExtentions(org.alfresco.dataprep.CMISUtil.DocumentType cmisDocumentType) static StringconvertBackslashToSlash(String value) static voiddeleteFolder(File folder) static ProcessexecuteCommandOnUnix(String command) Execute any Terminal commands Example: executeOnWin("ls -la")static StringexecuteOnUnix(String command) Execute any Terminal commands Example: executeOnWin("ls -la")static voidexecuteOnUnixNoWait(String command) static voidexecuteOnWin(String command) Example: executeOnWin("mkdir 'a'")static StringexecuteOnWinAndReturnOutput(String command) Method to retrieve a process output as Stringstatic Stringstatic FilegetFileWithSize(String fileName, int sizeMB) Create a newFilewith specific size (MB)static FilegetMountedApp(File fromLocation) static Stringstatic StringgetParentPath(String fullPath) If we have "/test/something/now" this method will return "/test/something"static PropertiesgetProperties(Class<?> classz, String propertieFileName) static StringgetResourceTestDataContent(String fileName) static FilegetResourceTestDataFile(String fileName) static StringgetSystemOrFileProperty(String key, Properties properties) static FilegetTestResourceFile(String filePath) Return a file from the filePath locationstatic StringGet text copied to System Clipboardstatic booleanisProcessRunning(String processName) Check if process identified byis currently running static booleanisPropertyEnabled(String key) Check if property identified by key in *.properties file is enabled or notstatic booleanisWinServiceRunning(String serviceName) static voidkillProcessExcludingMaven(String processName) Kill process excluding Mavenstatic voidkillProcessName(String processName) Kill a process using it's name.static StringprettyPrintJsonString(String unformattedJson) Pretty prints unformatted JSONstatic StringremoveLastSlash(String sourcePath) If the path ends with /, methods return the path without last /static FilesetNewFile(FileModel fileModel) Get newFilewith content based on file model.static voidsleep(int interval, int maxTime, RetryOperation callback) We will wait until the interval is passed from current run and retry until the maxTime is reachedstatic StringsplitGuidVersion(String guidWithVersion) static StringtoUrlParams(String url, Map<String, String> params) Generate URL query string from key value parametersstatic voidwaitToLoopTime(int seconds, String... info) We will wait until theare passed from current run static voidwaitUntilProcessFinishes(String processName, int timeout, int loopTime) Wait until process finish to runstatic booleanwaitUntilProcessIsRunning(String processName) Wait until process is running, or the retryCountSeconds is reached
-
Field Details
-
retryCountSeconds
public static int retryCountSeconds
-
-
Constructor Details
-
Utility
public Utility()
-
-
Method Details
-
checkObjectIsInitialized
public static void checkObjectIsInitialized(Object model, String message) throws TestObjectNotDefinedException Check if the model object is null or not.- Parameters:
model- The object to check.message- The message to return if there's an issue.- Throws:
TestObjectNotDefinedException- if the model object is null.
-
getTestResourceFile
Return a file from the filePath location- Parameters:
filePath-- Returns:
- file object
- Throws:
ExceptionTestConfigurationException
-
getResourceTestDataFile
- Throws:
TestConfigurationException
-
getResourceTestDataContent
- Parameters:
fileName-- Returns:
- the content of filename found in test/resources/testdata/
- Throws:
TestConfigurationException- If the file cannot be read.
-
convertBackslashToSlash
-
cmisDocTypeToExtentions
public static String cmisDocTypeToExtentions(org.alfresco.dataprep.CMISUtil.DocumentType cmisDocumentType) -
buildPath
Helper for building strings of the resource passed as parameter- Parameters:
parent-paths-- Returns:
- concatenated paths of
+ each
-
getParentPath
If we have "/test/something/now" this method will return "/test/something"- Parameters:
fullPath-
-
removeLastSlash
If the path ends with /, methods return the path without last /- Parameters:
sourcePath-- Returns:
- sourcePath without last slash
-
getProperties
public static Properties getProperties(Class<?> classz, String propertieFileName) throws TestConfigurationException - Throws:
TestConfigurationException
-
isPropertyEnabled
Check if property identified by key in *.properties file is enabled or not- Parameters:
key-- Returns:
-
waitToLoopTime
We will wait until theare passed from current run - Parameters:
seconds-
-
sleep
public static void sleep(int interval, int maxTime, RetryOperation callback) throws InterruptedException We will wait until the interval is passed from current run and retry until the maxTime is reached- Parameters:
interval-maxTime-callback-- Throws:
InterruptedException- if the thread was interrupted while sleeping.
-
prettyPrintJsonString
Pretty prints unformatted JSON- Parameters:
unformattedJson-- Returns:
-
toUrlParams
Generate URL query string from key value parameters- Parameters:
url-params-- Returns:
-
getEnvironmentPropertyFile
- Returns:
- the environment property file if nothing specified, default.properties is used if -Denvironment=local then local.properties is used.
-
splitGuidVersion
-
checkFileInPath
Search recursively in path- Parameters:
fileName-path-
-
getFileWithSize
Create a newFilewith specific size (MB)- Parameters:
fileName-sizeMB-- Returns:
File- Throws:
DataPreparationException- If there is an error preparing the file.
-
getSystemOrFileProperty
-
executeOnUnixNoWait
- Throws:
IOException
-
executeOnUnix
Execute any Terminal commands Example: executeOnWin("ls -la")- Parameters:
command-- Returns:
- output as string
-
executeCommandOnUnix
Execute any Terminal commands Example: executeOnWin("ls -la")- Parameters:
command-- Returns:
- process
-
executeOnWin
Example: executeOnWin("mkdir 'a'")- Parameters:
command-- Throws:
IOException
-
assertFileExists
Verify file from specified filePath exists- Parameters:
filePath- full path of the file- Returns:
- File new file object found
-
assertFileDoesNotExist
Verify file from specified filePath doesn't exist- Parameters:
filePath- full path of the file- Returns:
- File new file object
-
deleteFolder
- Throws:
IOException
-
killProcessName
Kill a process using it's name.- Parameters:
processName-- Throws:
IOException
-
killProcessExcludingMaven
Kill process excluding Maven- Parameters:
processName-- Throws:
IOException
-
setNewFile
Get newFilewith content based on file model. The new file will be deleted in the end. -
isProcessRunning
Check if process identified byis currently running - Parameters:
processName-- Returns:
-
getMountedApp
- Parameters:
fromLocation-- Returns:
Filemounted on- Throws:
TestConfigurationException
-
getTextFromClipboard
Get text copied to System Clipboard- Returns:
- Throws:
IOExceptionUnsupportedFlavorException
-
executeOnWinAndReturnOutput
Method to retrieve a process output as String- Parameters:
command-- Returns:
- process output in String format
-
assertIsEmpty
Asserting folder/File is empty based on its size- Parameters:
folder-
-
waitUntilProcessIsRunning
Wait until process is running, or the retryCountSeconds is reached- Parameters:
processName-
-
waitUntilProcessFinishes
Wait until process finish to run- Parameters:
processName-timeout-loopTime-
-
getOSName
- Returns:
- OS Name.
- Throws:
IOException
-
isWinServiceRunning
- Throws:
IOException
-