org.easetech.easytest.util
Class GeneralUtil

java.lang.Object
  extended by org.easetech.easytest.util.GeneralUtil

public class GeneralUtil
extends Object

This class contains common utils

Author:
gpcmol

Constructor Summary
GeneralUtil()
           
 
Method Summary
static Boolean convertToBoolean(Object object)
          Method to convert object to Boolean type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static Byte convertToByte(Object object)
          Method to convert object to Byte type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static Character convertToCharacter(Object object)
          Method to convert object to Character type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static Double convertToDouble(Object object)
          Method to convert object to Double type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static Enum convertToEnum(Class idClass, Object object)
          Method to convert object to Character type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static Float convertToFloat(Object object)
          Method to convert object to Float type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static Integer convertToInteger(Object object)
          Method to convert object to Integer type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static Long convertToLong(Object object)
          Method to convert object to Long type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static Short convertToShort(Object object)
          Method to convert object to Short type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static Date convertToSQLDate(Object object)
          Method to convert object to java.sql.Date type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static Time convertToSQLTime(Object object)
          Method to convert object to java.sql.Tim type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static Timestamp convertToSQLTimestamp(Object object)
          Method to convert object to java.sql.Timestamp type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static String convertToString(Object object)
          Method to convert object to String type It returns toString value of object.
static StringBuffer convertToStringBuffer(Object object)
          Method to convert object to String type It returns toString value of object.
static StringBuilder convertToStringBuilder(Object object)
          Method to convert object to String type It returns toString value of object.
static Object convertToTargetType(Class<?> idClass, Object object)
          Convert the given Class object to an object instance if possible
static Date convertToUtilDate(Object object)
          Method to convert object to java.util.Date type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.
static String createDefaultOutputFolder(String destinationFolder)
          Create directory
static String createFolder(String absoluteLocation)
          Creates directory.
static Boolean fillDataUsingConstructor(Class<?> idClass, List<Map<String,Object>> convertFrom, List<org.junit.experimental.theories.PotentialAssignment> finalData, String paramName, Collection collectionInstance)
           
static String getAbsoluteLocation(String location)
          Returns absulute path of either the classpath of file location
static Constructor getConstructor(Class<?> idClass)
           
static String getCurrentFolder()
           
static String getFormattedDate(Date date)
          Format date with pattern ddMMyyyyHHmmss
static Double getRounded(double valueToRound, int numberOfDecimalPlaces)
          Rounds a value with number of decimals
static
<T> void
handleJSONData(String expr, Class<T> idClass, List<org.junit.experimental.theories.PotentialAssignment> potentialAssignments)
           
static Boolean isJSON(String expression)
           
static boolean isStandardObjectInstance(Class<?> idClass)
           
static Boolean populateJSONData(Class<?> idClass, List<Map<String,Object>> convertFrom, List<org.junit.experimental.theories.PotentialAssignment> potentialAssignments, String paramName)
           
static Boolean populateParamData(Class<?> idClass, List<Map<String,Object>> convertFrom, List<org.junit.experimental.theories.PotentialAssignment> finalData, String paramName)
          Method responsible for calling a constructor on an object to try to fill it with data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralUtil

public GeneralUtil()
Method Detail

getRounded

public static Double getRounded(double valueToRound,
                                int numberOfDecimalPlaces)
Rounds a value with number of decimals

Parameters:
valueToRound -
numberOfDecimalPlaces -
Returns:
rounded double

createDefaultOutputFolder

public static String createDefaultOutputFolder(String destinationFolder)
Create directory

Parameters:
destinationFolder -
Returns:

getCurrentFolder

public static String getCurrentFolder()

createFolder

public static String createFolder(String absoluteLocation)
Creates directory. If absolute location is empty, pick current folder

Parameters:
absoluteLocation -
Returns:
directory

getFormattedDate

public static String getFormattedDate(Date date)
Format date with pattern ddMMyyyyHHmmss

Parameters:
date -
Returns:
string with formatted date

getAbsoluteLocation

public static String getAbsoluteLocation(String location)
Returns absulute path of either the classpath of file location

Parameters:
location -
Returns:
absolute location

convertToSQLTimestamp

