mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
remove DEFINE from zcl_abapgit_news (#3194)
* remove DEFINE from zcl_abapgit_news * linter fix Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
parent
ab0d1a3fa6
commit
1be907bd73
|
@ -53,6 +53,55 @@ CLASS ltcl_relevant IMPLEMENTATION.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
* Helper classed
|
||||||
|
|
||||||
|
CLASS lcl_string_buffer DEFINITION FINAL.
|
||||||
|
PUBLIC SECTION.
|
||||||
|
DATA mt_buffer TYPE string_table.
|
||||||
|
METHODS add
|
||||||
|
IMPORTING
|
||||||
|
iv_str TYPE string.
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
CLASS lcl_string_buffer IMPLEMENTATION.
|
||||||
|
METHOD add.
|
||||||
|
APPEND iv_str TO mt_buffer.
|
||||||
|
ENDMETHOD.
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
CLASS lcl_log_entries DEFINITION FINAL.
|
||||||
|
PUBLIC SECTION.
|
||||||
|
DATA mt_log_entries TYPE zcl_abapgit_news=>tt_log.
|
||||||
|
METHODS add
|
||||||
|
IMPORTING
|
||||||
|
iv_str TYPE string.
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
CLASS lcl_log_entries IMPLEMENTATION.
|
||||||
|
METHOD add.
|
||||||
|
DATA ls_log LIKE LINE OF mt_log_entries.
|
||||||
|
DATA lv_pos_to_cur_str TYPE string.
|
||||||
|
|
||||||
|
SPLIT iv_str AT '/' INTO
|
||||||
|
ls_log-version
|
||||||
|
ls_log-is_header
|
||||||
|
ls_log-is_important
|
||||||
|
lv_pos_to_cur_str
|
||||||
|
ls_log-text.
|
||||||
|
|
||||||
|
CONDENSE ls_log-version.
|
||||||
|
CONDENSE ls_log-is_header.
|
||||||
|
CONDENSE ls_log-is_important.
|
||||||
|
CONDENSE ls_log-text.
|
||||||
|
ls_log-pos_to_cur = lv_pos_to_cur_str.
|
||||||
|
|
||||||
|
APPEND ls_log TO mt_log_entries.
|
||||||
|
ENDMETHOD.
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
**********************************************************************
|
||||||
|
|
||||||
CLASS ltcl_news DEFINITION DEFERRED.
|
CLASS ltcl_news DEFINITION DEFERRED.
|
||||||
CLASS zcl_abapgit_news DEFINITION LOCAL FRIENDS ltcl_news.
|
CLASS zcl_abapgit_news DEFINITION LOCAL FRIENDS ltcl_news.
|
||||||
|
|
||||||
|
@ -204,83 +253,77 @@ CLASS ltcl_news IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD parse.
|
METHOD parse.
|
||||||
|
|
||||||
DEFINE _add_news_log_entry.
|
DATA lt_log_act TYPE zcl_abapgit_news=>tt_log.
|
||||||
CLEAR: ls_log.
|
DATA lo_src_text_buf TYPE REF TO lcl_string_buffer.
|
||||||
ls_log-version = &1.
|
DATA lo_log_entries TYPE REF TO lcl_log_entries.
|
||||||
ls_log-is_header = &2.
|
|
||||||
ls_log-is_important = &3.
|
|
||||||
ls_log-pos_to_cur = &4.
|
|
||||||
ls_log-text = &5.
|
|
||||||
APPEND ls_log TO lt_log_exp.
|
|
||||||
END-OF-DEFINITION.
|
|
||||||
|
|
||||||
DEFINE _add_news_txt_entry.
|
|
||||||
APPEND &1 TO lt_lines.
|
|
||||||
END-OF-DEFINITION.
|
|
||||||
|
|
||||||
DATA: lt_log_exp TYPE zcl_abapgit_news=>tt_log,
|
|
||||||
lt_log_act TYPE zcl_abapgit_news=>tt_log,
|
|
||||||
ls_log LIKE LINE OF lt_log_exp,
|
|
||||||
lt_lines TYPE string_table.
|
|
||||||
|
|
||||||
" Generate test data
|
" Generate test data
|
||||||
_add_news_txt_entry '======'.
|
CREATE OBJECT lo_src_text_buf.
|
||||||
_add_news_txt_entry '------'.
|
lo_src_text_buf->add( '======' ).
|
||||||
_add_news_txt_entry ` `.
|
lo_src_text_buf->add( '------' ).
|
||||||
_add_news_txt_entry 'abapGit changelog'.
|
lo_src_text_buf->add( ` ` ).
|
||||||
_add_news_txt_entry '2017-02-13 v1.28.0'.
|
lo_src_text_buf->add( 'abapGit changelog' ).
|
||||||
_add_news_txt_entry '------------------'.
|
lo_src_text_buf->add( '2017-02-13 v1.28.0' ).
|
||||||
_add_news_txt_entry '+ Staging page redesigned'.
|
lo_src_text_buf->add( '------------------' ).
|
||||||
_add_news_txt_entry '! Support for core data services'.
|
lo_src_text_buf->add( '+ Staging page redesigned' ).
|
||||||
_add_news_txt_entry ` `.
|
lo_src_text_buf->add( '! Support for core data services' ).
|
||||||
_add_news_txt_entry '2017-01-25 v1.27.0'.
|
lo_src_text_buf->add( ` ` ).
|
||||||
_add_news_txt_entry '------------------'.
|
lo_src_text_buf->add( '2017-01-25 v1.27.0' ).
|
||||||
_add_news_txt_entry '+ Two factor authentication with github.com'.
|
lo_src_text_buf->add( '------------------' ).
|
||||||
_add_news_txt_entry '2017-01-25 v1.26.0'.
|
lo_src_text_buf->add( '+ Two factor authentication with github.com' ).
|
||||||
|
lo_src_text_buf->add( '2017-01-25 v1.26.0' ).
|
||||||
|
|
||||||
" Case 1
|
" Case 1
|
||||||
" Generate expected results
|
" Generate expected results
|
||||||
" VERSION HEAD IMP POS TEXT
|
CREATE OBJECT lo_log_entries.
|
||||||
_add_news_log_entry '1.28.0' 'X' '' 1 '2017-02-13 v1.28.0'.
|
" VERSION HEAD IMP POS TEXT
|
||||||
_add_news_log_entry '1.28.0' '' '' 0 '+ Staging page redesigned'.
|
lo_log_entries->add( '1.28.0 /X / /1 /2017-02-13 v1.28.0' ).
|
||||||
_add_news_log_entry '1.28.0' '' 'X' 0 '! Support for core data services'.
|
lo_log_entries->add( '1.28.0 / / /0 /+ Staging page redesigned' ).
|
||||||
_add_news_log_entry '1.27.0' 'X' '' 1 '2017-01-25 v1.27.0'.
|
lo_log_entries->add( '1.28.0 / /X /0 /! Support for core data services' ).
|
||||||
_add_news_log_entry '1.27.0' '' '' 0 '+ Two factor authentication with github.com'.
|
lo_log_entries->add( '1.27.0 /X / /1 /2017-01-25 v1.27.0' ).
|
||||||
|
lo_log_entries->add( '1.27.0 / / /0 /+ Two factor authentication with github.com' ).
|
||||||
|
|
||||||
lt_log_act = zcl_abapgit_news=>parse( it_lines = lt_lines iv_current_version = '1.26.01' ).
|
lt_log_act = zcl_abapgit_news=>parse(
|
||||||
cl_abap_unit_assert=>assert_equals( exp = lt_log_exp
|
it_lines = lo_src_text_buf->mt_buffer
|
||||||
act = lt_log_act
|
iv_current_version = '1.26.01' ).
|
||||||
msg = ' Error during parsing: Case 1.' ).
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
exp = lo_log_entries->mt_log_entries
|
||||||
|
act = lt_log_act
|
||||||
|
msg = ' Error during parsing: Case 1.' ).
|
||||||
|
|
||||||
|
|
||||||
" Case 2 (exect version match)
|
" Case 2 (exect version match)
|
||||||
CLEAR lt_log_exp.
|
CREATE OBJECT lo_log_entries.
|
||||||
" VERSION HEAD IMP UPD TEXT
|
" VERSION HEAD IMP UPD TEXT
|
||||||
_add_news_log_entry '1.28.0' 'X' '' 1 '2017-02-13 v1.28.0'.
|
lo_log_entries->add( '1.28.0 /X / /1 /2017-02-13 v1.28.0' ).
|
||||||
_add_news_log_entry '1.28.0' '' '' 0 '+ Staging page redesigned'.
|
lo_log_entries->add( '1.28.0 / / /0 /+ Staging page redesigned' ).
|
||||||
_add_news_log_entry '1.28.0' '' 'X' 0 '! Support for core data services'.
|
lo_log_entries->add( '1.28.0 / /X /0 /! Support for core data services' ).
|
||||||
|
|
||||||
" Case 1: Test parsing of data
|
lt_log_act = zcl_abapgit_news=>parse(
|
||||||
lt_log_act = zcl_abapgit_news=>parse( it_lines = lt_lines iv_current_version = '1.27.00' ).
|
it_lines = lo_src_text_buf->mt_buffer
|
||||||
cl_abap_unit_assert=>assert_equals( exp = lt_log_exp
|
iv_current_version = '1.27.00' ).
|
||||||
act = lt_log_act
|
cl_abap_unit_assert=>assert_equals(
|
||||||
msg = ' Error during parsing: Case 2.' ).
|
exp = lo_log_entries->mt_log_entries
|
||||||
|
act = lt_log_act
|
||||||
|
msg = ' Error during parsing: Case 2.' ).
|
||||||
|
|
||||||
" Case 3 (display tail)
|
" Case 3 (display tail)
|
||||||
CLEAR lt_log_exp.
|
CREATE OBJECT lo_log_entries.
|
||||||
" VERSION HEAD IMP UPD TEXT
|
" VERSION HEAD IMP UPD TEXT
|
||||||
_add_news_log_entry '1.28.0' 'X' '' 0 '2017-02-13 v1.28.0'.
|
lo_log_entries->add( '1.28.0 /X / /0 /2017-02-13 v1.28.0' ).
|
||||||
_add_news_log_entry '1.28.0' '' '' 0 '+ Staging page redesigned'.
|
lo_log_entries->add( '1.28.0 / / /0 /+ Staging page redesigned' ).
|
||||||
_add_news_log_entry '1.28.0' '' 'X' 0 '! Support for core data services'.
|
lo_log_entries->add( '1.28.0 / /X /0 /! Support for core data services' ).
|
||||||
_add_news_log_entry '1.27.0' 'X' '' -1 '2017-01-25 v1.27.0'.
|
lo_log_entries->add( '1.27.0 /X / /-1 /2017-01-25 v1.27.0' ).
|
||||||
_add_news_log_entry '1.27.0' '' '' 0 '+ Two factor authentication with github.com'.
|
lo_log_entries->add( '1.27.0 / / /0 /+ Two factor authentication with github.com' ).
|
||||||
_add_news_log_entry '1.26.0' 'X' '' -1 '2017-01-25 v1.26.0'.
|
lo_log_entries->add( '1.26.0 /X / /-1 /2017-01-25 v1.26.0' ).
|
||||||
|
|
||||||
" Case 1: Test parsing of data
|
lt_log_act = zcl_abapgit_news=>parse(
|
||||||
lt_log_act = zcl_abapgit_news=>parse( it_lines = lt_lines iv_current_version = '1.28.00' ).
|
it_lines = lo_src_text_buf->mt_buffer
|
||||||
cl_abap_unit_assert=>assert_equals( exp = lt_log_exp
|
iv_current_version = '1.28.00' ).
|
||||||
act = lt_log_act
|
cl_abap_unit_assert=>assert_equals(
|
||||||
msg = ' Error during parsing: Case 3.' ).
|
exp = lo_log_entries->mt_log_entries
|
||||||
|
act = lt_log_act
|
||||||
|
msg = ' Error during parsing: Case 3.' ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user