Skip to content

Commit

Permalink
Issue #11 - Update Codebase to ABAP 7.40 SP 02
Browse files Browse the repository at this point in the history
Fixed some issues (Commit 6 / n)
  • Loading branch information
NeumannJoerg committed Jul 8, 2024
1 parent 8b160c4 commit e95edb5
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 65 deletions.
11 changes: 3 additions & 8 deletions src/#usi#bal_logger_bl/#usi#cl_bal_logger_bl_factory.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,13 @@ CLASS /usi/cl_bal_logger_bl_factory IMPLEMENTATION.
ENDMETHOD.

METHOD /usi/if_bal_logger_bl_factory~get_exception_mapper.
DATA: cust_evaluator TYPE REF TO /usi/if_bal_ce_cx_mapper,
classname TYPE seoclsname,
" TODO: variable is assigned but never used (ABAP cleaner)
create_error TYPE REF TO cx_sy_create_error.

cust_evaluator = cust_eval_factory->get_exception_mapper( ).
classname = cust_evaluator->get_exception_mapper_classname( i_exception ).
DATA(cust_evaluator) = cust_eval_factory->get_exception_mapper( ).
DATA(classname) = cust_evaluator->get_exception_mapper_classname( i_exception ).

TRY.
CREATE OBJECT r_result TYPE (classname)
EXPORTING i_exception = i_exception.
CATCH cx_sy_create_error INTO create_error.
CATCH cx_sy_create_error.
classname = cust_evaluator->get_fallback_mapper_classname( ).
CREATE OBJECT r_result TYPE (classname)
EXPORTING i_exception = i_exception.
Expand Down
6 changes: 2 additions & 4 deletions src/#usi#bal_logger_bl/#usi#cl_bal_lstate_active.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CLASS /usi/cl_bal_lstate_active DEFINITION PUBLIC FINAL CREATE PUBLIC.
"! @parameter i_auto_save_pckg_size | Package size of auto save (Customizing)
"! @parameter i_log_dao | DAO-Instance for messages (Persistency Layer)
"! @parameter i_data_cont_coll_dao | DAO-Instance for data-containers (Persistency Layer)
"! @parameter i_token | Token (Proof of Ownership - will be needed to authorize critical actions later)
"! @parameter i_token | Token (Proof of Ownership - needed to authorize critical actions later)
"! @parameter i_relevant_data_containers | Relevant data containers (Customizing)
METHODS constructor
IMPORTING i_factory TYPE REF TO /usi/if_bal_logger_bl_factory
Expand Down Expand Up @@ -423,9 +423,7 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION.
ENDMETHOD.

METHOD is_data_container_relevant.
IF line_exists( settings-relevant_data_containers[ table_line = i_data_container_classname ] ).
r_result = abap_true.
ENDIF.
r_result = boolc( line_exists( settings-relevant_data_containers[ table_line = i_data_container_classname ] ) ).
ENDMETHOD.

METHOD save_data_container_colls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ CLASS lcl_data_cont_coll_dao_spy DEFINITION FINAL FOR TESTING.

CONSTANTS:
BEGIN OF method_names,
delete_collection TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'DELETE_COLLECTION',
get_collection TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'GET_COLLECTION',
insert_collection_into_buffer TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'INSERT_COLLECTION_INTO_BUFFER',
save_buffer_to_db TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'SAVE_BUFFER_TO_DB',
delete_collection TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'DELETE_COLLECTION',
get_collection TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'GET_COLLECTION',
insert_into_buffer TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'INSERT_COLLECTION_INTO_BUFFER',
save_buffer_to_db TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'SAVE_BUFFER_TO_DB',
END OF method_names.

CONSTANTS:
Expand Down Expand Up @@ -102,7 +102,7 @@ CLASS lcl_data_cont_coll_dao_spy IMPLEMENTATION.
METHOD /usi/if_bal_data_cont_coll_dao~insert_collection_into_buffer.
DATA method_call TYPE REF TO /usi/cl_bal_aunit_method_call.

