Package core.apiCore.helpers
Class CsvReader
java.lang.Object
core.apiCore.helpers.CsvReader
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddActionCsvTests(List<Object[]> csvList) update csv test list with tests from action csv files eg.static voiddetectDuplicateTests(List<Object[]> testCaseList) print out warning for duplicated test namesstatic voidevaluateOption(ServiceObject serviceObject) set run count for individual test casestatic voidgets all keywords And stores them in apiMap in testObjectstatic voidgetAllTestCases(String testPath, String prefix) gets all test cases from testcase path based on prefixstatic intgetColumnIndexByName(String column, String[] row) gets column name by the column namestatic intstatic StringgetCsvFileFromIndex(int index) returns current csv test filestatic intgetCsvFileIndex(String fileName) returns the index of the file from the list of csv filesstatic intgetCsvFileIndex(String csvDir, String fileName) returns the index of the file from the list of csv filesgetCsvFileList(String csvTestPath) returns a list of all csv test filesstatic intget the number of tests in csv filegetCsvTestList(File file) reads csv file and returns the list of rows include and exclude tests eg.getCsvTestListForTestRunner(String csvFile) gets csv tests list for service testsgetCsvTestListForTestRunner(String csvDir, String csvInfo) gets csv tests list for service tests include and exclude tests eg.static intgets csv file index does not increment When retrystatic intgetFileIndex(ArrayList<File> testCsvFileList, String csvFile) getMatchingTestId(String[] testIds, List<Object[]> testRows) matches testIds with csv data rows TestIdstatic String[]getTestCaseIds(String testFileInfo) gets a list of test case ids from testFile:testcaseId info Used for actions and test base testcase ids separated by "," format: testFile:testcaseId1,testcaseId2gets the tests from csv file based on the current test file indexreturns a list of all csv test filesstatic StringgetTestname(String fullTestname) get test name without test step identifiergetTestStepMap(List<Object[]> csvList) get map of test cases with test steps removes test step prefix from test case idstatic booleanstatic booleanisValidTestFileType(String filename) returns if file is valid service test typestatic Map<String, ServiceObject> mapToApiObject(List<Object[]> testCases) maps list of test cases to service object mapstatic ServiceObjectmapToServiceObject(Object[] testData) test data array to service objectstatic com.opencsv.CSVReaderreadCsvFile(File file) static intsets the index of the file specified in include and exclude testssetTestRerun(List<Object[]> testCaseList) set test cases based on run countupdate test cases base on test steps (combining test steps with _step#number postfix.updateCsvFileFromFile(List<Object[]> csvList, String csvFileName, Map<String, List<Object[]>> testStepMap) update csv test list with additional meta data (csv file name, test index, service type, test count) if test case is set then single test is returned
-
Field Details
-
SERVICE_CSV_COLUMN_COUNT
public static int SERVICE_CSV_COLUMN_COUNT -
SERVICE_CSV_VISIBLE_COLUMN_COUNT
public static int SERVICE_CSV_VISIBLE_COLUMN_COUNT -
SERVICE_CSV_FILE_PREFIX
-
ACTION_KEY
- See Also:
-
SERVICE_CSV_SEPARATOR
- See Also:
-
SERVICE_CSV_DATAPROVIDER_COUNT
- See Also:
-
SERVICE_CSV_INCLUDE_SUB_DIR
- See Also:
-
SERVICE_INCLUDE_LIST
- See Also:
-
SERVICE_EXCLUDE_LIST
- See Also:
-
OPTION_RUN_COUNT
- See Also:
-
SERVICE_RUN_COUNT
- See Also:
-
SERVICE_RUN_CURRENT_COUNT
- See Also:
-
SERVICE_RUN_PREFIX
- See Also:
-
SERVICE_STEP_PREFIX
- See Also:
-
-
Constructor Details
-
CsvReader
public CsvReader()
-
-
Method Details
-
getTestCasesFromCsvFile
gets the tests from csv file based on the current test file index- Returns:
-
setTestRangeIndex
public static int setTestRangeIndex()sets the index of the file specified in include and exclude tests- Parameters:
index-- Returns:
-
filterTests
-
detectDuplicateTests
print out warning for duplicated test names- Parameters:
testCaseList-
-
setTestSteps
public static List<Object[]> setTestSteps(List<Object[]> csvList, Map<String, List<Object[]>> testStepMap) update test cases base on test steps (combining test steps with _step#number postfix. eg. verifyUser_step1, verifyUser_step2- Parameters:
testCaseList-- Returns:
-
getTestname
get test name without test step identifier- Parameters:
csvRow-- Returns:
-
getTestStepMap
get map of test cases with test steps removes test step prefix from test case id- Parameters:
csvList-- Returns:
-
setTestRerun
set test cases based on run count- Parameters:
testCaseList-- Returns:
-
updateCsvFileFromFile
public static List<Object[]> updateCsvFileFromFile(List<Object[]> csvList, String csvFileName, Map<String, List<Object[]>> testStepMap) update csv test list with additional meta data (csv file name, test index, service type, test count) if test case is set then single test is returned- Parameters:
csvList-csvFileName-testCaseFile-- Returns:
-
addActionCsvTests
update csv test list with tests from action csv files eg. action:createUser.csv:createUser, updateUser or action:createUser.csv- Parameters:
testData-- Returns:
-
getTestCaseIds
gets a list of test case ids from testFile:testcaseId info Used for actions and test base testcase ids separated by "," format: testFile:testcaseId1,testcaseId2- Parameters:
testFileInfo-- Returns:
-
getMatchingTestId
matches testIds with csv data rows TestId- Parameters:
testIds-testRows-- Returns:
-
mapToApiObject
maps list of test cases to service object map- Parameters:
testCases-- Returns:
-
mapToServiceObject
test data array to service object- Parameters:
testData-- Returns:
-
getAllTestCases
gets all test cases from testcase path based on prefix -
getAllKeywords
public static void getAllKeywords()gets all keywords And stores them in apiMap in testObject -
getCurrentTestInvocation
public static int getCurrentTestInvocation()gets csv file index does not increment When retry- Returns:
-
isRunningServiceTest
public static boolean isRunningServiceTest() -
getCsvFileFromIndex
returns current csv test file- Returns:
-
getCsvFileCount
public static int getCsvFileCount() -
getTestDataCsvFileList
returns a list of all csv test files- Returns:
-
getCsvFileList
returns a list of all csv test files- Parameters:
csvTestPath- : full path to csv directory- Returns:
-
getCsvFileIndex
returns the index of the file from the list of csv files- Parameters:
fileName-- Returns:
-
getCsvFileIndex
returns the index of the file from the list of csv files- Parameters:
fileName-- Returns:
-
getCsvTestListForTestRunner
gets csv tests list for service tests- Parameters:
csvFile-- Returns:
-
getCsvTestListForTestRunner
gets csv tests list for service tests include and exclude tests eg. include: TestCases_UserValidation.csv:createUser-createUserNoToken, createUserInvalidToken; eg. exclude: TestCases_UserValidation.csv:createUser-createUserNoToken, createUserInvalidToken;- Parameters:
csvInfo-- Returns:
-
getCsvTestList
reads csv file and returns the list of rows include and exclude tests eg. include: TestCases_UserValidation.csv:createUser-createUserNoToken, createUserInvalidToken; eg. exclude: TestCases_UserValidation.csv:createUser-createUserNoToken, createUserInvalidToken;- Parameters:
file-- Returns:
-
readCsvFile
-
getFileIndex
-
getColumnIndexByName
gets column name by the column name- Parameters:
column- : column namerow- : header row- Returns:
-
getCsvTestcount
public static int getCsvTestcount()get the number of tests in csv file- Returns:
-
isValidTestFileType
returns if file is valid service test type- Parameters:
filename-- Returns:
-
evaluateOption
set run count for individual test case- Parameters:
serviceObject-
-