Class CsvReader

java.lang.Object
core.apiCore.helpers.CsvReader

public class CsvReader
extends Object
  • Field Details

  • Constructor Details

    • CsvReader

      public CsvReader()
  • Method Details

    • getTestCasesFromCsvFile

      public static List<Object> 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

      public static ArrayList<File> filterTests()
    • detectDuplicateTests

      public static void detectDuplicateTests​(List<Object[]> testCaseList)
      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

      public static String getTestname​(String fullTestname)
      get test name without test step identifier
      Parameters:
      csvRow -
      Returns:
    • getTestStepMap

      public static Map<String,​List<Object[]>> getTestStepMap​(List<Object[]> csvList)
      get map of test cases with test steps removes test step prefix from test case id
      Parameters:
      csvList -
      Returns:
    • setTestRerun

      public static List<Object[]> setTestRerun​(List<Object[]> testCaseList)
      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

      public static List<Object[]> addActionCsvTests​(List<Object[]> csvList)
      update csv test list with tests from action csv files eg. action:createUser.csv:createUser, updateUser or action:createUser.csv
      Parameters:
      testData -
      Returns:
    • getTestCaseIds

      public static 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,testcaseId2
      Parameters:
      testFileInfo -
      Returns:
    • getMatchingTestId

      public static List<Object[]> getMatchingTestId​(String[] testIds, List<Object[]> testRows)
      matches testIds with csv data rows TestId
      Parameters:
      testIds -
      testRows -
      Returns:
    • mapToApiObject

      public static Map<String,​ServiceObject> mapToApiObject​(List<Object[]> testCases)
      maps list of test cases to service object map
      Parameters:
      testCases -
      Returns:
    • mapToServiceObject

      public static ServiceObject mapToServiceObject​(Object[] testData)
      test data array to service object
      Parameters:
      testData -
      Returns:
    • getAllTestCases

      public static void getAllTestCases​(String testPath, String prefix)
      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

      public static String getCsvFileFromIndex​(int index)
      returns current csv test file
      Returns:
    • getCsvFileCount

      public static int getCsvFileCount()
    • getTestDataCsvFileList

      public static ArrayList<File> getTestDataCsvFileList()
      returns a list of all csv test files
      Returns:
    • getCsvFileList

      public static ArrayList<File> getCsvFileList​(String csvTestPath)
      returns a list of all csv test files
      Parameters:
      csvTestPath - : full path to csv directory
      Returns:
    • getCsvFileIndex

      public static int getCsvFileIndex​(String fileName)
      returns the index of the file from the list of csv files
      Parameters:
      fileName -
      Returns:
    • getCsvFileIndex

      public static int getCsvFileIndex​(String csvDir, String fileName)
      returns the index of the file from the list of csv files
      Parameters:
      fileName -
      Returns:
    • getCsvTestListForTestRunner

      public static List<Object[]> getCsvTestListForTestRunner​(String csvFile)
      gets csv tests list for service tests
      Parameters:
      csvFile -
      Returns:
    • getCsvTestListForTestRunner

      public static List<Object[]> getCsvTestListForTestRunner​(String csvDir, String csvInfo)
      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

      public static List<Object[]> getCsvTestList​(File file)
      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

      public static com.opencsv.CSVReader readCsvFile​(File file)
    • getFileIndex

      public static int getFileIndex​(ArrayList<File> testCsvFileList, String csvFile)
    • getColumnIndexByName

      public static int getColumnIndexByName​(String column, String[] row)
      gets column name by the column name
      Parameters:
      column - : column name
      row - : header row
      Returns:
    • getCsvTestcount

      public static int getCsvTestcount()
      get the number of tests in csv file
      Returns:
    • isValidTestFileType

      public static boolean isValidTestFileType​(String filename)
      returns if file is valid service test type
      Parameters:
      filename -
      Returns:
    • evaluateOption

      public static void evaluateOption​(ServiceObject serviceObject)
      set run count for individual test case
      Parameters:
      serviceObject -