method_call = method_calls->insert_method_call( method_names-insert_collection_into_buffer ).
method_call = method_calls->insert_method_call( method_names-insert_into_buffer ).
method_call->add_parameter( i_parameter_name = 'I_LOG_NUMBER'
i_parameter_value = i_log_number ).
method_call->add_parameter( i_parameter_name = 'I_MESSAGE_NUMBER'
Expand Down Expand Up @@ -414,7 +414,7 @@ CLASS lcl_unit_test_dao_delegation IMPLEMENTATION.
log_dao_spy->method_calls->assert_method_was_called( log_dao_spy->method_names-save ).

" Data-Container-Collection-DAO (Saves data container collections)
dc_coll_dao_spy->method_calls->assert_method_was_called( dc_coll_dao_spy->method_names-insert_collection_into_buffer ).
dc_coll_dao_spy->method_calls->assert_method_was_called( dc_coll_dao_spy->method_names-insert_into_buffer ).

dc_coll_dao_spy->method_calls->assert_method_was_called( dc_coll_dao_spy->method_names-save_buffer_to_db ).
ENDMETHOD.
Expand All @@ -439,8 +439,7 @@ CLASS lcl_unit_test_dao_delegation IMPLEMENTATION.
log_dao_spy->method_calls->assert_method_was_not_called( log_dao_spy->method_names-save ).

" Data-Container-Collection-DAO (Saves data container collections)
dc_coll_dao_spy->method_calls->assert_method_was_not_called(
dc_coll_dao_spy->method_names-insert_collection_into_buffer ).
dc_coll_dao_spy->method_calls->assert_method_was_not_called( dc_coll_dao_spy->method_names-insert_into_buffer ).

dc_coll_dao_spy->method_calls->assert_method_was_not_called( dc_coll_dao_spy->method_names-save_buffer_to_db ).
ENDMETHOD.
Expand Down Expand Up @@ -470,7 +469,7 @@ CLASS lcl_unit_test_dao_delegation IMPLEMENTATION.
i_expected_number_of_calls = 1 ).