public static Timestamp convertToSQLTimestamp(Object object)
Method to convert object to java.sql.Timestamp type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
java.sql.Timestamp converted value.

convertToUtilDate

public static Date convertToUtilDate(Object object)
Method to convert object to java.util.Date type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
java.util.Date converted value.

convertToSQLDate

public static Date convertToSQLDate(Object object)
Method to convert object to java.sql.Date type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
java.sql.Date converted value.

convertToSQLTime

public static Time convertToSQLTime(Object object)
Method to convert object to java.sql.Tim type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
java.sql.Tim converted value.

convertToInteger

public static Integer convertToInteger(Object object)
Method to convert object to Integer type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
Integer converted value.

convertToShort

public static Short convertToShort(Object object)
Method to convert object to Short type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
Short converted value.

convertToLong

public static Long convertToLong(Object object)
Method to convert object to Long type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
Long converted value.

convertToDouble

public static Double convertToDouble(Object object)
Method to convert object to Double type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
Double converted value.

convertToFloat

public static Float convertToFloat(Object object)
Method to convert object to Float type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
Float converted value.

convertToBoolean

public static Boolean convertToBoolean(Object object)
Method to convert object to Boolean type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
Boolean converted value.

convertToByte

public static Byte convertToByte(Object object)
Method to convert object to Byte type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
Byte converted value.

convertToCharacter

public static Character convertToCharacter(Object object)
Method to convert object to Character type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
Character converted value.

convertToString

public static String convertToString(Object object)
Method to convert object to String type It returns toString value of object.

Parameters:
Object - object
Returns:
Character converted value.

convertToStringBuffer

public static StringBuffer convertToStringBuffer(Object object)
Method to convert object to String type It returns toString value of object.

Parameters:
Object - object
Returns:
Character converted value.

convertToStringBuilder

public static StringBuilder convertToStringBuilder(Object object)
Method to convert object to String type It returns toString value of object.

Parameters:
Object - object
Returns:
Character converted value.

convertToEnum

public static Enum convertToEnum(Class idClass,
                                 Object object)
Method to convert object to Character type It checks the instance of the object is of different datatype then it gets the value from the object and casts it to required data type.

Parameters:
Object - object
Returns:
Character converted value.

convertToTargetType

public static Object convertToTargetType(Class<?> idClass,
                                         Object object)
Convert the given Class object to an object instance if possible

Parameters:
idClass -
object -
Returns:

isStandardObjectInstance

public static boolean isStandardObjectInstance(Class<?> idClass)

populateJSONData

public static Boolean populateJSONData(Class<?> idClass,
                                       List<Map<String,Object>> convertFrom,
                                       List<org.junit.experimental.theories.PotentialAssignment> potentialAssignments,
                                       String paramName)

handleJSONData

public static <T> void handleJSONData(String expr,
                                      Class<T> idClass,
                                      List<org.junit.experimental.theories.PotentialAssignment> potentialAssignments)

isJSON

public static Boolean isJSON(String expression)

populateParamData

public static Boolean populateParamData(Class<?> idClass,
                                        List<Map<String,Object>> convertFrom,
                                        List<org.junit.experimental.theories.PotentialAssignment> finalData,
                                        String paramName)
                                 throws IllegalArgumentException,
                                        InstantiationException,
                                        IllegalAccessException,
                                        InvocationTargetException
Method responsible for calling a constructor on an object to try to fill it with data.

Parameters:
idClass -
convertFrom -
finalData -
paramName -
Returns:
Boolean in case the data is successfuly filled else false
Throws:
IllegalArgumentException
InstantiationException
IllegalAccessException
InvocationTargetException

fillDataUsingConstructor

public static Boolean fillDataUsingConstructor(Class<?> idClass,
                                               List<Map<String,Object>> convertFrom,
                                               List<org.junit.experimental.theories.PotentialAssignment> finalData,
                                               String paramName,
                                               Collection collectionInstance)
                                        throws IllegalArgumentException,
                                               InstantiationException,
                                               IllegalAccessException,
                                               InvocationTargetException
Throws:
IllegalArgumentException
InstantiationException
IllegalAccessException
InvocationTargetException

getConstructor

public static Constructor getConstructor(Class<?> idClass)


Copyright © 2013. All Rights Reserved.