Skip to content

Commit

Permalink
Merge pull request #12 from dominikpanzer/1.1.2
Browse files Browse the repository at this point in the history
1.1.2
  • Loading branch information
dominikpanzer authored May 30, 2023
2 parents 955ebb3 + e566938 commit de2e853
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 23 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 24 additions & 2 deletions src/zcl_cacamber.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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 ).
Expand All @@ -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|.
Expand Down Expand Up @@ -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.
57 changes: 43 additions & 14 deletions src/zcl_datatable.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,32 @@ 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.
ENDCLASS.



CLASS ZCL_DATATABLE IMPLEMENTATION.
CLASS zcl_datatable IMPLEMENTATION.


METHOD from_string.
Expand Down Expand Up @@ -99,11 +105,34 @@ CLASS ZCL_DATATABLE IMPLEMENTATION.
ENDIF.
ASSIGN COMPONENT datatable_line->column OF STRUCTURE <line> TO <cell>.
CHECK <cell> IS ASSIGNED.
<cell> = 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 = <cell> ).
ELSEIF is_time_format( datatable_line->value ).
<cell> = format_time( datatable_line->value ).
ELSE.
<cell> = datatable_line->value.
ENDIF.
UNASSIGN <cell>.
ENDLOOP.
APPEND <line> TO <table>.

table = <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.
8 changes: 4 additions & 4 deletions src/zcl_datatable.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -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 ).
Expand Down
2 changes: 1 addition & 1 deletion src/zif_cacamber_version.intf.abap
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions src/zst_bdd_demo.tabl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
<SHLPORIGIN>T</SHLPORIGIN>
<COMPTYPE>E</COMPTYPE>
</DD03P>
<DD03P>
<FIELDNAME>BIRTHTIME</FIELDNAME>
<ADMINFIELD>0</ADMINFIELD>
<INTTYPE>T</INTTYPE>
<INTLEN>000012</INTLEN>
<DATATYPE>TIMS</DATATYPE>
<LENG>000006</LENG>
<MASK> TIMS</MASK>
<SHLPORIGIN>T</SHLPORIGIN>
</DD03P>
<DD03P>
<FIELDNAME>FIRST_NAME</FIELDNAME>
<ROLLNAME>CHAR30</ROLLNAME>
Expand Down

0 comments on commit de2e853

Please sign in to comment.