dc_coll_dao_spy->method_calls->assert_method_called_n_times(
i_method_name = dc_coll_dao_spy->method_names-insert_collection_into_buffer
i_method_name = dc_coll_dao_spy->method_names-insert_into_buffer
i_expected_number_of_calls = 1 ).
dc_coll_dao_spy->method_calls->assert_method_called_n_times(
i_method_name = dc_coll_dao_spy->method_names-save_buffer_to_db
Expand Down Expand Up @@ -1896,8 +1895,7 @@ CLASS lcl_unit_test_multiple_saves IMPLEMENTATION.

FIELD-SYMBOLS <method_call> TYPE /usi/cl_bal_aunit_method_calls=>ty_method_call.

method_calls = dc_coll_dao_spy->method_calls->get_method_calls(
dc_coll_dao_spy->method_names-insert_collection_into_buffer ).
method_calls = dc_coll_dao_spy->method_calls->get_method_calls( dc_coll_dao_spy->method_names-insert_into_buffer ).
cl_aunit_assert=>assert_not_initial( act = method_calls
msg = 'Method was not called!' ).

Expand Down
15 changes: 5 additions & 10 deletions src/#usi#bal_logger_bl/#usi#cl_bal_token.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,20 @@ ENDCLASS.

CLASS lcl_unit_tests IMPLEMENTATION.
METHOD assert_equals_same_instance.
DATA cut TYPE REF TO /usi/if_bal_token.
DATA(cut) = NEW /usi/cl_bal_token( ).

cut = NEW /usi/cl_bal_token( ).

DATA(actual_result) = cut->is_equal( cut ).
DATA(actual_result) = cut->/usi/if_bal_token~is_equal( cut ).

cl_aunit_assert=>assert_equals( exp = abap_true
act = actual_result
msg = 'Instance does not equal itself!' ).
ENDMETHOD.

METHOD assert_not_equals_others.
DATA: cut TYPE REF TO /usi/if_bal_token,
other_instance TYPE REF TO /usi/if_bal_token.

cut = NEW /usi/cl_bal_token( ).
other_instance = NEW /usi/cl_bal_token( ).
DATA(cut) = NEW /usi/cl_bal_token( ).
DATA(other_instance) = NEW /usi/cl_bal_token( ).

DATA(actual_result) = cut->is_equal( other_instance ).
DATA(actual_result) = cut->/usi/if_bal_token~is_equal( other_instance ).

cl_aunit_assert=>assert_equals( exp = abap_false
act = actual_result
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
*"* use this source file for your ABAP unit test classes

*--------------------------------------------------------------------*
* Unit test: XML <-> DB conversion
*--------------------------------------------------------------------*
" ---------------------------------------------------------------------
" Unit test: XML <-> DB conversion
" ---------------------------------------------------------------------
CLASS lcl_unit_tests_db_conversion DEFINITION DEFERRED.
CLASS /usi/cl_bal_data_cont_coll_dao DEFINITION LOCAL FRIENDS lcl_unit_tests_db_conversion.

CLASS lcl_unit_tests_db_conversion DEFINITION FINAL FOR TESTING.
"#AU Risk_Level Harmless
"#AU Duration Short

PRIVATE SECTION.
METHODS test_conversion FOR TESTING.
METHODS test_empty_xml_string FOR TESTING.

METHODS get_xml_test_string
RETURNING
VALUE(r_result) TYPE /usi/bal_xml_string.
RETURNING VALUE(r_result) TYPE /usi/bal_xml_string.
ENDCLASS.


CLASS lcl_unit_tests_db_conversion IMPLEMENTATION.
METHOD test_conversion.
DATA: actual_result TYPE /usi/bal_xml_string,
Expand All @@ -27,7 +28,7 @@ CLASS lcl_unit_tests_db_conversion IMPLEMENTATION.

expected_result = get_xml_test_string( ).

CREATE OBJECT cut.
cut = NEW #( ).
db_records = cut->convert_xml_to_db( i_log_number = '123456'
i_message_number = '1'
i_serialized_data_cont_coll = expected_result ).
Expand All @@ -42,19 +43,18 @@ CLASS lcl_unit_tests_db_conversion IMPLEMENTATION.
DATA callstack TYPE abap_callstack.

CALL FUNCTION 'SYSTEM_CALLSTACK'
IMPORTING
callstack = callstack.
IMPORTING callstack = callstack.

CALL TRANSFORMATION id
SOURCE callstack = callstack
RESULT XML r_result.
SOURCE callstack = callstack
RESULT XML r_result.
ENDMETHOD.

METHOD test_empty_xml_string.
DATA: cut TYPE REF TO /usi/cl_bal_data_cont_coll_dao,
unexpected_exception TYPE REF TO /usi/cx_bal_root.

CREATE OBJECT cut.
cut = NEW #( ).

TRY.
cut->/usi/if_bal_data_cont_coll_dao~insert_collection_into_buffer( i_log_number = '1'
Expand All @@ -69,22 +69,25 @@ CLASS lcl_unit_tests_db_conversion IMPLEMENTATION.
ENDMETHOD.
ENDCLASS.

*--------------------------------------------------------------------*
* Unit test: Duplicate message
*--------------------------------------------------------------------*

" ---------------------------------------------------------------------
" Unit test: Duplicate message
" ---------------------------------------------------------------------
CLASS lcl_unit_test_duplicate_msg DEFINITION FINAL FOR TESTING.
"#AU Risk_Level Harmless
"#AU Duration Short

PRIVATE SECTION.
METHODS test_duplicate_message FOR TESTING.
ENDCLASS.


CLASS lcl_unit_test_duplicate_msg IMPLEMENTATION.
METHOD test_duplicate_message.
DATA: cut TYPE REF TO /usi/if_bal_data_cont_coll_dao,
unexpected_exception TYPE REF TO /usi/cx_bal_root.

CREATE OBJECT cut TYPE /usi/cl_bal_data_cont_coll_dao.
cut = NEW /usi/cl_bal_data_cont_coll_dao( ).
TRY.
cut->insert_collection_into_buffer( i_log_number = '1'
i_message_number = 1
Expand Down
2 changes: 1 addition & 1 deletion src/#usi#bal_logger_dao/#usi#cl_bal_log_dao.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CLASS /usi/cl_bal_log_dao DEFINITION PUBLIC FINAL CREATE PUBLIC.
"!
"! @parameter i_log_object | Log Object (Defined in SLG0)
"! @parameter i_sub_object | Sub Object (Defined in SLG0)
"! @parameter i_external_id | External ID of the log (Filter in SLG1 - use ID of processed object if feasible)
"! @parameter i_external_id | External ID of the log (Filter in SLG1; use processed objects ID if feasible)
"! @parameter i_retention_parameters | Retention parameters
"! @parameter i_context | Context structure
"! @parameter i_params | Parameters for standard API
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUNCTION /USI/BAL_SHLP_DATA_CONTAINER.
FUNCTION /usi/bal_shlp_data_container.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FUNCTION /USI/BAL_SHLP_EXCEPTION_MAPPER.
FUNCTION /usi/bal_shlp_exception_mapper.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CLASS lcl_plugin_interface DEFINITION FINAL CREATE PUBLIC.
classname TYPE seoclsname,
description TYPE seodescr,
END OF ty_class,
ty_classes TYPE STANDARD TABLE OF ty_class WITH NON-UNIQUE DEFAULT KEY.
ty_classes TYPE STANDARD TABLE OF ty_class WITH EMPTY KEY.

METHODS constructor
IMPORTING i_interface_name TYPE seoclsname
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CLASS /usi/cl_bal_tc_report_text_c40 DEFINITION PUBLIC FINAL CREATE PRIVATE.
"!
"! @parameter i_program | Program
"! @parameter i_text_key | Text key
"! @parameter i_text | Text (Dummy - ignored internally, passing the text will avoid ATC-Messages for unused texts)
"! @parameter i_text | Text (Dummy/ignored, passing the text will avoid ATC-Messages for unused texts)
"! @parameter r_result | Text container instance
CLASS-METHODS create_for_program
IMPORTING i_program TYPE programm
Expand All @@ -19,7 +19,7 @@ CLASS /usi/cl_bal_tc_report_text_c40 DEFINITION PUBLIC FINAL CREATE PRIVATE.
"! <h1>Create instance for current program</h1>
"!
"! @parameter i_text_key | Text key
"! @parameter i_text | Text (Dummy - ignored internally, passing the text will avoid ATC-Messages for unused texts)
"! @parameter i_text | Text (Dummy/ignored, passing the text will avoid ATC-Messages for unused texts)
"! @parameter r_result | Text container instance
CLASS-METHODS create
IMPORTING i_text_key TYPE ty_text_key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ CLASS /usi/cl_bal_aunit_cut_descr_cl IMPLEMENTATION.

class_description = get_rtti_description( ).

LOOP AT class_description->attributes ASSIGNING <attribute> WHERE visibility = cl_abap_classdescr=>public
AND is_class = abap_true
AND type_kind = cl_abap_classdescr=>typekind_oref.
LOOP AT class_description->attributes
ASSIGNING <attribute>
WHERE visibility = cl_abap_classdescr=>public
AND is_class = abap_true
AND type_kind = cl_abap_classdescr=>typekind_oref.
ASSIGN (classname)=>(<attribute>-name) TO <instance>.
IF sy-subrc <> 0.
cl_aunit_assert=>fail( msg = `Could not access public static oref-attribute`
Expand Down
12 changes: 4 additions & 8 deletions src/#usi#bal_unit_test/#usi#cl_bal_aunit_method_calls.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,18 @@ CLASS /usi/cl_bal_aunit_method_calls IMPLEMENTATION.
ENDMETHOD.

METHOD insert_method_call.
DATA method_call TYPE ty_method_call.

r_result = NEW #( i_method_name = i_method_name ).

method_call-method_name = r_result->method_name.
method_call-method_call = r_result.
INSERT method_call INTO TABLE method_calls.
INSERT VALUE #( method_name = r_result->method_name
method_call = r_result )
INTO TABLE method_calls.
ENDMETHOD.

METHOD reset_method_calls.
CLEAR method_calls.
ENDMETHOD.

METHOD was_method_called.
IF line_exists( method_calls[ method_name = i_method_name ] ).
r_result = abap_true.
ENDIF.
r_result = boolc( line_exists( method_calls[ method_name = i_method_name ] ) ).
ENDMETHOD.
ENDCLASS.

0 comments on commit e95edb5

Please sign in to comment.