Skip to content

Commit

Permalink
downport, #12
Browse files Browse the repository at this point in the history
  • Loading branch information
larshp committed Oct 11, 2016
1 parent 5d5f40e commit 807144f
Showing 1 changed file with 90 additions and 84 deletions.
174 changes: 90 additions & 84 deletions zcl_abapgit_object_by_sobj.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ CLASS ltcl_bobf DEFINITION FINAL FOR TESTING
CLASS-METHODS class_setup RAISING cx_static_check.
CLASS-METHODS class_teardown RAISING cx_static_check.

CLASS-DATA gv_ut_bo_key TYPE /bobf/conf_key.
CLASS-DATA gv_root_node_key TYPE /bobf/conf_key.
* TYPE /bobf/conf_key does not exist in old ABAP systems
TYPES: ty_conf_key TYPE x LENGTH 16.

CLASS-DATA gv_ut_bo_key TYPE ty_conf_key.
CLASS-DATA gv_root_node_key TYPE ty_conf_key.

METHODS:
t001_import_bo FOR TESTING RAISING cx_static_check,
Expand Down Expand Up @@ -228,13 +231,12 @@ CLASS ltcl_bobf IMPLEMENTATION.
cl_aunit_assert=>fail(
msg = 'BOPF not available in this system. Test cannot be executed'
level = cl_aunit_assert=>tolerable
quit = cl_aunit_assert=>class
).
quit = cl_aunit_assert=>class ).
ENDTRY.

* purge existing object if it exists from previous execution
go_bridge->delete_object_on_db( ).


* create ddic-structures which are needed by the BOPF runtime lateron
DATA ls_dd02v TYPE dd02v.
DATA lt_dd03p TYPE dd03ptab.
Expand Down Expand Up @@ -450,23 +452,24 @@ CLASS ltcl_bobf IMPLEMENTATION.
METHOD t001_import_bo.
go_bridge->import_object( me->get_bobf_container( ) ).

SELECT COUNT(*) FROM /bobf/act_conf WHERE name = 'ZABAPGIT_UNITTEST'.
SELECT COUNT(*) FROM ('/BOBF/ACT_CONF') WHERE name = 'ZABAPGIT_UNITTEST'.
cl_abap_unit_assert=>assert_equals(
msg = 'Database content of /BOBF/ACT_CONF found deviated'
exp = 7
act = sy-dbcnt ).

* check whether the BOPF designtime accepted the imported object
DATA lo_conf TYPE REF TO /bobf/if_frw_configuration.

gv_ut_bo_key = /bobf/cl_frw_factory=>query_bo( iv_bo_name = 'ZABAPGIT_UNITTEST' ).
cl_abap_unit_assert=>assert_not_initial( gv_ut_bo_key ).

lo_conf = /bobf/cl_frw_factory=>get_configuration( gv_ut_bo_key ).
cl_abap_unit_assert=>assert_not_initial( lo_conf ).

gv_root_node_key = lo_conf->query_node( iv_node_name = 'ROOT' ).
cl_abap_unit_assert=>assert_not_initial( gv_root_node_key ).
* TODO, COMMENTED, DOWNPORT
* DATA lo_conf TYPE REF TO /bobf/if_frw_configuration.
*
* gv_ut_bo_key = /bobf/cl_frw_factory=>query_bo( iv_bo_name = 'ZABAPGIT_UNITTEST' ).
* cl_abap_unit_assert=>assert_not_initial( gv_ut_bo_key ).
*
* lo_conf = /bobf/cl_frw_factory=>get_configuration( gv_ut_bo_key ).
* cl_abap_unit_assert=>assert_not_initial( lo_conf ).
*
* gv_root_node_key = lo_conf->query_node( iv_node_name = 'ROOT' ).
* cl_abap_unit_assert=>assert_not_initial( gv_root_node_key ).
ENDMETHOD.

METHOD t002_check_existence.
Expand Down Expand Up @@ -507,80 +510,83 @@ CLASS ltcl_bobf IMPLEMENTATION.

METHOD t100_use_imported_object.


DATA lo_mo_serv_mgr TYPE REF TO /bobf/if_tra_service_manager.
lo_mo_serv_mgr = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( gv_ut_bo_key ).

DATA lt_modification TYPE /bobf/t_frw_modification.
DATA ls_modification LIKE LINE OF lt_modification.

ls_modification-node = gv_root_node_key.
ls_modification-change_mode = /bobf/if_frw_c=>sc_modify_create.
ls_modification-key = /bobf/cl_frw_factory=>get_new_key( ).
INSERT ls_modification INTO TABLE lt_modification.

lo_mo_serv_mgr->modify(
lt_modification " Changes
).

DATA lt_key TYPE /bobf/t_frw_key.
DATA ls_key LIKE LINE OF lt_key.
DATA lt_failed_ley LIKE lt_key.

ls_key-key = ls_modification-key.
INSERT ls_key INTO TABLE lt_key.

DATA lr_root_node_tab TYPE REF TO data.
CREATE DATA lr_root_node_tab TYPE ('ZAGUT_T_ROOT').
FIELD-SYMBOLS <lt_root> TYPE ANY TABLE.
ASSIGN lr_root_node_tab->* TO <lt_root>.

