Class FileParserGSpec


  • public class FileParserGSpec
    extends BaseGSpec
    Steps definitions for handling and parsing text files. This class makes use of Utah-parser, a Java library for parsing semi-structured text files
    Author:
    Jose Fernandez
    See Also:
    https://github.com/sonalake/utah-parser
    • Constructor Detail

      • FileParserGSpec

        public FileParserGSpec​(CommonG spec)
    • Method Detail

      • iParseTheFileLocatedAtUsingTheTemplateDefinedIn

        @Given("^I parse the file located at \'(.+?)\' using the template defined in \'(.+?)\'$")
        public void iParseTheFileLocatedAtUsingTheTemplateDefinedIn​(String fileToParse,
                                                                    String XMLDefinitionFile)
                                                             throws IOException,
                                                                    JAXBException,
                                                                    URISyntaxException
        Parse the given file according to the rules described in the XML configuration file The operation returns a list of 'records' (List(Map(String, String))) that is stored internally for further operations
        Parameters:
        fileToParse - Location of the file to parse
        XMLDefinitionFile - Location of the XML configuration file
        Throws:
        IOException - IOException
        JAXBException - JAXBException
        URISyntaxException - URISyntaxException
      • theFileContainsRecords

        @Then("^the result contains( at least)? \'(\\d+)\' records$")
        public void theFileContainsRecords​(String atLeast,
                                           int quantity)
        Verifies that the stored result from the last operation contains the specified amount of records, or if the amount of records is greater that or equal than the expected
        Parameters:
        atLeast - Verifies a greater than or equal condition
        quantity - Expected quantity
      • theTotalOfTheColumnColumnaNameIs

        @And("^the total of the column \'(.+?)\' is \'(.+?)\'$")
        public void theTotalOfTheColumnColumnaNameIs​(String columnName,
                                                     float expectedTotal)
                                              throws ParseException
        Calculates the sum of the given column. The column must contain numeric values
        Parameters:
        columnName - Column name
        expectedTotal - Expected total
        Throws:
        ParseException - Exception if the column does not contain numeric values
      • thereAreRecordsWithColumnEqualTo

        @And("^there are \'(\\d+)\' records with column \'(.+?)\' equal to \'(.+?)\'$")
        public void thereAreRecordsWithColumnEqualTo​(int quantity,
                                                     String columnName,
                                                     String expectedValue)
        Calculates the ammount of records in the last operation where the column matches the expected value
        Parameters:
        quantity - Expected amount of columns to find that match the condition
        columnName - Column name to consider
        expectedValue - Expected value for the command
      • theRecordAtPositionAtColumnColumnHasTheValueValue

        @And("^the record at position \'(\\d+)\' at column \'(.+?)\' has the value \'(.+?)\'$")
        public void theRecordAtPositionAtColumnColumnHasTheValueValue​(int position,
                                                                      String columnName,
                                                                      String valueExpected)
        Verifies that for the record located at the given position, the column contains the expected value
        Parameters:
        position - position
        columnName - columnName
        valueExpected - valueExpected
      • iGetTheFirstRecordWithColumnXEqualToY

        @And("^I get the first record with column \'(.+?)\' equal to \'(.+?)\'$")
        public void iGetTheFirstRecordWithColumnXEqualToY​(String columnName,
                                                          String value)
        Returns the first records in the set in which the column has the given value
        Parameters:
        columnName - Column name to consider
        value - Expected value
      • iGetTheRecordAtPosition

        @Then("^I get the record at position \'(\\d+)\'$")
        public void iGetTheRecordAtPosition​(int rowNUmber)
                                     throws Throwable
        Returns the record at the specified position in the set
        Parameters:
        rowNUmber - Index (starting by 0)
        Throws:
        Throwable - Throwable
      • theSelectedRecordMatchesTheFollowingCases

        @And("^the selected record matches the following cases:$")
        public void theSelectedRecordMatchesTheFollowingCases​(io.cucumber.datatable.DataTable dataTable)
        Verifies if the selected record matches the given cases by the datatable
        Parameters:
        dataTable - DataTable containing the set of columns to be verified against the condition. Syntax will be: | <column name> | <condition> | <expected value> where: header name: header name condition: Condition that is going to be evaluated (available: equal, not equal, contains, does not contain, length) expected value: Value used to verify the condition for example: If we want to verify that the column "uptime" is equal to "10:37:12" we would do | uptime | equal | 10:37:12 |
      • iSelectAllRecordsThatMatchTheFollowingCases

        @And("^I select all records that match the following cases:$")
        public void iSelectAllRecordsThatMatchTheFollowingCases​(io.cucumber.datatable.DataTable dataTable)
        From the previous operation, filter all the records from the set that match the conditions given in the datatable. The resulting set will be stored internally and will be avilable to perform further filter operations
        Parameters:
        dataTable - DataTable containing the set of columns to be verified against the condition. Syntax will be: | <column name> | <condition> | <expected value> where: header name: header name condition: Condition that is going to be evaluated (available: equal, not equal, contains, does not contain, length) expected value: Value used to verify the condition for example: If we want to filter all the records in the set where 'status' does not contains '0' | status | does not contain | 0 |