mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-02 04:36:49 +08:00
Merge pull request #528 from EduardoCopat/clas-intf-changed-by
CLAS-INTF refactor changed by/change since
This commit is contained in:
commit
eba41c5b3a
|
@ -8,6 +8,11 @@
|
||||||
*
|
*
|
||||||
*----------------------------------------------------------------------*
|
*----------------------------------------------------------------------*
|
||||||
INTERFACE lif_object_oriented_object.
|
INTERFACE lif_object_oriented_object.
|
||||||
|
TYPES: BEGIN OF ty_includes,
|
||||||
|
programm TYPE programm,
|
||||||
|
END OF ty_includes,
|
||||||
|
ty_includes_tt TYPE STANDARD TABLE OF ty_includes WITH DEFAULT KEY.
|
||||||
|
|
||||||
METHODS:
|
METHODS:
|
||||||
create
|
create
|
||||||
IMPORTING
|
IMPORTING
|
||||||
|
@ -62,7 +67,12 @@ INTERFACE lif_object_oriented_object.
|
||||||
iv_object_name TYPE dokhl-object
|
iv_object_name TYPE dokhl-object
|
||||||
iv_language TYPE spras
|
iv_language TYPE spras
|
||||||
RAISING
|
RAISING
|
||||||
lcx_exception.
|
lcx_exception,
|
||||||
|
get_includes
|
||||||
|
IMPORTING
|
||||||
|
iv_object_name TYPE sobj_name
|
||||||
|
RETURNING
|
||||||
|
VALUE(rt_includes) TYPE ty_includes_tt.
|
||||||
ENDINTERFACE.
|
ENDINTERFACE.
|
||||||
|
|
||||||
CLASS lcl_object_oriented_base DEFINITION ABSTRACT.
|
CLASS lcl_object_oriented_base DEFINITION ABSTRACT.
|
||||||
|
@ -85,7 +95,7 @@ CLASS lcl_object_oriented_base IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD lif_object_oriented_object~create.
|
METHOD lif_object_oriented_object~create.
|
||||||
"Subclass responsibility
|
"Subclass responsibility
|
||||||
RETURN.
|
ASSERT 0 = 1.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD lif_object_oriented_object~deserialize_source.
|
METHOD lif_object_oriented_object~deserialize_source.
|
||||||
|
@ -102,7 +112,7 @@ CLASS lcl_object_oriented_base IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD lif_object_oriented_object~generate_locals.
|
METHOD lif_object_oriented_object~generate_locals.
|
||||||
"Subclass responsibility
|
"Subclass responsibility
|
||||||
RETURN.
|
ASSERT 0 = 1.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD deserialize_abap_source_old.
|
METHOD deserialize_abap_source_old.
|
||||||
|
@ -172,12 +182,12 @@ CLASS lcl_object_oriented_base IMPLEMENTATION.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
METHOD lif_object_oriented_object~insert_text_pool.
|
METHOD lif_object_oriented_object~insert_text_pool.
|
||||||
"Subclass responsibility
|
"Subclass responsibility
|
||||||
RETURN.
|
ASSERT 0 = 1.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD lif_object_oriented_object~create_sotr.
|
METHOD lif_object_oriented_object~create_sotr.
|
||||||
"Subclass responsibility
|
"Subclass responsibility
|
||||||
RETURN.
|
ASSERT 0 = 1.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD lif_object_oriented_object~create_documentation.
|
METHOD lif_object_oriented_object~create_documentation.
|
||||||
|
@ -196,6 +206,11 @@ CLASS lcl_object_oriented_base IMPLEMENTATION.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD lif_object_oriented_object~get_includes.
|
||||||
|
"Subclass responsibility
|
||||||
|
ASSERT 0 = 1.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
@ -206,7 +221,8 @@ CLASS lcl_object_oriented_class DEFINITION
|
||||||
lif_object_oriented_object~create REDEFINITION,
|
lif_object_oriented_object~create REDEFINITION,
|
||||||
lif_object_oriented_object~generate_locals REDEFINITION,
|
lif_object_oriented_object~generate_locals REDEFINITION,
|
||||||
lif_object_oriented_object~insert_text_pool REDEFINITION,
|
lif_object_oriented_object~insert_text_pool REDEFINITION,
|
||||||
lif_object_oriented_object~create_sotr REDEFINITION.
|
lif_object_oriented_object~create_sotr REDEFINITION,
|
||||||
|
lif_object_oriented_object~get_includes REDEFINITION.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
CLASS lcl_object_oriented_class IMPLEMENTATION.
|
CLASS lcl_object_oriented_class IMPLEMENTATION.
|
||||||
|
@ -325,13 +341,44 @@ CLASS lcl_object_oriented_class IMPLEMENTATION.
|
||||||
ENDLOOP.
|
ENDLOOP.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD lif_object_oriented_object~get_includes.
|
||||||
|
* note: includes returned might not exist
|
||||||
|
* method cl_oo_classname_service=>GET_ALL_CLASS_INCLUDES does not exist in 702
|
||||||
|
|
||||||
|
DATA: lv_class_name TYPE seoclsname,
|
||||||
|
lt_methods TYPE seop_methods_w_include.
|
||||||
|
|
||||||
|
FIELD-SYMBOLS: <ls_method> LIKE LINE OF lt_methods.
|
||||||
|
|
||||||
|
lv_class_name = iv_object_name.
|
||||||
|
|
||||||
|
APPEND cl_oo_classname_service=>get_ccdef_name( lv_class_name ) TO rt_includes.
|
||||||
|
APPEND cl_oo_classname_service=>get_ccmac_name( lv_class_name ) TO rt_includes.
|
||||||
|
APPEND cl_oo_classname_service=>get_ccimp_name( lv_class_name ) TO rt_includes.
|
||||||
|
APPEND cl_oo_classname_service=>get_cl_name( lv_class_name ) TO rt_includes.
|
||||||
|
APPEND cl_oo_classname_service=>get_ccau_name( lv_class_name ) TO rt_includes.
|
||||||
|
APPEND cl_oo_classname_service=>get_pubsec_name( lv_class_name ) TO rt_includes.
|
||||||
|
APPEND cl_oo_classname_service=>get_prosec_name( lv_class_name ) TO rt_includes.
|
||||||
|
APPEND cl_oo_classname_service=>get_prisec_name( lv_class_name ) TO rt_includes.
|
||||||
|
APPEND cl_oo_classname_service=>get_classpool_name( lv_class_name ) TO rt_includes.
|
||||||
|
APPEND cl_oo_classname_service=>get_ct_name( lv_class_name ) TO rt_includes.
|
||||||
|
APPEND cl_oo_classname_service=>get_cs_name( lv_class_name ) TO rt_includes.
|
||||||
|
|
||||||
|
lt_methods = cl_oo_classname_service=>get_all_method_includes( lv_class_name ).
|
||||||
|
LOOP AT lt_methods ASSIGNING <ls_method>.
|
||||||
|
APPEND <ls_method>-incname TO rt_includes.
|
||||||
|
ENDLOOP.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
CLASS lcl_object_oriented_interface DEFINITION
|
CLASS lcl_object_oriented_interface DEFINITION
|
||||||
INHERITING FROM lcl_object_oriented_base.
|
INHERITING FROM lcl_object_oriented_base.
|
||||||
PUBLIC SECTION.
|
PUBLIC SECTION.
|
||||||
METHODS:
|
METHODS:
|
||||||
lif_object_oriented_object~create REDEFINITION.
|
lif_object_oriented_object~create REDEFINITION,
|
||||||
|
lif_object_oriented_object~get_includes REDEFINITION.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
CLASS lcl_object_oriented_interface IMPLEMENTATION.
|
CLASS lcl_object_oriented_interface IMPLEMENTATION.
|
||||||
|
@ -354,6 +401,12 @@ CLASS lcl_object_oriented_interface IMPLEMENTATION.
|
||||||
lcx_exception=>raise( 'Error from SEO_INTERFACE_CREATE_COMPLETE' ).
|
lcx_exception=>raise( 'Error from SEO_INTERFACE_CREATE_COMPLETE' ).
|
||||||
ENDIF.
|
ENDIF.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
METHOD lif_object_oriented_object~get_includes.
|
||||||
|
DATA lv_interface_name TYPE seoclsname.
|
||||||
|
lv_interface_name = iv_object_name.
|
||||||
|
APPEND cl_oo_classname_service=>get_interfacepool_name( lv_interface_name ) TO rt_includes.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
CLASS lth_oo_factory_injector DEFINITION DEFERRED.
|
CLASS lth_oo_factory_injector DEFINITION DEFERRED.
|
||||||
|
@ -403,6 +456,11 @@ CLASS lcl_object_clas DEFINITION INHERITING FROM lcl_objects_program.
|
||||||
PUBLIC SECTION.
|
PUBLIC SECTION.
|
||||||
INTERFACES lif_object.
|
INTERFACES lif_object.
|
||||||
ALIASES mo_files FOR lif_object~mo_files.
|
ALIASES mo_files FOR lif_object~mo_files.
|
||||||
|
METHODS constructor
|
||||||
|
IMPORTING
|
||||||
|
is_item TYPE ty_item
|
||||||
|
iv_language TYPE spras.
|
||||||
|
|
||||||
PROTECTED SECTION.
|
PROTECTED SECTION.
|
||||||
METHODS deserialize_abap
|
METHODS deserialize_abap
|
||||||
IMPORTING io_xml TYPE REF TO lcl_xml_input
|
IMPORTING io_xml TYPE REF TO lcl_xml_input
|
||||||
|
@ -474,10 +532,6 @@ CLASS lcl_object_clas DEFINITION INHERITING FROM lcl_objects_program.
|
||||||
|
|
||||||
METHODS reduce
|
METHODS reduce
|
||||||
CHANGING ct_source TYPE ty_string_tt.
|
CHANGING ct_source TYPE ty_string_tt.
|
||||||
|
|
||||||
METHODS get_all_class_includes
|
|
||||||
RETURNING VALUE(rt_includes) TYPE seoincl_t.
|
|
||||||
|
|
||||||
ENDCLASS. "lcl_object_dtel DEFINITION
|
ENDCLASS. "lcl_object_dtel DEFINITION
|
||||||
|
|
||||||
*----------------------------------------------------------------------*
|
*----------------------------------------------------------------------*
|
||||||
|
@ -487,78 +541,22 @@ ENDCLASS. "lcl_object_dtel DEFINITION
|
||||||
*----------------------------------------------------------------------*
|
*----------------------------------------------------------------------*
|
||||||
CLASS lcl_object_clas IMPLEMENTATION.
|
CLASS lcl_object_clas IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD get_all_class_includes.
|
|
||||||
* note: includes returned might not exist
|
|
||||||
* method cl_oo_classname_service=>GET_ALL_CLASS_INCLUDES does not exist in 702
|
|
||||||
|
|
||||||
DATA: lv_clsname TYPE seoclsname,
|
|
||||||
lt_methods TYPE seop_methods_w_include.
|
|
||||||
|
|
||||||
FIELD-SYMBOLS: <ls_method> LIKE LINE OF lt_methods.
|
|
||||||
|
|
||||||
|
|
||||||
lv_clsname = ms_item-obj_name.
|
|
||||||
|
|
||||||
APPEND cl_oo_classname_service=>get_ccdef_name( lv_clsname ) TO rt_includes.
|
|
||||||
APPEND cl_oo_classname_service=>get_ccmac_name( lv_clsname ) TO rt_includes.
|
|
||||||
APPEND cl_oo_classname_service=>get_ccimp_name( lv_clsname ) TO rt_includes.
|
|
||||||
APPEND cl_oo_classname_service=>get_cl_name( lv_clsname ) TO rt_includes.
|
|
||||||
APPEND cl_oo_classname_service=>get_ccau_name( lv_clsname ) TO rt_includes.
|
|
||||||
APPEND cl_oo_classname_service=>get_pubsec_name( lv_clsname ) TO rt_includes.
|
|
||||||
APPEND cl_oo_classname_service=>get_prosec_name( lv_clsname ) TO rt_includes.
|
|
||||||
APPEND cl_oo_classname_service=>get_prisec_name( lv_clsname ) TO rt_includes.
|
|
||||||
APPEND cl_oo_classname_service=>get_classpool_name( lv_clsname ) TO rt_includes.
|
|
||||||
APPEND cl_oo_classname_service=>get_ct_name( lv_clsname ) TO rt_includes.
|
|
||||||
APPEND cl_oo_classname_service=>get_cs_name( lv_clsname ) TO rt_includes.
|
|
||||||
|
|
||||||
lt_methods = cl_oo_classname_service=>get_all_method_includes( lv_clsname ).
|
|
||||||
LOOP AT lt_methods ASSIGNING <ls_method>.
|
|
||||||
APPEND <ls_method>-incname TO rt_includes.
|
|
||||||
ENDLOOP.
|
|
||||||
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_object~has_changed_since.
|
METHOD lif_object~has_changed_since.
|
||||||
|
DATA:
|
||||||
|
lt_includes TYPE seoincl_t.
|
||||||
|
|
||||||
DATA: lv_clsname TYPE seoclsname,
|
FIELD-SYMBOLS <incl> LIKE LINE OF lt_includes.
|
||||||
lv_program TYPE program,
|
|
||||||
lt_incl TYPE seoincl_t.
|
|
||||||
|
|
||||||
FIELD-SYMBOLS <incl> LIKE LINE OF lt_incl.
|
|
||||||
|
|
||||||
lv_clsname = ms_item-obj_name.
|
|
||||||
|
|
||||||
CASE ms_item-obj_type.
|
|
||||||
WHEN 'CLAS'.
|
|
||||||
TRY.
|
|
||||||
CALL METHOD cl_oo_classname_service=>('GET_ALL_CLASS_INCLUDES')
|
|
||||||
EXPORTING
|
|
||||||
class_name = lv_clsname
|
|
||||||
RECEIVING
|
|
||||||
result = lt_incl.
|
|
||||||
CATCH cx_sy_dyn_call_illegal_method.
|
|
||||||
* method does not exist in 702, just report everything as changed
|
|
||||||
rv_changed = abap_true.
|
|
||||||
ENDTRY.
|
|
||||||
LOOP AT lt_incl ASSIGNING <incl>.
|
|
||||||
rv_changed = check_prog_changed_since(
|
|
||||||
iv_program = <incl>
|
|
||||||
iv_timestamp = iv_timestamp
|
|
||||||
iv_skip_gui = abap_true ).
|
|
||||||
IF rv_changed = abap_true.
|
|
||||||
RETURN.
|
|
||||||
ENDIF.
|
|
||||||
ENDLOOP.
|
|
||||||
WHEN 'INTF'.
|
|
||||||
lv_program = cl_oo_classname_service=>get_interfacepool_name( lv_clsname ).
|
|
||||||
rv_changed = check_prog_changed_since(
|
|
||||||
iv_program = lv_program
|
|
||||||
iv_timestamp = iv_timestamp
|
|
||||||
iv_skip_gui = abap_true ).
|
|
||||||
WHEN OTHERS.
|
|
||||||
lcx_exception=>raise( 'class delete, unknown type' ).
|
|
||||||
ENDCASE.
|
|
||||||
|
|
||||||
|
lt_includes = mo_object_oriented_object->get_includes( ms_item-obj_name ).
|
||||||
|
LOOP AT lt_includes ASSIGNING <incl>.
|
||||||
|
rv_changed = check_prog_changed_since(
|
||||||
|
iv_program = <incl>
|
||||||
|
iv_timestamp = iv_timestamp
|
||||||
|
iv_skip_gui = abap_true ).
|
||||||
|
IF rv_changed = abap_true.
|
||||||
|
RETURN.
|
||||||
|
ENDIF.
|
||||||
|
ENDLOOP.
|
||||||
ENDMETHOD. "lif_object~has_changed_since
|
ENDMETHOD. "lif_object~has_changed_since
|
||||||
|
|
||||||
METHOD lif_object~get_metadata.
|
METHOD lif_object~get_metadata.
|
||||||
|
@ -579,21 +577,10 @@ CLASS lcl_object_clas IMPLEMENTATION.
|
||||||
|
|
||||||
DATA: lt_reposrc TYPE STANDARD TABLE OF ty_reposrc,
|
DATA: lt_reposrc TYPE STANDARD TABLE OF ty_reposrc,
|
||||||
ls_reposrc LIKE LINE OF lt_reposrc,
|
ls_reposrc LIKE LINE OF lt_reposrc,
|
||||||
lt_includes TYPE STANDARD TABLE OF ty_includes,
|
lt_includes TYPE STANDARD TABLE OF ty_includes.
|
||||||
lv_clsname TYPE seoclsname.
|
|
||||||
|
|
||||||
|
lt_includes = mo_object_oriented_object->get_includes( ms_item-obj_name ).
|
||||||
lv_clsname = ms_item-obj_name.
|
ASSERT lines( lt_includes ) > 0.
|
||||||
|
|
||||||
CASE ms_item-obj_type.
|
|
||||||
WHEN 'CLAS'.
|
|
||||||
lt_includes = get_all_class_includes( ).
|
|
||||||
ASSERT lines( lt_includes ) > 0.
|
|
||||||
WHEN 'INTF'.
|
|
||||||
APPEND cl_oo_classname_service=>get_interfacepool_name( lv_clsname ) TO lt_includes.
|
|
||||||
WHEN OTHERS.
|
|
||||||
ASSERT 0 = 1.
|
|
||||||
ENDCASE.
|
|
||||||
|
|
||||||
SELECT unam udat utime FROM reposrc
|
SELECT unam udat utime FROM reposrc
|
||||||
INTO TABLE lt_reposrc
|
INTO TABLE lt_reposrc
|
||||||
|
@ -1099,9 +1086,6 @@ CLASS lcl_object_clas IMPLEMENTATION.
|
||||||
ENDMETHOD. "serialize_xml
|
ENDMETHOD. "serialize_xml
|
||||||
|
|
||||||
METHOD lif_object~deserialize.
|
METHOD lif_object~deserialize.
|
||||||
|
|
||||||
mo_object_oriented_object = lcl_object_oriented_factory=>make( iv_object_type = ms_item-obj_type ).
|
|
||||||
|
|
||||||
deserialize_abap( io_xml = io_xml
|
deserialize_abap( io_xml = io_xml
|
||||||
iv_package = iv_package ).
|
iv_package = iv_package ).
|
||||||
|
|
||||||
|
@ -1237,6 +1221,13 @@ CLASS lcl_object_clas IMPLEMENTATION.
|
||||||
CREATE OBJECT ro_comparison_result TYPE lcl_null_comparison_result.
|
CREATE OBJECT ro_comparison_result TYPE lcl_null_comparison_result.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD constructor.
|
||||||
|
super->constructor(
|
||||||
|
is_item = is_item
|
||||||
|
iv_language = iv_language ).
|
||||||
|
mo_object_oriented_object = lcl_object_oriented_factory=>make( iv_object_type = ms_item-obj_type ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS. "lcl_object_CLAS IMPLEMENTATION
|
ENDCLASS. "lcl_object_CLAS IMPLEMENTATION
|
||||||
|
|
||||||
*----------------------------------------------------------------------*
|
*----------------------------------------------------------------------*
|
||||||
|
@ -1249,15 +1240,14 @@ CLASS lcl_object_intf DEFINITION INHERITING FROM lcl_object_clas FINAL.
|
||||||
* https://github.com/larshp/abapGit/issues/21
|
* https://github.com/larshp/abapGit/issues/21
|
||||||
PUBLIC SECTION.
|
PUBLIC SECTION.
|
||||||
METHODS:
|
METHODS:
|
||||||
lif_object~deserialize REDEFINITION.
|
lif_object~deserialize REDEFINITION,
|
||||||
|
lif_object~has_changed_since REDEFINITION.
|
||||||
PROTECTED SECTION.
|
PROTECTED SECTION.
|
||||||
METHODS:
|
METHODS:
|
||||||
deserialize_abap REDEFINITION.
|
deserialize_abap REDEFINITION.
|
||||||
ENDCLASS. "lcl_object_intf DEFINITION
|
ENDCLASS. "lcl_object_intf DEFINITION
|
||||||
CLASS lcl_object_intf IMPLEMENTATION.
|
CLASS lcl_object_intf IMPLEMENTATION.
|
||||||
METHOD lif_object~deserialize.
|
METHOD lif_object~deserialize.
|
||||||
mo_object_oriented_object = lcl_object_oriented_factory=>make( iv_object_type = ms_item-obj_type ).
|
|
||||||
|
|
||||||
deserialize_abap( io_xml = io_xml
|
deserialize_abap( io_xml = io_xml
|
||||||
iv_package = iv_package ).
|
iv_package = iv_package ).
|
||||||
|
|
||||||
|
@ -1294,4 +1284,18 @@ CLASS lcl_object_intf IMPLEMENTATION.
|
||||||
|
|
||||||
mo_object_oriented_object->add_to_activation_list( is_item = ms_item ).
|
mo_object_oriented_object->add_to_activation_list( is_item = ms_item ).
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
METHOD lif_object~has_changed_since.
|
||||||
|
DATA:
|
||||||
|
lv_program TYPE program,
|
||||||
|
lt_includes TYPE seoincl_t.
|
||||||
|
|
||||||
|
lt_includes = mo_object_oriented_object->get_includes( ms_item-obj_name ).
|
||||||
|
READ TABLE lt_includes INDEX 1 INTO lv_program.
|
||||||
|
"lv_program = cl_oo_classname_service=>get_interfacepool_name( lv_clsname ).
|
||||||
|
rv_changed = check_prog_changed_since(
|
||||||
|
iv_program = lv_program
|
||||||
|
iv_timestamp = iv_timestamp
|
||||||
|
iv_skip_gui = abap_true ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
|
@ -2210,548 +2210,4 @@ CLASS ltcl_persistence_settings IMPLEMENTATION.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
INCLUDE ZABAPGIT_UNIT_TEST_CLAS_INTF.
|
||||||
CLASS ltd_spy_oo_object DEFINITION FOR TESTING.
|
|
||||||
PUBLIC SECTION.
|
|
||||||
INTERFACES: lif_object_oriented_object.
|
|
||||||
DATA:
|
|
||||||
mv_package TYPE devclass,
|
|
||||||
mv_overwrite TYPE seox_boolean,
|
|
||||||
ms_interface_properties TYPE vseointerf,
|
|
||||||
ms_class_properties TYPE vseoclass,
|
|
||||||
ms_locals_key TYPE seoclskey,
|
|
||||||
mt_local_definitions TYPE rswsourcet,
|
|
||||||
mt_local_implementations TYPE rswsourcet,
|
|
||||||
mt_local_macros TYPE rswsourcet,
|
|
||||||
mt_local_test_classes TYPE rswsourcet,
|
|
||||||
mv_force TYPE seoflag,
|
|
||||||
ms_deserialize_key TYPE seoclskey,
|
|
||||||
mt_source TYPE ty_string_tt,
|
|
||||||
ms_item_to_activate TYPE ty_item,
|
|
||||||
mt_descriptions TYPE ty_seocompotx_tt,
|
|
||||||
ms_description_key TYPE seoclskey,
|
|
||||||
mv_text_pool_class_name TYPE seoclsname,
|
|
||||||
mt_text_pool TYPE textpool_table,
|
|
||||||
mv_text_pool_inserted TYPE abap_bool,
|
|
||||||
mt_sotr TYPE ty_sotr_tt,
|
|
||||||
mt_sotr_package TYPE devclass,
|
|
||||||
mv_docu_object_name TYPE dokhl-object,
|
|
||||||
mv_docu_language TYPE spras,
|
|
||||||
mt_docu_lines TYPE tlinetab.
|
|
||||||
|
|
||||||
ENDCLASS.
|
|
||||||
CLASS ltd_spy_oo_object IMPLEMENTATION.
|
|
||||||
METHOD lif_object_oriented_object~create.
|
|
||||||
DATA lv_properties_structure_name TYPE string.
|
|
||||||
lv_properties_structure_name = cl_abap_typedescr=>describe_by_data( is_properties )->absolute_name.
|
|
||||||
IF lv_properties_structure_name = cl_abap_typedescr=>describe_by_data( ms_interface_properties )->absolute_name.
|
|
||||||
ms_interface_properties = is_properties.
|
|
||||||
ELSE.
|
|
||||||
ms_class_properties = is_properties.
|
|
||||||
ENDIF.
|
|
||||||
mv_package = iv_package.
|
|
||||||
mv_overwrite = iv_overwrite.
|
|
||||||
ENDMETHOD.
|
|
||||||
METHOD lif_object_oriented_object~generate_locals.
|
|
||||||
ms_locals_key = is_key.
|
|
||||||
mt_local_definitions = it_local_definitions.
|
|
||||||
mt_local_implementations = it_local_implementations.
|
|
||||||
mt_local_macros = it_local_macros.
|
|
||||||
mt_local_test_classes = it_local_test_classes.
|
|
||||||
mv_force = iv_force.
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_object_oriented_object~deserialize_source.
|
|
||||||
ms_deserialize_key = is_key.
|
|
||||||
mt_source = it_source.
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_object_oriented_object~add_to_activation_list.
|
|
||||||
ms_item_to_activate = is_item.
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_object_oriented_object~update_descriptions.
|
|
||||||
ms_description_key = is_key.
|
|
||||||
mt_descriptions = it_descriptions.
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_object_oriented_object~insert_text_pool.
|
|
||||||
mv_text_pool_inserted = abap_true.
|
|
||||||
mv_text_pool_class_name = iv_class_name.
|
|
||||||
mt_text_pool = it_text_pool.
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = iv_language
|
|
||||||
exp = sy-langu ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_object_oriented_object~create_sotr.
|
|
||||||
mt_sotr = it_sotr.
|
|
||||||
mt_sotr_package = iv_package.
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_object_oriented_object~create_documentation.
|
|
||||||
mv_docu_object_name = iv_object_name.
|
|
||||||
mv_docu_language = iv_language.
|
|
||||||
mt_docu_lines = it_lines.
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
ENDCLASS.
|
|
||||||
|
|
||||||
CLASS ltd_fake_object_files DEFINITION FOR TESTING
|
|
||||||
INHERITING FROM lcl_objects_files.
|
|
||||||
PUBLIC SECTION.
|
|
||||||
METHODS constructor.
|
|
||||||
METHODS read_abap REDEFINITION.
|
|
||||||
DATA:
|
|
||||||
mt_sources TYPE seop_source_string,
|
|
||||||
mt_local_definitions TYPE seop_source_string,
|
|
||||||
mt_local_implementations TYPE seop_source_string,
|
|
||||||
mt_local_macros TYPE seop_source_string,
|
|
||||||
mt_local_test_classes TYPE seop_source_string.
|
|
||||||
ENDCLASS.
|
|
||||||
CLASS ltd_fake_object_files IMPLEMENTATION.
|
|
||||||
METHOD read_abap.
|
|
||||||
CASE iv_extra.
|
|
||||||
WHEN 'locals_def'.
|
|
||||||
rt_abap = mt_local_definitions.
|
|
||||||
WHEN 'locals_imp'.
|
|
||||||
rt_abap = mt_local_implementations.
|
|
||||||
WHEN 'macros'.
|
|
||||||
rt_abap = mt_local_macros.
|
|
||||||
WHEN 'testclasses'.
|
|
||||||
rt_abap = mt_local_test_classes.
|
|
||||||
WHEN OTHERS.
|
|
||||||
rt_abap = mt_sources.
|
|
||||||
RETURN.
|
|
||||||
ENDCASE.
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals( act = iv_error
|
|
||||||
exp = abap_false ).
|
|
||||||
ENDMETHOD.
|
|
||||||
METHOD constructor.
|
|
||||||
DATA ls_empty_item TYPE ty_item.
|
|
||||||
super->constructor( ls_empty_item ).
|
|
||||||
APPEND 'source' TO me->mt_sources.
|
|
||||||
APPEND 'definition' TO me->mt_local_definitions.
|
|
||||||
APPEND 'implementation' TO me->mt_local_implementations.
|
|
||||||
APPEND 'macro' TO me->mt_local_macros.
|
|
||||||
APPEND 'test' TO me->mt_local_test_classes.
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
ENDCLASS.
|
|
||||||
|
|
||||||
CLASS ltc_oo_test DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
|
|
||||||
PROTECTED SECTION.
|
|
||||||
DATA:
|
|
||||||
mo_spy_oo_object TYPE REF TO ltd_spy_oo_object,
|
|
||||||
mo_fake_object_files TYPE REF TO ltd_fake_object_files,
|
|
||||||
mo_xml_input TYPE REF TO lcl_xml_input,
|
|
||||||
mo_xml_out TYPE REF TO lcl_xml_output,
|
|
||||||
mo_oo_object TYPE REF TO lif_object,
|
|
||||||
ms_item TYPE ty_item.
|
|
||||||
METHODS: when_deserializing
|
|
||||||
RAISING
|
|
||||||
lcx_exception,
|
|
||||||
then_should_deserialize_source,
|
|
||||||
given_the_descriptions
|
|
||||||
IMPORTING
|
|
||||||
it_descriptions TYPE ty_seocompotx_tt
|
|
||||||
RAISING
|
|
||||||
lcx_exception,
|
|
||||||
then_shuld_update_descriptions
|
|
||||||
IMPORTING
|
|
||||||
it_descriptions TYPE ty_seocompotx_tt,
|
|
||||||
then_it_should_add_activation,
|
|
||||||
given_documentation_in_xml_as
|
|
||||||
IMPORTING
|
|
||||||
it_lines TYPE tlinetab
|
|
||||||
RAISING
|
|
||||||
lcx_exception,
|
|
||||||
then_docu_should_be_created
|
|
||||||
IMPORTING
|
|
||||||
it_lines TYPE tlinetab.
|
|
||||||
|
|
||||||
ENDCLASS.
|
|
||||||
CLASS ltc_oo_test IMPLEMENTATION.
|
|
||||||
|
|
||||||
METHOD then_docu_should_be_created.
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mt_docu_lines
|
|
||||||
exp = it_lines ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mv_docu_object_name
|
|
||||||
exp = ms_item-obj_name ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mv_docu_language
|
|
||||||
exp = sy-langu ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD given_documentation_in_xml_as.
|
|
||||||
mo_xml_out->add(
|
|
||||||
iv_name = 'LINES'
|
|
||||||
ig_data = it_lines ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD then_it_should_add_activation.
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->ms_item_to_activate
|
|
||||||
exp = ms_item ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD then_shuld_update_descriptions.
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mt_descriptions
|
|
||||||
exp = it_descriptions ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->ms_description_key
|
|
||||||
exp = ms_item-obj_name ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD given_the_descriptions.
|
|
||||||
mo_xml_out->add(
|
|
||||||
iv_name = 'DESCRIPTIONS'
|
|
||||||
ig_data = it_descriptions ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD then_should_deserialize_source.
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mt_source
|
|
||||||
exp = mo_fake_object_files->mt_sources ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->ms_deserialize_key
|
|
||||||
exp = ms_item-obj_name ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD when_deserializing.
|
|
||||||
CREATE OBJECT mo_xml_input
|
|
||||||
EXPORTING
|
|
||||||
iv_xml = mo_xml_out->render( ).
|
|
||||||
mo_oo_object->deserialize(
|
|
||||||
iv_package = 'package_name'
|
|
||||||
io_xml = mo_xml_input ).
|
|
||||||
ENDMETHOD.
|
|
||||||
ENDCLASS.
|
|
||||||
|
|
||||||
CLASS ltcl_class_deserialization DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT
|
|
||||||
INHERITING FROM ltc_oo_test.
|
|
||||||
PRIVATE SECTION.
|
|
||||||
METHODS:
|
|
||||||
setup,
|
|
||||||
given_a_class_properties
|
|
||||||
RAISING
|
|
||||||
lcx_exception,
|
|
||||||
then_should_create_class,
|
|
||||||
then_it_should_generate_locals,
|
|
||||||
should_create_class FOR TESTING RAISING cx_static_check,
|
|
||||||
should_generate_locals FOR TESTING RAISING cx_static_check,
|
|
||||||
should_deserialize_source FOR TESTING RAISING cx_static_check,
|
|
||||||
should_update_descriptions FOR TESTING RAISING cx_static_check,
|
|
||||||
should_add_to_activation FOR TESTING RAISING cx_static_check,
|
|
||||||
no_text_pool_no_insert FOR TESTING RAISING cx_static_check,
|
|
||||||
insert_text_pool FOR TESTING RAISING cx_static_check,
|
|
||||||
create_stor_from_xml FOR TESTING RAISING cx_static_check,
|
|
||||||
create_documentation FOR TESTING RAISING cx_static_check.
|
|
||||||
DATA:
|
|
||||||
ms_class_properties TYPE vseoclass.
|
|
||||||
ENDCLASS.
|
|
||||||
|
|
||||||
CLASS ltcl_class_deserialization IMPLEMENTATION.
|
|
||||||
METHOD setup.
|
|
||||||
CREATE OBJECT mo_fake_object_files.
|
|
||||||
CREATE OBJECT mo_spy_oo_object.
|
|
||||||
CREATE OBJECT mo_xml_out.
|
|
||||||
lth_oo_factory_injector=>inject( mo_spy_oo_object ).
|
|
||||||
|
|
||||||
ms_item-devclass = 'package_name'.
|
|
||||||
ms_item-obj_name = 'zcl_class'.
|
|
||||||
ms_item-obj_type = 'CLAS'.
|
|
||||||
|
|
||||||
CREATE OBJECT mo_oo_object TYPE lcl_object_clas
|
|
||||||
EXPORTING
|
|
||||||
is_item = ms_item
|
|
||||||
iv_language = sy-langu.
|
|
||||||
mo_oo_object->mo_files = mo_fake_object_files.
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD should_create_class.
|
|
||||||
ms_class_properties-clsname = ms_item-obj_name.
|
|
||||||
|
|
||||||
given_a_class_properties( ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
then_should_create_class( ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD should_generate_locals.
|
|
||||||
given_a_class_properties( ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
then_it_should_generate_locals( ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD should_deserialize_source.
|
|
||||||
given_a_class_properties( ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
then_should_deserialize_source( ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD should_update_descriptions.
|
|
||||||
DATA:
|
|
||||||
ls_description TYPE seocompotx,
|
|
||||||
lt_descriptions TYPE ty_seocompotx_tt.
|
|
||||||
|
|
||||||
given_a_class_properties( ).
|
|
||||||
|
|
||||||
ls_description-clsname = ms_item-obj_name.
|
|
||||||
ls_description-cmpname = 'a_method'.
|
|
||||||
APPEND ls_description TO lt_descriptions.
|
|
||||||
given_the_descriptions( lt_descriptions ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
then_shuld_update_descriptions( lt_descriptions ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD should_add_to_activation.
|
|
||||||
given_a_class_properties( ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
then_it_should_add_activation( ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD given_a_class_properties.
|
|
||||||
mo_xml_out->add(
|
|
||||||
iv_name = 'VSEOCLASS'
|
|
||||||
ig_data = ms_class_properties ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD then_should_create_class.
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->ms_class_properties
|
|
||||||
exp = ms_class_properties ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals( act = mo_spy_oo_object->mv_overwrite
|
|
||||||
exp = abap_true ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mv_package
|
|
||||||
exp = 'package_name' ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
|
|
||||||
METHOD then_it_should_generate_locals.
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->ms_locals_key
|
|
||||||
exp = ms_item-obj_name ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals( act = mo_spy_oo_object->mv_force
|
|
||||||
exp = abap_true ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mt_local_definitions
|
|
||||||
exp = mo_fake_object_files->mt_local_definitions ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mt_local_implementations
|
|
||||||
exp = mo_fake_object_files->mt_local_implementations ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mt_local_macros
|
|
||||||
exp = mo_fake_object_files->mt_local_macros ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mt_local_test_classes
|
|
||||||
exp = mo_fake_object_files->mt_local_test_classes ).
|
|
||||||
ENDMETHOD.
|
|
||||||
METHOD no_text_pool_no_insert.
|
|
||||||
given_a_class_properties( ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals( act = mo_spy_oo_object->mv_text_pool_inserted
|
|
||||||
exp = abap_false ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD insert_text_pool.
|
|
||||||
DATA: lt_pool_external TYPE textpool_table,
|
|
||||||
ls_pool_external TYPE ty_tpool.
|
|
||||||
ls_pool_external-id = 'ID'.
|
|
||||||
ls_pool_external-key = 'KEY'.
|
|
||||||
APPEND ls_pool_external TO lt_pool_external.
|
|
||||||
|
|
||||||
given_a_class_properties( ).
|
|
||||||
|
|
||||||
mo_xml_out->add(
|
|
||||||
iv_name = 'TPOOL'
|
|
||||||
ig_data = lt_pool_external ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mt_text_pool
|
|
||||||
exp = lt_pool_external ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mv_text_pool_class_name
|
|
||||||
exp = 'zcl_class' ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD create_stor_from_xml.
|
|
||||||
DATA:
|
|
||||||
lt_sotr TYPE ty_sotr_tt,
|
|
||||||
ls_sotr LIKE LINE OF lt_sotr.
|
|
||||||
|
|
||||||
given_a_class_properties( ).
|
|
||||||
|
|
||||||
ls_sotr-header-concept = 'HEADER'.
|
|
||||||
APPEND ls_sotr TO lt_sotr.
|
|
||||||
mo_xml_out->add(
|
|
||||||
iv_name = 'SOTR'
|
|
||||||
ig_data = lt_sotr ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mt_sotr
|
|
||||||
exp = lt_sotr ).
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mt_sotr_package
|
|
||||||
exp = 'package_name' ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD create_documentation.
|
|
||||||
DATA: lt_lines TYPE tlinetab,
|
|
||||||
ls_line TYPE LINE OF tlinetab.
|
|
||||||
ls_line-tdline = 'Class Line Doc'.
|
|
||||||
APPEND ls_line TO lt_lines.
|
|
||||||
|
|
||||||
given_a_class_properties( ).
|
|
||||||
|
|
||||||
given_documentation_in_xml_as( lt_lines ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
then_docu_should_be_created( lt_lines ).
|
|
||||||
ENDMETHOD.
|
|
||||||
ENDCLASS.
|
|
||||||
|
|
||||||
CLASS ltcl_interface_deserialization DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT
|
|
||||||
INHERITING FROM ltc_oo_test.
|
|
||||||
PRIVATE SECTION.
|
|
||||||
METHODS:
|
|
||||||
setup,
|
|
||||||
given_an_interface_properties
|
|
||||||
RAISING
|
|
||||||
lcx_exception,
|
|
||||||
then_should_create_interface,
|
|
||||||
create_interface FOR TESTING RAISING cx_static_check,
|
|
||||||
update_descriptions FOR TESTING RAISING cx_static_check,
|
|
||||||
add_to_activation FOR TESTING RAISING cx_static_check,
|
|
||||||
deserialize_source FOR TESTING RAISING cx_static_check,
|
|
||||||
create_documentation FOR TESTING RAISING cx_static_check.
|
|
||||||
DATA:
|
|
||||||
ms_interface_properties TYPE vseointerf.
|
|
||||||
ENDCLASS.
|
|
||||||
CLASS ltcl_interface_deserialization IMPLEMENTATION.
|
|
||||||
METHOD setup.
|
|
||||||
CREATE OBJECT mo_fake_object_files.
|
|
||||||
CREATE OBJECT mo_spy_oo_object.
|
|
||||||
CREATE OBJECT mo_xml_out.
|
|
||||||
lth_oo_factory_injector=>inject( mo_spy_oo_object ).
|
|
||||||
|
|
||||||
ms_item-devclass = 'package_name'.
|
|
||||||
ms_item-obj_name = 'zif_interface'.
|
|
||||||
ms_item-obj_type = 'INTF'.
|
|
||||||
|
|
||||||
CREATE OBJECT mo_oo_object TYPE lcl_object_intf
|
|
||||||
EXPORTING
|
|
||||||
is_item = ms_item
|
|
||||||
iv_language = sy-langu.
|
|
||||||
mo_oo_object->mo_files = mo_fake_object_files.
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD create_interface.
|
|
||||||
ms_interface_properties-clsname = ms_item-obj_name.
|
|
||||||
given_an_interface_properties( ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
then_should_create_interface( ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD update_descriptions.
|
|
||||||
DATA:
|
|
||||||
ls_description TYPE seocompotx,
|
|
||||||
lt_descriptions TYPE ty_seocompotx_tt.
|
|
||||||
|
|
||||||
given_an_interface_properties( ).
|
|
||||||
|
|
||||||
ls_description-clsname = ms_item-obj_name.
|
|
||||||
ls_description-cmpname = 'a_method'.
|
|
||||||
APPEND ls_description TO lt_descriptions.
|
|
||||||
given_the_descriptions( lt_descriptions ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
then_shuld_update_descriptions( lt_descriptions ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD add_to_activation.
|
|
||||||
given_an_interface_properties( ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
then_it_should_add_activation( ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD deserialize_source.
|
|
||||||
given_an_interface_properties( ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
then_should_deserialize_source( ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD given_an_interface_properties.
|
|
||||||
mo_xml_out->add(
|
|
||||||
iv_name = 'VSEOINTERF'
|
|
||||||
ig_data = ms_interface_properties ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD then_should_create_interface.
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->ms_interface_properties
|
|
||||||
exp = ms_interface_properties ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals( act = mo_spy_oo_object->mv_overwrite
|
|
||||||
exp = abap_true ).
|
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
|
||||||
act = mo_spy_oo_object->mv_package
|
|
||||||
exp = 'package_name' ).
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD create_documentation.
|
|
||||||
DATA: lt_lines TYPE tlinetab,
|
|
||||||
ls_line TYPE LINE OF tlinetab.
|
|
||||||
ls_line-tdline = 'Interface Line Doc'.
|
|
||||||
APPEND ls_line TO lt_lines.
|
|
||||||
|
|
||||||
given_an_interface_properties( ).
|
|
||||||
|
|
||||||
given_documentation_in_xml_as( lt_lines ).
|
|
||||||
|
|
||||||
when_deserializing( ).
|
|
||||||
|
|
||||||
then_docu_should_be_created( lt_lines ).
|
|
||||||
ENDMETHOD.
|
|
||||||
ENDCLASS.
|
|
646
src/zabapgit_unit_test_clas_intf.prog.abap
Normal file
646
src/zabapgit_unit_test_clas_intf.prog.abap
Normal file
|
@ -0,0 +1,646 @@
|
||||||
|
|
||||||
|
CLASS ltd_spy_oo_object DEFINITION FOR TESTING.
|
||||||
|
PUBLIC SECTION.
|
||||||
|
INTERFACES: lif_object_oriented_object.
|
||||||
|
DATA:
|
||||||
|
mv_package TYPE devclass,
|
||||||
|
mv_overwrite TYPE seox_boolean,
|
||||||
|
ms_interface_properties TYPE vseointerf,
|
||||||
|
ms_class_properties TYPE vseoclass,
|
||||||
|
ms_locals_key TYPE seoclskey,
|
||||||
|
mt_local_definitions TYPE rswsourcet,
|
||||||
|
mt_local_implementations TYPE rswsourcet,
|
||||||
|
mt_local_macros TYPE rswsourcet,
|
||||||
|
mt_local_test_classes TYPE rswsourcet,
|
||||||
|
mv_force TYPE seoflag,
|
||||||
|
ms_deserialize_key TYPE seoclskey,
|
||||||
|
mt_source TYPE ty_string_tt,
|
||||||
|
ms_item_to_activate TYPE ty_item,
|
||||||
|
mt_descriptions TYPE ty_seocompotx_tt,
|
||||||
|
ms_description_key TYPE seoclskey,
|
||||||
|
mv_text_pool_class_name TYPE seoclsname,
|
||||||
|
mt_text_pool TYPE textpool_table,
|
||||||
|
mv_text_pool_inserted TYPE abap_bool,
|
||||||
|
mt_sotr TYPE ty_sotr_tt,
|
||||||
|
mt_sotr_package TYPE devclass,
|
||||||
|
mv_docu_object_name TYPE dokhl-object,
|
||||||
|
mv_docu_language TYPE spras,
|
||||||
|
mt_docu_lines TYPE tlinetab,
|
||||||
|
mv_get_includes_called TYPE abap_bool.
|
||||||
|
ENDCLASS.
|
||||||
|
CLASS ltd_spy_oo_object IMPLEMENTATION.
|
||||||
|
METHOD lif_object_oriented_object~create.
|
||||||
|
DATA lv_properties_structure_name TYPE string.
|
||||||
|
lv_properties_structure_name = cl_abap_typedescr=>describe_by_data( is_properties )->absolute_name.
|
||||||
|
IF lv_properties_structure_name = cl_abap_typedescr=>describe_by_data( ms_interface_properties )->absolute_name.
|
||||||
|
ms_interface_properties = is_properties.
|
||||||
|
ELSE.
|
||||||
|
ms_class_properties = is_properties.
|
||||||
|
ENDIF.
|
||||||
|
mv_package = iv_package.
|
||||||
|
mv_overwrite = iv_overwrite.
|
||||||
|
ENDMETHOD.
|
||||||
|
METHOD lif_object_oriented_object~generate_locals.
|
||||||
|
ms_locals_key = is_key.
|
||||||
|
mt_local_definitions = it_local_definitions.
|
||||||
|
mt_local_implementations = it_local_implementations.
|
||||||
|
mt_local_macros = it_local_macros.
|
||||||
|
mt_local_test_classes = it_local_test_classes.
|
||||||
|
mv_force = iv_force.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD lif_object_oriented_object~deserialize_source.
|
||||||
|
ms_deserialize_key = is_key.
|
||||||
|
mt_source = it_source.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD lif_object_oriented_object~add_to_activation_list.
|
||||||
|
ms_item_to_activate = is_item.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD lif_object_oriented_object~update_descriptions.
|
||||||
|
ms_description_key = is_key.
|
||||||
|
mt_descriptions = it_descriptions.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD lif_object_oriented_object~insert_text_pool.
|
||||||
|
mv_text_pool_inserted = abap_true.
|
||||||
|
mv_text_pool_class_name = iv_class_name.
|
||||||
|
mt_text_pool = it_text_pool.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = iv_language
|
||||||
|
exp = sy-langu ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD lif_object_oriented_object~create_sotr.
|
||||||
|
mt_sotr = it_sotr.
|
||||||
|
mt_sotr_package = iv_package.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD lif_object_oriented_object~create_documentation.
|
||||||
|
mv_docu_object_name = iv_object_name.
|
||||||
|
mv_docu_language = iv_language.
|
||||||
|
mt_docu_lines = it_lines.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD lif_object_oriented_object~get_includes.
|
||||||
|
APPEND 'dummy' TO rt_includes.
|
||||||
|
mv_get_includes_called = abap_true.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
CLASS ltd_fake_object_files DEFINITION FOR TESTING
|
||||||
|
INHERITING FROM lcl_objects_files.
|
||||||
|
PUBLIC SECTION.
|
||||||
|
METHODS constructor.
|
||||||
|
METHODS read_abap REDEFINITION.
|
||||||
|
DATA:
|
||||||
|
mt_sources TYPE seop_source_string,
|
||||||
|
mt_local_definitions TYPE seop_source_string,
|
||||||
|
mt_local_implementations TYPE seop_source_string,
|
||||||
|
mt_local_macros TYPE seop_source_string,
|
||||||
|
mt_local_test_classes TYPE seop_source_string.
|
||||||
|
ENDCLASS.
|
||||||
|
CLASS ltd_fake_object_files IMPLEMENTATION.
|
||||||
|
METHOD read_abap.
|
||||||
|
CASE iv_extra.
|
||||||
|
WHEN 'locals_def'.
|
||||||
|
rt_abap = mt_local_definitions.
|
||||||
|
WHEN 'locals_imp'.
|
||||||
|
rt_abap = mt_local_implementations.
|
||||||
|
WHEN 'macros'.
|
||||||
|
rt_abap = mt_local_macros.
|
||||||
|
WHEN 'testclasses'.
|
||||||
|
rt_abap = mt_local_test_classes.
|
||||||
|
WHEN OTHERS.
|
||||||
|
rt_abap = mt_sources.
|
||||||
|
RETURN.
|
||||||
|
ENDCASE.
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = iv_error
|
||||||
|
exp = abap_false ).
|
||||||
|
ENDMETHOD.
|
||||||
|
METHOD constructor.
|
||||||
|
DATA ls_empty_item TYPE ty_item.
|
||||||
|
super->constructor( ls_empty_item ).
|
||||||
|
APPEND 'source' TO me->mt_sources.
|
||||||
|
APPEND 'definition' TO me->mt_local_definitions.
|
||||||
|
APPEND 'implementation' TO me->mt_local_implementations.
|
||||||
|
APPEND 'macro' TO me->mt_local_macros.
|
||||||
|
APPEND 'test' TO me->mt_local_test_classes.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
CLASS ltc_oo_test DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.
|
||||||
|
PROTECTED SECTION.
|
||||||
|
DATA:
|
||||||
|
mo_spy_oo_object TYPE REF TO ltd_spy_oo_object,
|
||||||
|
mo_fake_object_files TYPE REF TO ltd_fake_object_files,
|
||||||
|
mo_xml_input TYPE REF TO lcl_xml_input,
|
||||||
|
mo_xml_out TYPE REF TO lcl_xml_output,
|
||||||
|
mo_oo_object TYPE REF TO lif_object,
|
||||||
|
ms_item TYPE ty_item.
|
||||||
|
METHODS: when_deserializing
|
||||||
|
RAISING
|
||||||
|
lcx_exception,
|
||||||
|
then_should_deserialize_source,
|
||||||
|
given_the_descriptions
|
||||||
|
IMPORTING
|
||||||
|
it_descriptions TYPE ty_seocompotx_tt
|
||||||
|
RAISING
|
||||||
|
lcx_exception,
|
||||||
|
then_shuld_update_descriptions
|
||||||
|
IMPORTING
|
||||||
|
it_descriptions TYPE ty_seocompotx_tt,
|
||||||
|
then_it_should_add_activation,
|
||||||
|
given_documentation_in_xml_as
|
||||||
|
IMPORTING
|
||||||
|
it_lines TYPE tlinetab
|
||||||
|
RAISING
|
||||||
|
lcx_exception,
|
||||||
|
then_docu_should_be_created
|
||||||
|
IMPORTING
|
||||||
|
it_lines TYPE tlinetab.
|
||||||
|
|
||||||
|
ENDCLASS.
|
||||||
|
CLASS ltc_oo_test IMPLEMENTATION.
|
||||||
|
|
||||||
|
METHOD then_docu_should_be_created.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mt_docu_lines
|
||||||
|
exp = it_lines ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mv_docu_object_name
|
||||||
|
exp = ms_item-obj_name ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mv_docu_language
|
||||||
|
exp = sy-langu ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD given_documentation_in_xml_as.
|
||||||
|
mo_xml_out->add(
|
||||||
|
iv_name = 'LINES'
|
||||||
|
ig_data = it_lines ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD then_it_should_add_activation.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->ms_item_to_activate
|
||||||
|
exp = ms_item ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD then_shuld_update_descriptions.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mt_descriptions
|
||||||
|
exp = it_descriptions ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->ms_description_key
|
||||||
|
exp = ms_item-obj_name ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD given_the_descriptions.
|
||||||
|
mo_xml_out->add(
|
||||||
|
iv_name = 'DESCRIPTIONS'
|
||||||
|
ig_data = it_descriptions ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD then_should_deserialize_source.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mt_source
|
||||||
|
exp = mo_fake_object_files->mt_sources ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->ms_deserialize_key
|
||||||
|
exp = ms_item-obj_name ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD when_deserializing.
|
||||||
|
CREATE OBJECT mo_xml_input
|
||||||
|
EXPORTING
|
||||||
|
iv_xml = mo_xml_out->render( ).
|
||||||
|
mo_oo_object->deserialize(
|
||||||
|
iv_package = 'package_name'
|
||||||
|
io_xml = mo_xml_input ).
|
||||||
|
ENDMETHOD.
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
CLASS ltcl_class_deserialization DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT
|
||||||
|
INHERITING FROM ltc_oo_test.
|
||||||
|
PRIVATE SECTION.
|
||||||
|
METHODS:
|
||||||
|
setup,
|
||||||
|
given_a_class_properties
|
||||||
|
RAISING
|
||||||
|
lcx_exception,
|
||||||
|
then_should_create_class,
|
||||||
|
then_it_should_generate_locals,
|
||||||
|
should_create_class FOR TESTING RAISING cx_static_check,
|
||||||
|
should_generate_locals FOR TESTING RAISING cx_static_check,
|
||||||
|
should_deserialize_source FOR TESTING RAISING cx_static_check,
|
||||||
|
should_update_descriptions FOR TESTING RAISING cx_static_check,
|
||||||
|
should_add_to_activation FOR TESTING RAISING cx_static_check,
|
||||||
|
no_text_pool_no_insert FOR TESTING RAISING cx_static_check,
|
||||||
|
insert_text_pool FOR TESTING RAISING cx_static_check,
|
||||||
|
create_stor_from_xml FOR TESTING RAISING cx_static_check,
|
||||||
|
create_documentation FOR TESTING RAISING cx_static_check.
|
||||||
|
DATA:
|
||||||
|
ms_class_properties TYPE vseoclass.
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
CLASS ltcl_class_deserialization IMPLEMENTATION.
|
||||||
|
METHOD setup.
|
||||||
|
CREATE OBJECT mo_fake_object_files.
|
||||||
|
CREATE OBJECT mo_spy_oo_object.
|
||||||
|
CREATE OBJECT mo_xml_out.
|
||||||
|
lth_oo_factory_injector=>inject( mo_spy_oo_object ).
|
||||||
|
|
||||||
|
ms_item-devclass = 'package_name'.
|
||||||
|
ms_item-obj_name = 'zcl_class'.
|
||||||
|
ms_item-obj_type = 'CLAS'.
|
||||||
|
|
||||||
|
CREATE OBJECT mo_oo_object TYPE lcl_object_clas
|
||||||
|
EXPORTING
|
||||||
|
is_item = ms_item
|
||||||
|
iv_language = sy-langu.
|
||||||
|
mo_oo_object->mo_files = mo_fake_object_files.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD should_create_class.
|
||||||
|
ms_class_properties-clsname = ms_item-obj_name.
|
||||||
|
|
||||||
|
given_a_class_properties( ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
then_should_create_class( ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD should_generate_locals.
|
||||||
|
given_a_class_properties( ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
then_it_should_generate_locals( ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD should_deserialize_source.
|
||||||
|
given_a_class_properties( ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
then_should_deserialize_source( ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD should_update_descriptions.
|
||||||
|
DATA:
|
||||||
|
ls_description TYPE seocompotx,
|
||||||
|
lt_descriptions TYPE ty_seocompotx_tt.
|
||||||
|
|
||||||
|
given_a_class_properties( ).
|
||||||
|
|
||||||
|
ls_description-clsname = ms_item-obj_name.
|
||||||
|
ls_description-cmpname = 'a_method'.
|
||||||
|
APPEND ls_description TO lt_descriptions.
|
||||||
|
given_the_descriptions( lt_descriptions ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
then_shuld_update_descriptions( lt_descriptions ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD should_add_to_activation.
|
||||||
|
given_a_class_properties( ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
then_it_should_add_activation( ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD given_a_class_properties.
|
||||||
|
mo_xml_out->add(
|
||||||
|
iv_name = 'VSEOCLASS'
|
||||||
|
ig_data = ms_class_properties ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD then_should_create_class.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->ms_class_properties
|
||||||
|
exp = ms_class_properties ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = mo_spy_oo_object->mv_overwrite
|
||||||
|
exp = abap_true ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mv_package
|
||||||
|
exp = 'package_name' ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD then_it_should_generate_locals.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->ms_locals_key
|
||||||
|
exp = ms_item-obj_name ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = mo_spy_oo_object->mv_force
|
||||||
|
exp = abap_true ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mt_local_definitions
|
||||||
|
exp = mo_fake_object_files->mt_local_definitions ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mt_local_implementations
|
||||||
|
exp = mo_fake_object_files->mt_local_implementations ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mt_local_macros
|
||||||
|
exp = mo_fake_object_files->mt_local_macros ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mt_local_test_classes
|
||||||
|
exp = mo_fake_object_files->mt_local_test_classes ).
|
||||||
|
ENDMETHOD.
|
||||||
|
METHOD no_text_pool_no_insert.
|
||||||
|
given_a_class_properties( ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = mo_spy_oo_object->mv_text_pool_inserted
|
||||||
|
exp = abap_false ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD insert_text_pool.
|
||||||
|
DATA: lt_pool_external TYPE textpool_table,
|
||||||
|
ls_pool_external TYPE ty_tpool.
|
||||||
|
ls_pool_external-id = 'ID'.
|
||||||
|
ls_pool_external-key = 'KEY'.
|
||||||
|
APPEND ls_pool_external TO lt_pool_external.
|
||||||
|
|
||||||
|
given_a_class_properties( ).
|
||||||
|
|
||||||
|
mo_xml_out->add(
|
||||||
|
iv_name = 'TPOOL'
|
||||||
|
ig_data = lt_pool_external ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mt_text_pool
|
||||||
|
exp = lt_pool_external ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mv_text_pool_class_name
|
||||||
|
exp = 'zcl_class' ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD create_stor_from_xml.
|
||||||
|
DATA:
|
||||||
|
lt_sotr TYPE ty_sotr_tt,
|
||||||
|
ls_sotr LIKE LINE OF lt_sotr.
|
||||||
|
|
||||||
|
given_a_class_properties( ).
|
||||||
|
|
||||||
|
ls_sotr-header-concept = 'HEADER'.
|
||||||
|
APPEND ls_sotr TO lt_sotr.
|
||||||
|
mo_xml_out->add(
|
||||||
|
iv_name = 'SOTR'
|
||||||
|
ig_data = lt_sotr ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mt_sotr
|
||||||
|
exp = lt_sotr ).
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mt_sotr_package
|
||||||
|
exp = 'package_name' ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD create_documentation.
|
||||||
|
DATA: lt_lines TYPE tlinetab,
|
||||||
|
ls_line TYPE LINE OF tlinetab.
|
||||||
|
ls_line-tdline = 'Class Line Doc'.
|
||||||
|
APPEND ls_line TO lt_lines.
|
||||||
|
|
||||||
|
given_a_class_properties( ).
|
||||||
|
|
||||||
|
given_documentation_in_xml_as( lt_lines ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
then_docu_should_be_created( lt_lines ).
|
||||||
|
ENDMETHOD.
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
CLASS ltcl_interface_deserialization DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT
|
||||||
|
INHERITING FROM ltc_oo_test.
|
||||||
|
PRIVATE SECTION.
|
||||||
|
METHODS:
|
||||||
|
setup,
|
||||||
|
given_an_interface_properties
|
||||||
|
RAISING
|
||||||
|
lcx_exception,
|
||||||
|
then_should_create_interface,
|
||||||
|
create_interface FOR TESTING RAISING cx_static_check,
|
||||||
|
update_descriptions FOR TESTING RAISING cx_static_check,
|
||||||
|
add_to_activation FOR TESTING RAISING cx_static_check,
|
||||||
|
deserialize_source FOR TESTING RAISING cx_static_check,
|
||||||
|
create_documentation FOR TESTING RAISING cx_static_check.
|
||||||
|
DATA:
|
||||||
|
ms_interface_properties TYPE vseointerf.
|
||||||
|
ENDCLASS.
|
||||||
|
CLASS ltcl_interface_deserialization IMPLEMENTATION.
|
||||||
|
METHOD setup.
|
||||||
|
CREATE OBJECT mo_fake_object_files.
|
||||||
|
CREATE OBJECT mo_spy_oo_object.
|
||||||
|
CREATE OBJECT mo_xml_out.
|
||||||
|
lth_oo_factory_injector=>inject( mo_spy_oo_object ).
|
||||||
|
|
||||||
|
ms_item-devclass = 'package_name'.
|
||||||
|
ms_item-obj_name = 'zif_interface'.
|
||||||
|
ms_item-obj_type = 'INTF'.
|
||||||
|
|
||||||
|
CREATE OBJECT mo_oo_object TYPE lcl_object_intf
|
||||||
|
EXPORTING
|
||||||
|
is_item = ms_item
|
||||||
|
iv_language = sy-langu.
|
||||||
|
mo_oo_object->mo_files = mo_fake_object_files.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD create_interface.
|
||||||
|
ms_interface_properties-clsname = ms_item-obj_name.
|
||||||
|
given_an_interface_properties( ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
then_should_create_interface( ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD update_descriptions.
|
||||||
|
DATA:
|
||||||
|
ls_description TYPE seocompotx,
|
||||||
|
lt_descriptions TYPE ty_seocompotx_tt.
|
||||||
|
|
||||||
|
given_an_interface_properties( ).
|
||||||
|
|
||||||
|
ls_description-clsname = ms_item-obj_name.
|
||||||
|
ls_description-cmpname = 'a_method'.
|
||||||
|
APPEND ls_description TO lt_descriptions.
|
||||||
|
given_the_descriptions( lt_descriptions ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
then_shuld_update_descriptions( lt_descriptions ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD add_to_activation.
|
||||||
|
given_an_interface_properties( ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
then_it_should_add_activation( ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD deserialize_source.
|
||||||
|
given_an_interface_properties( ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
then_should_deserialize_source( ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD given_an_interface_properties.
|
||||||
|
mo_xml_out->add(
|
||||||
|
iv_name = 'VSEOINTERF'
|
||||||
|
ig_data = ms_interface_properties ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD then_should_create_interface.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->ms_interface_properties
|
||||||
|
exp = ms_interface_properties ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals( act = mo_spy_oo_object->mv_overwrite
|
||||||
|
exp = abap_true ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mv_package
|
||||||
|
exp = 'package_name' ).
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD create_documentation.
|
||||||
|
DATA: lt_lines TYPE tlinetab,
|
||||||
|
ls_line TYPE LINE OF tlinetab.
|
||||||
|
ls_line-tdline = 'Interface Line Doc'.
|
||||||
|
APPEND ls_line TO lt_lines.
|
||||||
|
|
||||||
|
given_an_interface_properties( ).
|
||||||
|
|
||||||
|
given_documentation_in_xml_as( lt_lines ).
|
||||||
|
|
||||||
|
when_deserializing( ).
|
||||||
|
|
||||||
|
then_docu_should_be_created( lt_lines ).
|
||||||
|
ENDMETHOD.
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
CLASS ltcl_class_changed DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT
|
||||||
|
INHERITING FROM ltc_oo_test.
|
||||||
|
PRIVATE SECTION.
|
||||||
|
METHODS:
|
||||||
|
setup,
|
||||||
|
changed_by_call_get_includes FOR TESTING RAISING cx_static_check,
|
||||||
|
changed_since_call_get_include FOR TESTING RAISING cx_static_check.
|
||||||
|
|
||||||
|
ENDCLASS.
|
||||||
|
CLASS ltcl_class_changed IMPLEMENTATION.
|
||||||
|
METHOD setup.
|
||||||
|
CREATE OBJECT mo_fake_object_files.
|
||||||
|
CREATE OBJECT mo_spy_oo_object.
|
||||||
|
CREATE OBJECT mo_xml_out.
|
||||||
|
lth_oo_factory_injector=>inject( mo_spy_oo_object ).
|
||||||
|
|
||||||
|
ms_item-devclass = 'package_name'.
|
||||||
|
ms_item-obj_name = 'zcl_class'.
|
||||||
|
ms_item-obj_type = 'CLAS'.
|
||||||
|
|
||||||
|
CREATE OBJECT mo_oo_object TYPE lcl_object_clas
|
||||||
|
EXPORTING
|
||||||
|
is_item = ms_item
|
||||||
|
iv_language = sy-langu.
|
||||||
|
mo_oo_object->mo_files = mo_fake_object_files.
|
||||||
|
ENDMETHOD.
|
||||||
|
METHOD changed_by_call_get_includes.
|
||||||
|
DATA lv_username TYPE xubname.
|
||||||
|
lv_username = mo_oo_object->changed_by( ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mv_get_includes_called
|
||||||
|
exp = abap_true ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lv_username
|
||||||
|
exp = lcl_objects_super=>c_user_unknown ).
|
||||||
|
ENDMETHOD.
|
||||||
|
METHOD changed_since_call_get_include.
|
||||||
|
DATA lv_timestamp TYPE timestamp.
|
||||||
|
GET TIME STAMP FIELD lv_timestamp.
|
||||||
|
mo_oo_object->has_changed_since( lv_timestamp ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mv_get_includes_called
|
||||||
|
exp = abap_true ).
|
||||||
|
ENDMETHOD.
|
||||||
|
ENDCLASS.
|
||||||
|
CLASS ltcl_interface_changed DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT
|
||||||
|
INHERITING FROM ltc_oo_test.
|
||||||
|
PRIVATE SECTION.
|
||||||
|
METHODS:
|
||||||
|
setup,
|
||||||
|
changed_by_call_get_includes FOR TESTING RAISING cx_static_check,
|
||||||
|
changed_since_call_get_include FOR TESTING RAISING cx_static_check.
|
||||||
|
ENDCLASS.
|
||||||
|
CLASS ltcl_interface_changed IMPLEMENTATION.
|
||||||
|
METHOD setup.
|
||||||
|
CREATE OBJECT mo_fake_object_files.
|
||||||
|
CREATE OBJECT mo_spy_oo_object.
|
||||||
|
CREATE OBJECT mo_xml_out.
|
||||||
|
lth_oo_factory_injector=>inject( mo_spy_oo_object ).
|
||||||
|
|
||||||
|
ms_item-devclass = 'package_name'.
|
||||||
|
ms_item-obj_name = 'zif_interface'.
|
||||||
|
ms_item-obj_type = 'INTF'.
|
||||||
|
|
||||||
|
CREATE OBJECT mo_oo_object TYPE lcl_object_intf
|
||||||
|
EXPORTING
|
||||||
|
is_item = ms_item
|
||||||
|
iv_language = sy-langu.
|
||||||
|
mo_oo_object->mo_files = mo_fake_object_files.
|
||||||
|
ENDMETHOD.
|
||||||
|
METHOD changed_by_call_get_includes.
|
||||||
|
DATA lv_username TYPE xubname.
|
||||||
|
lv_username = mo_oo_object->changed_by( ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mv_get_includes_called
|
||||||
|
exp = abap_true ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lv_username
|
||||||
|
exp = lcl_objects_super=>c_user_unknown ).
|
||||||
|
ENDMETHOD.
|
||||||
|
METHOD changed_since_call_get_include.
|
||||||
|
DATA lv_timestamp TYPE timestamp.
|
||||||
|
GET TIME STAMP FIELD lv_timestamp.
|
||||||
|
mo_oo_object->has_changed_since( lv_timestamp ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = mo_spy_oo_object->mv_get_includes_called
|
||||||
|
exp = abap_true ).
|
||||||
|
ENDMETHOD.
|
||||||
|
ENDCLASS.
|
48
src/zabapgit_unit_test_clas_intf.prog.xml
Normal file
48
src/zabapgit_unit_test_clas_intf.prog.xml
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
|
||||||
|
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||||
|
<asx:values>
|
||||||
|
<PROGDIR>
|
||||||
|
<NAME>ZABAPGIT_UNIT_TEST_CLAS_INTF</NAME>
|
||||||
|
<STATE>A</STATE>
|
||||||
|
<SQLX/>
|
||||||
|
<EDTX/>
|
||||||
|
<VARCL>X</VARCL>
|
||||||
|
<DBAPL>S</DBAPL>
|
||||||
|
<DBNA>D$</DBNA>
|
||||||
|
<CLAS/>
|
||||||
|
<TYPE/>
|
||||||
|
<OCCURS/>
|
||||||
|
<SUBC>I</SUBC>
|
||||||
|
<APPL/>
|
||||||
|
<SECU/>
|
||||||
|
<CNAM/>
|
||||||
|
<CDAT>0000-00-00</CDAT>
|
||||||
|
<UNAM/>
|
||||||
|
<UDAT>0000-00-00</UDAT>
|
||||||
|
<VERN/>
|
||||||
|
<LEVL/>
|
||||||
|
<RSTAT/>
|
||||||
|
<RMAND/>
|
||||||
|
<RLOAD/>
|
||||||
|
<FIXPT>X</FIXPT>
|
||||||
|
<SSET/>
|
||||||
|
<SDATE>0000-00-00</SDATE>
|
||||||
|
<STIME/>
|
||||||
|
<IDATE>0000-00-00</IDATE>
|
||||||
|
<ITIME/>
|
||||||
|
<LDBNAME>D$S</LDBNAME>
|
||||||
|
<UCCHECK>X</UCCHECK>
|
||||||
|
</PROGDIR>
|
||||||
|
<TPOOL>
|
||||||
|
<item>
|
||||||
|
<ID>R</ID>
|
||||||
|
<KEY/>
|
||||||
|
<ENTRY>Unit tests for classes and interfaces objecst</ENTRY>
|
||||||
|
<LENGTH>45</LENGTH>
|
||||||
|
<SPLIT/>
|
||||||
|
</item>
|
||||||
|
</TPOOL>
|
||||||
|
</asx:values>
|
||||||
|
</asx:abap>
|
||||||
|
</abapGit>
|
Loading…
Reference in New Issue
Block a user