lo_mo_serv_mgr->retrieve(
EXPORTING
iv_node_key = gv_root_node_key " Node
it_key = lt_key " Key Table
IMPORTING
et_data = <lt_root>
et_failed_key = lt_failed_ley " Key Table
).

cl_aunit_assert=>assert_not_initial(
act = <lt_root> " Actual Data Object
msg = |The BO instance which has been created previously could not be retrieved|
).

cl_aunit_assert=>assert_initial(
act = lt_failed_ley " Actual Data Object
msg = |The BO instance which has been created previously could not be retrieved|
).

* Save the transaction in order to be able to see the DB access in the log ;)
DATA lv_save_rejected TYPE abap_bool.
/bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( )->save(
IMPORTING
ev_rejected = lv_save_rejected " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')
).

cl_aunit_assert=>assert_initial(
act = lv_save_rejected " Actual Data Object
msg = |The BO instance could not be persisted|
).

DATA lv_key_from_db TYPE /bobf/conf_key.
CLEAR lv_key_from_db.
SELECT SINGLE db_key FROM ('ZAGUT_D_ROOT') INTO lv_key_from_db WHERE db_key = ls_key-key.
cl_aunit_assert=>assert_not_initial(
act = <lt_root> " Actual Data Object
msg = |The BO instance which has been saved previously could not be SELECTed|
).
* TODO, COMMENTED, DOWNPORT
* DATA lo_mo_serv_mgr TYPE REF TO /bobf/if_tra_service_manager.
* lo_mo_serv_mgr = /bobf/cl_tra_serv_mgr_factory=>get_service_manager( gv_ut_bo_key ).
*
* DATA lt_modification TYPE /bobf/t_frw_modification.
* DATA ls_modification LIKE LINE OF lt_modification.
*
* ls_modification-node = gv_root_node_key.
* ls_modification-change_mode = /bobf/if_frw_c=>sc_modify_create.
* ls_modification-key = /bobf/cl_frw_factory=>get_new_key( ).
* INSERT ls_modification INTO TABLE lt_modification.
*
* lo_mo_serv_mgr->modify(
* lt_modification " Changes
* ).
*
* DATA lt_key TYPE /bobf/t_frw_key.
* DATA ls_key LIKE LINE OF lt_key.
* DATA lt_failed_ley LIKE lt_key.
*
* ls_key-key = ls_modification-key.
* INSERT ls_key INTO TABLE lt_key.
*
* DATA lr_root_node_tab TYPE REF TO data.
* CREATE DATA lr_root_node_tab TYPE ('ZAGUT_T_ROOT').
* FIELD-SYMBOLS <lt_root> TYPE ANY TABLE.
* ASSIGN lr_root_node_tab->* TO <lt_root>.
*
* lo_mo_serv_mgr->retrieve(
* EXPORTING
* iv_node_key = gv_root_node_key " Node
* it_key = lt_key " Key Table
* IMPORTING
* et_data = <lt_root>
* et_failed_key = lt_failed_ley " Key Table
* ).
*
* cl_aunit_assert=>assert_not_initial(
* act = <lt_root> " Actual Data Object
* msg = |The BO instance which has been created previously could not be retrieved|
* ).
*
* cl_aunit_assert=>assert_initial(
* act = lt_failed_ley " Actual Data Object
* msg = |The BO instance which has been created previously could not be retrieved|
* ).
*
** Save the transaction in order to be able to see the DB access in the log ;)
* DATA lv_save_rejected TYPE abap_bool.
* /bobf/cl_tra_trans_mgr_factory=>get_transaction_manager( )->save(
* IMPORTING
* ev_rejected = lv_save_rejected " Data element for domain BOOLE: TRUE (='X') and FALSE (=' ')
* ).
*
* cl_aunit_assert=>assert_initial(
* act = lv_save_rejected " Actual Data Object
* msg = |The BO instance could not be persisted|
* ).
*
* DATA lv_key_from_db TYPE /bobf/conf_key.
* CLEAR lv_key_from_db.
* SELECT SINGLE db_key FROM ('ZAGUT_D_ROOT') INTO lv_key_from_db WHERE db_key = ls_key-key.
* cl_aunit_assert=>assert_not_initial(
* act = <lt_root> " Actual Data Object
* msg = |The BO instance which has been saved previously could not be SELECTed|
* ).

ENDMETHOD.

METHOD t200_delete_object.
go_bridge->delete_object_on_db( ).

SELECT COUNT(*) FROM /bobf/act_conf WHERE name = 'ZABAPGIT_UNITTEST'.
cl_abap_unit_assert=>assert_equals( msg = 'Database content of /BOBF/ACT_CONF found deviated' exp = 0 act = sy-dbcnt ).
SELECT COUNT(*) FROM ('/BOBF/ACT_CONF') WHERE name = 'ZABAPGIT_UNITTEST'.
cl_abap_unit_assert=>assert_equals(
msg = 'Database content of /BOBF/ACT_CONF found deviated'
exp = 0
act = sy-dbcnt ).

ENDMETHOD.

Expand Down

0 comments on commit 807144f

Please sign in to comment.