diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a42cb7..18ed2d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.2] - 2023-05-30 + +### Added + +- none + +### Fixed + +- data table now parses dates (dd.mm.yyyy) correctly +- data table now parses time (hh:mm:ss) correctly + +### Changed + +- none + +### Removed + +- none + ## [1.1.1] - 2023-05-30 ### Added diff --git a/README.md b/README.md index e5f3088..f48ad4a 100644 --- a/README.md +++ b/README.md @@ -573,8 +573,7 @@ I like to create a simple [acceptance test list](https://agiledojo.de/2018-12-16 :white_check_mark: introduce versioning :white_check_mark: :boom: FIRST PUBLIC RELEASE :boom: Twitter + Blog :white_check_mark: enable some kind of i18n to support german Gherkin keywords -:black_square_button: write blog about ADRs -:black_square_button: [fix the unit tests runner](https://github.com/open-abap/open-abap-core/issues/674) +:white_check_mark: fix the unit tests runner - thanks Lars :black_square_button: get rid of ddic objects :black_square_button: maybe text file parsing is a good idea? maybe not? :black_square_button: your awesome idea diff --git a/src/zcl_cacamber.clas.abap b/src/zcl_cacamber.clas.abap index c7729f4..17d47bc 100644 --- a/src/zcl_cacamber.clas.abap +++ b/src/zcl_cacamber.clas.abap @@ -101,7 +101,11 @@ CLASS zcl_cacamber DEFINITION RETURNING VALUE(strings) TYPE string_table. ENDCLASS. -CLASS zcl_cacamber IMPLEMENTATION. + + +CLASS ZCL_CACAMBER IMPLEMENTATION. + + METHOD configure. CHECK pattern IS NOT INITIAL. CHECK method_name IS NOT INITIAL. @@ -135,6 +139,7 @@ CLASS zcl_cacamber IMPLEMENTATION. ENDLOOP. ENDMETHOD. + METHOD get_method_parameters. DATA: class_description TYPE REF TO cl_abap_classdescr. DATA: object_description TYPE REF TO cl_abap_objectdescr. @@ -155,10 +160,12 @@ CLASS zcl_cacamber IMPLEMENTATION. ENDLOOP. ENDMETHOD. + METHOD get_method_by_method_name. READ TABLE class_description->methods REFERENCE INTO method_description WITH KEY name = method_name. ENDMETHOD. + METHOD add_variables_to_parameters. CONSTANTS exporting TYPE string VALUE 'E' ##NO_TEXT. DATA: parameter_value TYPE REF TO data. @@ -181,24 +188,29 @@ CLASS zcl_cacamber IMPLEMENTATION. ENDLOOP. ENDMETHOD. + METHOD conversion_exit_inbound. variable_internal = |{ variable ALPHA = IN }|. ENDMETHOD. + METHOD format_time. time = translate( val = variable from = `:` to = `` ). ENDMETHOD. + METHOD is_time_format. CONSTANTS time_format_hhmmss_with_colon TYPE string VALUE '^(2[0-3]|[01]?[0-9]):([0-5]?[0-9]):([0-5]?[0-9])$'. result = xsdbool( matches( val = variable regex = time_format_hhmmss_with_colon ) ). ENDMETHOD. + METHOD is_gregorian_dot_seperated. CONSTANTS ddmmyyyy_dot_seperated TYPE string VALUE '^(0[0-9]|[12][0-9]|3[01])[- \..](0[0-9]|1[012])[- \..]\d\d\d\d$'. result = xsdbool( matches( val = variable regex = ddmmyyyy_dot_seperated ) ). ENDMETHOD. + METHOD given. DATA(method_name) = match_step_to_method_name( step ). DATA(variables) = extract_variables_from_step( step ). @@ -213,34 +225,42 @@ CLASS zcl_cacamber IMPLEMENTATION. CALL METHOD me->test_class_instance->(method_name) PARAMETER-TABLE matched_parameters. ENDMETHOD. + METHOD when. given( step ). ENDMETHOD. + METHOD and. given( step ). ENDMETHOD. + METHOD or. given( step ). ENDMETHOD. + METHOD then. given( step ). ENDMETHOD. + METHOD example. scenario( example ). ENDMETHOD. + METHOD but. given( step ). ENDMETHOD. + METHOD _. given( step ). ENDMETHOD. + METHOD constructor. DATA(english_scenario) = |Scenario|. DATA(english_rule) = |Rule|. @@ -342,16 +362,18 @@ CLASS zcl_cacamber IMPLEMENTATION. ENDLOOP. ENDMETHOD. + METHOD get_current_feature. current_feature = me->current_feature. ENDMETHOD. + METHOD get_current_rule. current_rule = me->current_rule. ENDMETHOD. + METHOD get_current_scenario. current_scenario = me->current_scenario. ENDMETHOD. - ENDCLASS. diff --git a/src/zcl_datatable.clas.abap b/src/zcl_datatable.clas.abap index 65d66d3..3a68bee 100644 --- a/src/zcl_datatable.clas.abap +++ b/src/zcl_datatable.clas.abap @@ -9,18 +9,24 @@ CLASS zcl_datatable DEFINITION value TYPE string, END OF datatable_line_ts. TYPES: datatable_tt TYPE SORTED TABLE OF datatable_line_ts WITH UNIQUE KEY row column. - CLASS-METHODS: from_string IMPORTING table_as_string TYPE string - RETURNING VALUE(datatable) TYPE REF TO zcl_datatable - RAISING zcx_cacamber_error. - METHODS: read_row IMPORTING rownumber TYPE int4 - RETURNING VALUE(line) TYPE string_table - RAISING zcx_cacamber_error ##NEEDED. - METHODS: read_cell IMPORTING rownumber TYPE int4 - columnnumber TYPE int4 - RETURNING VALUE(value) TYPE string - RAISING zcx_cacamber_error. - METHODS: to_table IMPORTING ddic_table_type_name TYPE tabname - EXPORTING VALUE(table) TYPE any. + CLASS-METHODS from_string IMPORTING table_as_string TYPE string + RETURNING VALUE(datatable) TYPE REF TO zcl_datatable + RAISING zcx_cacamber_error. + METHODS read_row IMPORTING rownumber TYPE int4 + RETURNING VALUE(line) TYPE string_table + RAISING zcx_cacamber_error ##NEEDED. + METHODS read_cell IMPORTING rownumber TYPE int4 + columnnumber TYPE int4 + RETURNING VALUE(value) TYPE string + RAISING zcx_cacamber_error. + METHODS to_table IMPORTING ddic_table_type_name TYPE tabname + EXPORTING VALUE(table) TYPE any. + METHODS is_gregorian_dot_seperated IMPORTING variable TYPE string + RETURNING VALUE(result) TYPE abap_bool. + METHODS is_time_format IMPORTING variable TYPE string + RETURNING VALUE(result) TYPE abap_bool. + METHODS format_time IMPORTING variable TYPE string + RETURNING VALUE(time) TYPE string. PRIVATE SECTION. DATA datatable TYPE datatable_tt. METHODS parse IMPORTING table_as_string TYPE string. @@ -28,7 +34,7 @@ ENDCLASS. -CLASS ZCL_DATATABLE IMPLEMENTATION. +CLASS zcl_datatable IMPLEMENTATION. METHOD from_string. @@ -99,11 +105,34 @@ CLASS ZCL_DATATABLE IMPLEMENTATION. ENDIF. ASSIGN COMPONENT datatable_line->column OF STRUCTURE TO . CHECK IS ASSIGNED. - = datatable_line->value. + + IF is_gregorian_dot_seperated( datatable_line->value ). + cl_abap_datfm=>conv_date_ext_to_int( EXPORTING im_datext = datatable_line->value + im_datfmdes = '1' + IMPORTING ex_datint = ). + ELSEIF is_time_format( datatable_line->value ). + = format_time( datatable_line->value ). + ELSE. + = datatable_line->value. + ENDIF. UNASSIGN . ENDLOOP. APPEND TO . table =
. ENDMETHOD. + + METHOD is_gregorian_dot_seperated. + CONSTANTS ddmmyyyy_dot_seperated TYPE string VALUE '^(0[0-9]|[12][0-9]|3[01])[- \..](0[0-9]|1[012])[- \..]\d\d\d\d$'. + result = xsdbool( matches( val = variable regex = ddmmyyyy_dot_seperated ) ). + ENDMETHOD. + + METHOD is_time_format. + CONSTANTS time_format_hhmmss_with_colon TYPE string VALUE '^(2[0-3]|[01]?[0-9]):([0-5]?[0-9]):([0-5]?[0-9])$'. + result = xsdbool( matches( val = variable regex = time_format_hhmmss_with_colon ) ). + ENDMETHOD. + + METHOD format_time. + time = translate( val = variable from = `:` to = `` ). + ENDMETHOD. ENDCLASS. diff --git a/src/zcl_datatable.clas.testclasses.abap b/src/zcl_datatable.clas.testclasses.abap index 8bbb3f5..f1d3406 100644 --- a/src/zcl_datatable.clas.testclasses.abap +++ b/src/zcl_datatable.clas.testclasses.abap @@ -123,11 +123,11 @@ CLASS acceptance_tests IMPLEMENTATION. METHOD transforms_to_internal_table. DATA internal_table TYPE ztt_bdd_demo. - DATA(internal_table_expected) = VALUE ztt_bdd_demo( ( birthdate = '17.07.1952' first_name = 'David' last_name = 'Hasselhoff' age = 0 ) - ( birthdate = '30.07.1947' first_name = 'Arnold' last_name = 'Schwarzenegger' age = 100 ) ). + DATA(internal_table_expected) = VALUE ztt_bdd_demo( ( birthdate = '19520717' birthtime = '111111' first_name = 'David' last_name = 'Hasselhoff' age = 0 ) + ( birthdate = '19470730' birthtime = '235959' first_name = 'Arnold' last_name = 'Schwarzenegger' age = 100 ) ). - DATA(datatable) = zcl_datatable=>from_string( '| 17.07.1952 | David | Hasselhoff | |' && - '| 30.07.1947 | Arnold | Schwarzenegger | 100 |' ). + DATA(datatable) = zcl_datatable=>from_string( '| 17.07.1952 | 11:11:11 | David | Hasselhoff | |' && + '| 30.07.1947 | 23:59:59 | Arnold | Schwarzenegger | 100 |' ). datatable->to_table( EXPORTING ddic_table_type_name = 'ZTT_BDD_DEMO' IMPORTING table = internal_table ). diff --git a/src/zif_cacamber_version.intf.abap b/src/zif_cacamber_version.intf.abap index 20196de..deb089a 100644 --- a/src/zif_cacamber_version.intf.abap +++ b/src/zif_cacamber_version.intf.abap @@ -1,4 +1,4 @@ INTERFACE zif_cacamber_version PUBLIC. - CONSTANTS version TYPE string VALUE '1.1.1' ##NO_TEXT. + CONSTANTS version TYPE string VALUE '1.1.2' ##NO_TEXT. ENDINTERFACE. diff --git a/src/zst_bdd_demo.tabl.xml b/src/zst_bdd_demo.tabl.xml index d84e17a..539d62e 100644 --- a/src/zst_bdd_demo.tabl.xml +++ b/src/zst_bdd_demo.tabl.xml @@ -18,6 +18,16 @@ TE + + BIRTHTIME + 0 + T + 000012 + TIMS + 000006 + TIMS + T + FIRST_NAME CHAR30