diff --git a/package-lock.json b/package-lock.json index 1a33cf07..0ad44f05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,16 +9,16 @@ "version": "1.0.0", "license": "MIT", "devDependencies": { - "@abaplint/cli": "^2.105.15", + "@abaplint/cli": "^2.105.16", "@abaplint/database-sqlite": "^2.7.144", - "@abaplint/runtime": "^2.7.154", - "@abaplint/transpiler-cli": "^2.7.154" + "@abaplint/runtime": "^2.7.156", + "@abaplint/transpiler-cli": "^2.7.156" } }, "node_modules/@abaplint/cli": { - "version": "2.105.15", - "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.105.15.tgz", - "integrity": "sha512-HTGiHC/jJHhHpv3GX8DC2lmm6xCYYNP5jPAhSEcmgulZx5v4nrn8TEX+qyPUJa9nc+8C3q+vAPFah0SeKyP2AA==", + "version": "2.105.16", + "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.105.16.tgz", + "integrity": "sha512-EalQp5oL71AOe2gkX2l7ekvI2aaoVl6XgfVHtbYBWy5xGaDc7CICH48uPkRv7EU6BMO79+BioECBEwLl9wXWqQ==", "dev": true, "bin": { "abaplint": "abaplint" @@ -40,21 +40,21 @@ } }, "node_modules/@abaplint/runtime": { - "version": "2.7.154", - "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.7.154.tgz", - "integrity": "sha512-/oiTLcCkZOCQIez9X8I42OPsCQiP/FXGwnyS/paUfAr32m5f3YTcwZW0X0YMPlc4q5JvtjEtd8cCgJ8olV6sxA==", + "version": "2.7.156", + "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.7.156.tgz", + "integrity": "sha512-VfqLkHJ2DZ+ShuVqCxu2UeSnBBtCRwS54kVnyVHTDEmcbA7CGYhmHVoO04778IqONlqwjvfL/ZW1G9+eNMaqSA==", "dev": true, "dependencies": { - "temporal-polyfill": "^0.2.0" + "temporal-polyfill": "^0.2.1" }, "funding": { "url": "https://github.com/sponsors/larshp" } }, "node_modules/@abaplint/transpiler-cli": { - "version": "2.7.154", - "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.7.154.tgz", - "integrity": "sha512-GqqdmjtWd6yM7pFBbxFzj48kel91aO5pogTTGxb1FAtJVeczL4xOddUVo+2YCvXQFMC5xyu52DVP6KP/9HCXeA==", + "version": "2.7.156", + "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.7.156.tgz", + "integrity": "sha512-QTNFiZNU6fCY9UOuVOHo9mHBWC+oN+QuHj/u+Re9XchbnvPRspP/q7CPKyh7uM0cxNkaKIOruFJV2haDRVqAbg==", "dev": true, "bin": { "abap_transpile": "abap_transpile" @@ -70,9 +70,9 @@ "dev": true }, "node_modules/temporal-polyfill": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.2.0.tgz", - "integrity": "sha512-ra5tfISsVwUlDk9fhvEiIuvfBshV7jDtHYxmC8ACLIVV91MYoVlOBE1RpIrDjqGTYkCrZf0mWhgAW9XSOVPuGw==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.2.1.tgz", + "integrity": "sha512-JaCnPrUY0NkisdARpjbYIZ1P1Nt/Bhe7gRxEcboKJZnMkjtjLnmpDjQ8jM6mtpm/KUt4B3ijkkphlX2wKybX1g==", "dev": true, "dependencies": { "temporal-spec": "^0.2.0" @@ -87,9 +87,9 @@ }, "dependencies": { "@abaplint/cli": { - "version": "2.105.15", - "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.105.15.tgz", - "integrity": "sha512-HTGiHC/jJHhHpv3GX8DC2lmm6xCYYNP5jPAhSEcmgulZx5v4nrn8TEX+qyPUJa9nc+8C3q+vAPFah0SeKyP2AA==", + "version": "2.105.16", + "resolved": "https://registry.npmjs.org/@abaplint/cli/-/cli-2.105.16.tgz", + "integrity": "sha512-EalQp5oL71AOe2gkX2l7ekvI2aaoVl6XgfVHtbYBWy5xGaDc7CICH48uPkRv7EU6BMO79+BioECBEwLl9wXWqQ==", "dev": true }, "@abaplint/database-sqlite": { @@ -102,18 +102,18 @@ } }, "@abaplint/runtime": { - "version": "2.7.154", - "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.7.154.tgz", - "integrity": "sha512-/oiTLcCkZOCQIez9X8I42OPsCQiP/FXGwnyS/paUfAr32m5f3YTcwZW0X0YMPlc4q5JvtjEtd8cCgJ8olV6sxA==", + "version": "2.7.156", + "resolved": "https://registry.npmjs.org/@abaplint/runtime/-/runtime-2.7.156.tgz", + "integrity": "sha512-VfqLkHJ2DZ+ShuVqCxu2UeSnBBtCRwS54kVnyVHTDEmcbA7CGYhmHVoO04778IqONlqwjvfL/ZW1G9+eNMaqSA==", "dev": true, "requires": { - "temporal-polyfill": "^0.2.0" + "temporal-polyfill": "^0.2.1" } }, "@abaplint/transpiler-cli": { - "version": "2.7.154", - "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.7.154.tgz", - "integrity": "sha512-GqqdmjtWd6yM7pFBbxFzj48kel91aO5pogTTGxb1FAtJVeczL4xOddUVo+2YCvXQFMC5xyu52DVP6KP/9HCXeA==", + "version": "2.7.156", + "resolved": "https://registry.npmjs.org/@abaplint/transpiler-cli/-/transpiler-cli-2.7.156.tgz", + "integrity": "sha512-QTNFiZNU6fCY9UOuVOHo9mHBWC+oN+QuHj/u+Re9XchbnvPRspP/q7CPKyh7uM0cxNkaKIOruFJV2haDRVqAbg==", "dev": true }, "sql.js": { @@ -123,9 +123,9 @@ "dev": true }, "temporal-polyfill": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.2.0.tgz", - "integrity": "sha512-ra5tfISsVwUlDk9fhvEiIuvfBshV7jDtHYxmC8ACLIVV91MYoVlOBE1RpIrDjqGTYkCrZf0mWhgAW9XSOVPuGw==", + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/temporal-polyfill/-/temporal-polyfill-0.2.1.tgz", + "integrity": "sha512-JaCnPrUY0NkisdARpjbYIZ1P1Nt/Bhe7gRxEcboKJZnMkjtjLnmpDjQ8jM6mtpm/KUt4B3ijkkphlX2wKybX1g==", "dev": true, "requires": { "temporal-spec": "^0.2.0" diff --git a/package.json b/package.json index d4ee037c..e2d2ccba 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,9 @@ }, "homepage": "https://github.com/abap2UI5/abap2UI5#readme", "devDependencies": { - "@abaplint/cli": "^2.105.15", + "@abaplint/cli": "^2.105.16", "@abaplint/database-sqlite": "^2.7.144", - "@abaplint/runtime": "^2.7.154", - "@abaplint/transpiler-cli": "^2.7.154" + "@abaplint/runtime": "^2.7.156", + "@abaplint/transpiler-cli": "^2.7.156" } } diff --git a/src/01/01/z2ui5_cl_util_api.clas.abap b/src/01/01/z2ui5_cl_util_api.clas.abap index ed497189..df437dbb 100644 --- a/src/01/01/z2ui5_cl_util_api.clas.abap +++ b/src/01/01/z2ui5_cl_util_api.clas.abap @@ -67,7 +67,7 @@ CLASS z2ui5_cl_util_api DEFINITION IMPORTING val TYPE any RETURNING - VALUE(result) TYPE REF TO object. + VALUE(result) TYPE REF TO data. CLASS-METHODS conv_get_as_data_ref IMPORTING @@ -432,7 +432,6 @@ CLASS z2ui5_cl_util_api IMPLEMENTATION. ENDMETHOD. - METHOD conv_copy_ref_data. FIELD-SYMBOLS TYPE data. @@ -731,10 +730,12 @@ CLASS z2ui5_cl_util_api IMPLEMENTATION. METHOD rtti_check_ref_data. TRY. - cl_abap_typedescr=>describe_by_data_ref( val ). + DATA(lo_typdescr) = cl_abap_typedescr=>describe_by_data( val ). + DATA(lo_ref) = CAST cl_abap_refdescr( lo_typdescr ) ##NEEDED. result = abap_true. CATCH cx_root. ENDTRY. + ENDMETHOD. diff --git a/src/01/01/z2ui5_cl_util_api.clas.testclasses.abap b/src/01/01/z2ui5_cl_util_api.clas.testclasses.abap index 6be8ed71..febfbd11 100644 --- a/src/01/01/z2ui5_cl_util_api.clas.testclasses.abap +++ b/src/01/01/z2ui5_cl_util_api.clas.testclasses.abap @@ -1,714 +1,749 @@ -*CLASS ltcl_test_app DEFINITION FOR TESTING. -* -* PUBLIC SECTION. -* -* INTERFACES if_serializable_object. -* -* TYPES: -* BEGIN OF ty_row, -* title TYPE string, -* value TYPE string, -* descr TYPE string, -* icon TYPE string, -* info TYPE string, -* selected TYPE abap_bool, -* checkbox TYPE abap_bool, -* END OF ty_row. -* -* CONSTANTS sv_status TYPE string VALUE `test` ##NEEDED. -* -* CLASS-DATA sv_var TYPE string. -* CLASS-DATA ss_tab TYPE ty_row. -* CLASS-DATA st_tab TYPE STANDARD TABLE OF ty_row WITH EMPTY KEY. -* CLASS-METHODS class_constructor. -* -* DATA mv_val TYPE string ##NEEDED. -* DATA ms_tab TYPE ty_row ##NEEDED. -* DATA mt_tab TYPE STANDARD TABLE OF ty_row WITH EMPTY KEY ##NEEDED. -* -* PROTECTED SECTION. -* PRIVATE SECTION. -*ENDCLASS. -* -*CLASS ltcl_test_app IMPLEMENTATION. -* -* METHOD class_constructor. -* -* sv_var = 1. -* ss_tab = VALUE #( ). -* st_tab = VALUE #( ). -* -* ENDMETHOD. -*ENDCLASS. -* -*CLASS ltcl_unit_test_abap_api DEFINITION FINAL FOR TESTING -* DURATION SHORT -* RISK LEVEL HARMLESS. -* -* PRIVATE SECTION. -* -* METHODS check_input -* IMPORTING -* val TYPE data -* RETURNING -* VALUE(result) TYPE abap_bool. -* -* METHODS test_assign FOR TESTING RAISING cx_static_check. -* METHODS test_eledescr_rel_name FOR TESTING RAISING cx_static_check. -* METHODS test_classdescr FOR TESTING RAISING cx_static_check. -* METHODS test_substring_after FOR TESTING RAISING cx_static_check. -* METHODS test_substring_before FOR TESTING RAISING cx_static_check. -* METHODS test_string_shift FOR TESTING RAISING cx_static_check. -* METHODS test_string_replace FOR TESTING RAISING cx_static_check. -* METHODS test_raise_error FOR TESTING RAISING cx_static_check. -* METHODS test_xsdbool FOR TESTING RAISING cx_static_check. -* METHODS test_xsdbool_nested FOR TESTING RAISING cx_static_check. -* -*ENDCLASS. -* -*CLASS ltcl_unit_test DEFINITION FINAL FOR TESTING -* DURATION MEDIUM -* RISK LEVEL HARMLESS. -* -* PRIVATE SECTION. -* -* METHODS test_create FOR TESTING RAISING cx_static_check. -* -* METHODS test_boolean_abap_2_json FOR TESTING RAISING cx_static_check. -* METHODS test_boolean_check FOR TESTING RAISING cx_static_check. -* -* METHODS test_c_trim FOR TESTING RAISING cx_static_check. -* METHODS test_c_trim_lower FOR TESTING RAISING cx_static_check. -* METHODS test_c_trim_upper FOR TESTING RAISING cx_static_check. -* METHODS test_c_trim_horizontal_tab FOR TESTING RAISING cx_static_check. -* -* METHODS test_time_get_timestampl FOR TESTING RAISING cx_static_check. -* METHODS test_time_substract_seconds FOR TESTING RAISING cx_static_check. -* METHODS test_func_get_user_tech FOR TESTING RAISING cx_static_check. -* -* METHODS test_rtti_get_classname_by_ref FOR TESTING RAISING cx_static_check. -* METHODS test_rtti_get_type_name FOR TESTING RAISING cx_static_check. -* METHODS test_rtti_get_type_kind FOR TESTING RAISING cx_static_check. -* METHODS test_rtti_check_type_kind FOR TESTING RAISING cx_static_check. -* METHODS test_rtti_get_t_attri_by_obj FOR TESTING RAISING cx_static_check. -* METHODS test_rtti_get_t_comp_by_struc FOR TESTING RAISING cx_static_check. -* -* METHODS test_trans_json_any_2__w_struc FOR TESTING RAISING cx_static_check. -* METHODS test_trans_xml_any_2__w_obj FOR TESTING RAISING cx_static_check. -* METHODS test_trans_xml_any_2__w_data FOR TESTING RAISING cx_static_check. -* METHODS test_trans_xml_2_any__w_obj FOR TESTING RAISING cx_static_check. -* METHODS test_trans_xml_2_any__w_data FOR TESTING RAISING cx_static_check. -* -* METHODS test_url_param_create_url FOR TESTING RAISING cx_static_check. -* METHODS test_url_param_get FOR TESTING RAISING cx_static_check. -* METHODS test_url_param_get_tab FOR TESTING RAISING cx_static_check. -* METHODS test_url_param_set FOR TESTING RAISING cx_static_check. -* -* METHODS test_x_check_raise FOR TESTING RAISING cx_static_check. -* METHODS test_x_check_raise_not FOR TESTING RAISING cx_static_check. -* METHODS test_x_raise FOR TESTING RAISING cx_static_check. -* METHODS test_check_unassign_inital FOR TESTING RAISING cx_static_check. -* METHODS conv_copy_ref_data FOR TESTING RAISING cx_static_check. -* -*ENDCLASS. -* -*CLASS ltcl_unit_test_abap_api IMPLEMENTATION. -* -* -* METHOD test_assign. -* -* DATA(lo_app) = NEW ltcl_test_app( ). -* FIELD-SYMBOLS TYPE any. -* -* lo_app->mv_val = `ABC`. -* -* DATA(lv_assign) = `LO_APP->` && 'MV_VAL'. -* ASSIGN (lv_assign) TO . -* -* cl_abap_unit_assert=>assert_equals( -* act = -* exp = `ABC` ). -* -* ENDMETHOD. -* -* -* METHOD test_classdescr. -* -* DATA(lo_app) = NEW ltcl_test_app( ). -* -* DATA(lt_attri) = CAST cl_abap_classdescr( cl_abap_objectdescr=>describe_by_object_ref( lo_app ) )->attributes. -* -* DATA(lv_test) = lt_attri[ name = `MS_TAB` ]. -* lv_test = lt_attri[ name = `MT_TAB` ]. -* lv_test = lt_attri[ name = `MV_VAL` ]. -* lv_test = lt_attri[ name = `SS_TAB` ]. -* lv_test = lt_attri[ name = `ST_TAB` ]. -* lv_test = lt_attri[ name = `SV_STATUS` ]. -* lv_test = lt_attri[ name = `SV_VAR` ]. -* -* ENDMETHOD. -* -* METHOD test_eledescr_rel_name. -* -* DATA(lo_ele) = CAST cl_abap_elemdescr( cl_abap_elemdescr=>describe_by_data( abap_true ) ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lo_ele->get_relative_name( ) -* exp = `ABAP_BOOL` ). -* -* ENDMETHOD. -* -* METHOD test_substring_after. -* -* cl_abap_unit_assert=>assert_equals( -* act = substring_after( val = 'this is a string' sub = 'a' ) -* exp = ` string` ). -* -* ENDMETHOD. -* -* METHOD test_substring_before. -* -* cl_abap_unit_assert=>assert_equals( -* act = substring_before( val = 'this is a string' sub = 'a' ) -* exp = `this is ` ). -* -* ENDMETHOD. -* -* METHOD test_string_shift. -* -* cl_abap_unit_assert=>assert_equals( -* act = shift_left( shift_right( val = ` string ` sub = ` ` ) ) -* exp = `string` ). -* -* ENDMETHOD. -* -* METHOD test_string_replace. -* -* DATA(lv_search) = replace( val = `one two three` -* sub = `two` -* with = 'ABC' -* occ = 0 ) ##NEEDED. -* -* cl_abap_unit_assert=>assert_equals( -* act = replace( val = `one two three` sub = `two` with = 'ABC' occ = 0 ) -* exp = `one ABC three` ). -* -* ENDMETHOD. -* -* METHOD test_raise_error. -* -* TRY. -* IF 1 = 1. -* RAISE EXCEPTION TYPE z2ui5_cx_util_error. -* ENDIF. -* cl_abap_unit_assert=>fail( ). -* -* CATCH z2ui5_cx_util_error INTO DATA(lx). -* cl_abap_unit_assert=>assert_bound( lx ). -* ENDTRY. -* -* ENDMETHOD. -* -* METHOD test_xsdbool. -* -* DATA(lv_xsdbool) = xsdbool( 1 = 1 ). -* IF lv_xsdbool = abap_false. -* cl_abap_unit_assert=>assert_equals( -* act = lv_xsdbool -* exp = abap_false ). -* ENDIF. -* -* IF xsdbool( 1 = 1 ) = abap_false. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* ENDMETHOD. -* -* METHOD test_xsdbool_nested. -* -* DATA(lv_xsdbool) = check_input( xsdbool( 1 = 1 ) ). -* IF lv_xsdbool = abap_false. -* cl_abap_unit_assert=>assert_equals( -* act = lv_xsdbool -* exp = abap_false ). -* ENDIF. -* -* IF check_input( abap_false ). -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF check_input( xsdbool( 1 = 1 ) ) = abap_false. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* ENDMETHOD. -* -* METHOD check_input. -* -* result = val. -* -* ENDMETHOD. -* -*ENDCLASS. -* -*CLASS ltcl_unit_test IMPLEMENTATION. -* -* METHOD test_boolean_check. -* -* DATA(lv_bool) = xsdbool( 1 = 1 ). -* cl_abap_unit_assert=>assert_equals( -* act = z2ui5_cl_util=>boolean_check_by_data( lv_bool ) -* exp = abap_true ). -* -* lv_bool = xsdbool( 1 = 2 ). -* cl_abap_unit_assert=>assert_equals( -* act = z2ui5_cl_util=>boolean_check_by_data( lv_bool ) -* exp = abap_true ). -* -* cl_abap_unit_assert=>assert_equals( -* act = z2ui5_cl_util=>boolean_check_by_data( abap_true ) -* exp = abap_true ). -* -* cl_abap_unit_assert=>assert_equals( -* act = z2ui5_cl_util=>boolean_check_by_data( abap_false ) -* exp = abap_true ). -* -* ENDMETHOD. -* -* METHOD test_create. -* -* DATA(lo_test) = NEW z2ui5_cl_util( ) ##NEEDED. -* -* ENDMETHOD. -* -* METHOD test_rtti_get_classname_by_ref. -* -* DATA(lo_test) = NEW z2ui5_cl_util( ). -* DATA(lv_name) = z2ui5_cl_util=>rtti_get_classname_by_ref( lo_test ). -* cl_abap_unit_assert=>assert_equals( exp = `Z2UI5_CL_UTIL` -* act = lv_name ). -* -* DATA(lo_test2) = NEW ltcl_test_app( ). -* DATA(lv_name2) = z2ui5_cl_util=>rtti_get_classname_by_ref( lo_test2 ). -* cl_abap_unit_assert=>assert_equals( exp = `LTCL_TEST_APP` -* act = lv_name2 ). -* -* ENDMETHOD. -* -* METHOD test_check_unassign_inital. -* -* DATA(lv_test) = `test`. -* DATA(lr_test) = REF #( lv_test ). -* -* cl_abap_unit_assert=>assert_false( z2ui5_cl_util_api=>check_unassign_inital( lr_test ) ). -* -* CLEAR lv_test. -* cl_abap_unit_assert=>assert_true( z2ui5_cl_util_api=>check_unassign_inital( lr_test ) ). -* -* ENDMETHOD. -* -* METHOD conv_copy_ref_data. -* -* DATA(lv_test) = `test`. -* -* DATA(lr_test2) = z2ui5_cl_util_api=>conv_copy_ref_data( from = lv_test ). -* -* ASSIGN lr_test2->* TO FIELD-SYMBOL(). -* cl_abap_unit_assert=>assert_equals( -* act = -* exp = lv_test ). -* -* ENDMETHOD. -* -* METHOD test_boolean_abap_2_json. -* -* cl_abap_unit_assert=>assert_equals( -* act = z2ui5_cl_util=>boolean_abap_2_json( `{ABCD}` ) -* exp = `{ABCD}`). -* -* ENDMETHOD. -* -* METHOD test_time_get_timestampl. -* -* DATA(lv_time) = z2ui5_cl_util=>time_get_timestampl( ). -* -* DATA(lv_time2) = z2ui5_cl_util=>time_substract_seconds( -* time = lv_time -* seconds = 60 * 60 * 4 ). -* -* IF lv_time IS INITIAL OR lv_time2 IS INITIAL. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF lv_time < lv_time2. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* ENDMETHOD. -* -* METHOD test_time_substract_seconds. -* -* DATA(lv_time) = z2ui5_cl_util=>time_get_timestampl( ). -* DATA(lv_time2) = z2ui5_cl_util=>time_get_timestampl( ). -* -* IF lv_time IS INITIAL OR lv_time2 IS INITIAL. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF lv_time2 < lv_time. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* ENDMETHOD. -* -* METHOD test_c_trim. -* -* cl_abap_unit_assert=>assert_equals( -* act = z2ui5_cl_util=>c_trim( ` JsadfHHs ` ) -* exp = `JsadfHHs` ). -* -* ENDMETHOD. -* -* METHOD test_c_trim_lower. -* -* cl_abap_unit_assert=>assert_equals( -* act = z2ui5_cl_util=>c_trim_lower( ` JsadfHHs ` ) -* exp = `jsadfhhs` ). -* -* ENDMETHOD. -* -* METHOD test_c_trim_upper. -* -* cl_abap_unit_assert=>assert_equals( -* act = z2ui5_cl_util=>c_trim_upper( ` JsadfHHs ` ) -* exp = `JSADFHHS` ). -* -* ENDMETHOD. -* -* METHOD test_func_get_user_tech. -* -* cl_abap_unit_assert=>assert_equals( -* act = sy-uname -* exp = z2ui5_cl_util=>user_get_tech( ) ). -* -* cl_abap_unit_assert=>assert_not_initial( z2ui5_cl_util=>user_get_tech( ) ). -* -* ENDMETHOD. -* -* METHOD test_x_raise. -* -* TRY. -* z2ui5_cl_util=>x_raise( ). -* cl_abap_unit_assert=>fail( ). -* CATCH cx_root. -* ENDTRY. -* -* ENDMETHOD. -* -* -* METHOD test_x_check_raise. -* -* TRY. -* z2ui5_cl_util=>x_check_raise( xsdbool( 1 = 1 ) ). -* cl_abap_unit_assert=>fail( ). -* CATCH cx_root. -* ENDTRY. -* -* TRY. -* z2ui5_cl_util=>x_check_raise( xsdbool( 1 = 3 ) ). -* CATCH cx_root. -* cl_abap_unit_assert=>fail( ). -* ENDTRY. -* -* ENDMETHOD. -* -* -* METHOD test_trans_json_any_2__w_struc. -* -* TYPES: -* BEGIN OF ty_row, -* title TYPE string, -* value TYPE string, -* selected TYPE abap_bool, -* END OF ty_row. -* DATA(ls_row) = VALUE ty_row( title = `test` ). -* -* cl_abap_unit_assert=>assert_equals( -* act = z2ui5_cl_util=>json_stringify( ls_row ) -* exp = `{"selected":false,"title":"test","value":""}` ). -* -* ENDMETHOD. -* -* -* METHOD test_url_param_create_url. -* -* DATA(lt_param) = z2ui5_cl_util=>url_param_get_tab( `https://url.com/rvice_for_ui?sap-client=100&app_start=z2ui5_cl_app_hello_world` ). -* DATA(lv_url) = z2ui5_cl_util=>url_param_create_url( lt_param ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_url -* exp = `sap-client=100&app_start=z2ui5_cl_app_hello_world` ). -* -* ENDMETHOD. -* -* METHOD test_url_param_get. -* -* DATA(lv_param) = z2ui5_cl_util=>url_param_get( -* val = `app_start` -* url = `https://url.com/rvice_for_ui?sap-client=100&app_start=z2ui5_cl_app_hello_world` ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_param -* exp = `z2ui5_cl_app_hello_world` ). -* -* ENDMETHOD. -* -* METHOD test_url_param_get_tab. -* -* DATA(lt_param) = z2ui5_cl_util=>url_param_get_tab( `https://url.com/rvice_for_ui?sap-client=100&app_start=z2ui5_cl_app_hello_world` ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lt_param[ n = `sap-client` ]-v -* exp = `100` ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lt_param[ n = `app_start` ]-v -* exp = `z2ui5_cl_app_hello_world` ). -* -* ENDMETHOD. -* -* METHOD test_url_param_set. -* -* DATA(lv_param) = z2ui5_cl_util=>url_param_set( -* name = `app_start` -* value = `z2ui5_cl_app_hello_world2` -* url = `https://url.com/rvice_for_ui?sap-client=100&app_start=z2ui5_cl_app_hello_world` ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_param -* exp = `sap-client=100&app_start=z2ui5_cl_app_hello_world2` ). -* -* ENDMETHOD. -* -* METHOD test_x_check_raise_not. -* -* TRY. -* z2ui5_cl_util=>x_check_raise( xsdbool( 1 = 2 ) ). -* CATCH z2ui5_cx_util_error. -* cl_abap_unit_assert=>fail( ). -* ENDTRY. -* ENDMETHOD. -* -* METHOD test_rtti_get_type_name. -* -* DATA(lv_xsdbool) = VALUE xsdboolean( ). -* DATA(lv_name) = z2ui5_cl_util=>rtti_get_type_name( lv_xsdbool ). -* cl_abap_unit_assert=>assert_equals( -* act = lv_name -* exp = `XSDBOOLEAN` ). -* -* ENDMETHOD. -* -* METHOD test_rtti_get_type_kind. -* -* DATA(lv_string) = VALUE string( ). -* -* DATA(lv_type_kind) = z2ui5_cl_util=>rtti_get_type_kind( lv_string ). -* DATA lr_string TYPE REF TO string. -* cl_abap_unit_assert=>assert_equals( -* act = lv_type_kind -* exp = cl_abap_typedescr=>typekind_string ). -* -* -* CREATE DATA lr_string. -* lv_type_kind = z2ui5_cl_util=>rtti_get_type_kind( lr_string ). -* cl_abap_unit_assert=>assert_equals( -* act = lv_type_kind -* exp = cl_abap_typedescr=>typekind_dref ). -* -* ENDMETHOD. -* -* METHOD test_rtti_check_type_kind. -* -* DATA(lv_string) = VALUE string( ). -* DATA lr_string TYPE REF TO string. -* cl_abap_unit_assert=>assert_equals( -* act = z2ui5_cl_util=>rtti_check_type_kind_dref( lv_string ) -* exp = abap_false ). -* -* -* CREATE DATA lr_string. -* cl_abap_unit_assert=>assert_equals( -* act = z2ui5_cl_util=>rtti_check_type_kind_dref( lr_string ) -* exp = abap_true ). -* -* ENDMETHOD. -* -* METHOD test_rtti_get_t_attri_by_obj. -* -* DATA(lo_obj) = NEW ltcl_test_app( ). -* DATA(lt_attri) = z2ui5_cl_util=>rtti_get_t_attri_by_oref( lo_obj ). -* -* IF lines( lt_attri ) <> 7. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF NOT line_exists( lt_attri[ name = `MS_TAB` ] ). -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF NOT line_exists( lt_attri[ name = `SS_TAB` type_kind = `v` ] ). -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF NOT line_exists( lt_attri[ name = `SV_VAR` type_kind = `g` is_class = abap_true ] ). -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF NOT line_exists( lt_attri[ name = `SV_STATUS` type_kind = `g` is_class = abap_true is_constant = `X` ] ). -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* ENDMETHOD. -* -* METHOD test_rtti_get_t_comp_by_struc. -* -* TYPES: -* BEGIN OF ty_row, -* title TYPE string, -* value TYPE string, -* descr TYPE string, -* icon TYPE string, -* info TYPE string, -* selected TYPE abap_bool, -* checkbox TYPE abap_bool, -* END OF ty_row. -* -* DATA(ls_row) = VALUE ty_row( ). -* -* DATA(lt_comp) = z2ui5_cl_util=>rtti_get_t_attri_by_struc( ls_row ). -* -* IF lines( lt_comp ) <> 7. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF NOT line_exists( lt_comp[ name = `TITLE` ] ). -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF NOT line_exists( lt_comp[ name = `VALUE` ] ). -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF NOT line_exists( lt_comp[ name = `SELECTED` ] ). -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF NOT line_exists( lt_comp[ name = `CHECKBOX` ] ). -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* DATA(ls_title) = lt_comp[ 1 ]. -* -* IF ls_title-type->type_kind <> `g`. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* ENDMETHOD. -* -* METHOD test_trans_xml_any_2__w_obj. -* -* DATA(lo_obj) = NEW ltcl_test_app( ). -* DATA(lv_xml) = z2ui5_cl_util=>xml_stringify( lo_obj ). -* -* IF lv_xml IS INITIAL. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* ENDMETHOD. -* -* METHOD test_trans_xml_2_any__w_obj. -* -* DATA(lo_obj) = NEW ltcl_test_app( ). -* DATA(lv_xml) = z2ui5_cl_util=>xml_stringify( lo_obj ). -* -* CLEAR lo_obj. -* z2ui5_cl_util=>xml_parse( -* EXPORTING -* xml = lv_xml -* IMPORTING -* any = lo_obj ). -* -* IF lo_obj IS NOT BOUND. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* ENDMETHOD. -* -* METHOD test_trans_xml_any_2__w_data. -* -* TYPES: -* BEGIN OF ty_row, -* title TYPE string, -* value TYPE string, -* descr TYPE string, -* icon TYPE string, -* info TYPE string, -* selected TYPE abap_bool, -* checkbox TYPE abap_bool, -* END OF ty_row. -* -* DATA(ls_row) = VALUE ty_row( ). -* ls_row-value = `test`. -* -* DATA(lv_xml) = z2ui5_cl_util=>xml_stringify( ls_row ). -* -* IF lv_xml IS INITIAL. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* ENDMETHOD. -* -* METHOD test_trans_xml_2_any__w_data. -* -* TYPES: -* BEGIN OF ty_row, -* title TYPE string, -* value TYPE string, -* descr TYPE string, -* icon TYPE string, -* info TYPE string, -* selected TYPE abap_bool, -* checkbox TYPE abap_bool, -* END OF ty_row. -* -* DATA(ls_row) = VALUE ty_row( ). -* DATA(ls_row2) = VALUE ty_row( ). -* ls_row-value = `test`. -* -* DATA(lv_xml) = z2ui5_cl_util=>xml_stringify( ls_row ). -* -* z2ui5_cl_util=>xml_parse( -* EXPORTING -* xml = lv_xml -* IMPORTING -* any = ls_row2 ). -* -* cl_abap_unit_assert=>assert_equals( -* act = ls_row -* exp = ls_row2 ). -* -* ENDMETHOD. -* -* -* METHOD test_c_trim_horizontal_tab. -* -* IF z2ui5_cl_util=>c_trim( |{ cl_abap_char_utilities=>horizontal_tab }| -* && |JsadfHHs| -* && |{ cl_abap_char_utilities=>horizontal_tab }| ) <> `JsadfHHs`. -* cl_abap_unit_assert=>fail( ). -* -* ENDIF. -* -* ENDMETHOD. -* -*ENDCLASS. +CLASS ltcl_test_app DEFINITION FOR TESTING. + + PUBLIC SECTION. + + INTERFACES if_serializable_object. + + TYPES: + BEGIN OF ty_row, + title TYPE string, + value TYPE string, + descr TYPE string, + icon TYPE string, + info TYPE string, + selected TYPE abap_bool, + checkbox TYPE abap_bool, + END OF ty_row. + + CONSTANTS sv_status TYPE string VALUE `test` ##NEEDED. + + CLASS-DATA sv_var TYPE string. + CLASS-DATA ss_tab TYPE ty_row. + CLASS-DATA st_tab TYPE STANDARD TABLE OF ty_row WITH EMPTY KEY. + CLASS-METHODS class_constructor. + + DATA mv_val TYPE string ##NEEDED. + DATA ms_tab TYPE ty_row ##NEEDED. + DATA mt_tab TYPE STANDARD TABLE OF ty_row WITH EMPTY KEY ##NEEDED. + + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + +CLASS ltcl_test_app IMPLEMENTATION. + + METHOD class_constructor. + + sv_var = 1. + ss_tab = VALUE #( ). + st_tab = VALUE #( ). + + ENDMETHOD. +ENDCLASS. + +CLASS ltcl_unit_test_abap_api DEFINITION FINAL FOR TESTING + DURATION SHORT + RISK LEVEL HARMLESS. + + PRIVATE SECTION. + + METHODS check_input + IMPORTING + val TYPE data + RETURNING + VALUE(result) TYPE abap_bool. + + METHODS test_assign FOR TESTING RAISING cx_static_check. + METHODS test_eledescr_rel_name FOR TESTING RAISING cx_static_check. + METHODS test_classdescr FOR TESTING RAISING cx_static_check. + METHODS test_substring_after FOR TESTING RAISING cx_static_check. + METHODS test_substring_before FOR TESTING RAISING cx_static_check. + METHODS test_string_shift FOR TESTING RAISING cx_static_check. + METHODS test_string_replace FOR TESTING RAISING cx_static_check. + METHODS test_raise_error FOR TESTING RAISING cx_static_check. + METHODS test_xsdbool FOR TESTING RAISING cx_static_check. + METHODS test_xsdbool_nested FOR TESTING RAISING cx_static_check. + +ENDCLASS. + +CLASS ltcl_unit_test DEFINITION FINAL FOR TESTING + DURATION MEDIUM + RISK LEVEL HARMLESS. + + PRIVATE SECTION. + + METHODS test_create FOR TESTING RAISING cx_static_check. + + METHODS test_boolean_abap_2_json FOR TESTING RAISING cx_static_check. + METHODS test_boolean_check FOR TESTING RAISING cx_static_check. + + METHODS test_c_trim FOR TESTING RAISING cx_static_check. + METHODS test_c_trim_lower FOR TESTING RAISING cx_static_check. + METHODS test_c_trim_upper FOR TESTING RAISING cx_static_check. + METHODS test_c_trim_horizontal_tab FOR TESTING RAISING cx_static_check. + + METHODS test_time_get_timestampl FOR TESTING RAISING cx_static_check. + METHODS test_time_substract_seconds FOR TESTING RAISING cx_static_check. + METHODS test_func_get_user_tech FOR TESTING RAISING cx_static_check. + + METHODS test_rtti_get_classname_by_ref FOR TESTING RAISING cx_static_check. + METHODS test_rtti_get_type_name FOR TESTING RAISING cx_static_check. + METHODS test_rtti_get_type_kind FOR TESTING RAISING cx_static_check. + METHODS test_rtti_check_type_kind FOR TESTING RAISING cx_static_check. + METHODS test_rtti_get_t_attri_by_obj FOR TESTING RAISING cx_static_check. + METHODS test_rtti_get_t_comp_by_struc FOR TESTING RAISING cx_static_check. + + METHODS test_trans_json_any_2__w_struc FOR TESTING RAISING cx_static_check. + METHODS test_trans_xml_any_2__w_obj FOR TESTING RAISING cx_static_check. + METHODS test_trans_xml_any_2__w_data FOR TESTING RAISING cx_static_check. + METHODS test_trans_xml_2_any__w_obj FOR TESTING RAISING cx_static_check. + METHODS test_trans_xml_2_any__w_data FOR TESTING RAISING cx_static_check. + + METHODS test_url_param_create_url FOR TESTING RAISING cx_static_check. + METHODS test_url_param_get FOR TESTING RAISING cx_static_check. + METHODS test_url_param_get_tab FOR TESTING RAISING cx_static_check. + METHODS test_url_param_set FOR TESTING RAISING cx_static_check. + + METHODS test_x_check_raise FOR TESTING RAISING cx_static_check. + METHODS test_x_check_raise_not FOR TESTING RAISING cx_static_check. + METHODS test_x_raise FOR TESTING RAISING cx_static_check. + METHODS test_check_unassign_inital FOR TESTING RAISING cx_static_check. + METHODS conv_copy_ref_data FOR TESTING RAISING cx_static_check. + METHODS rtti_check_ref_data FOR TESTING RAISING cx_static_check. + METHODS test_check_bound_a_not_inital FOR TESTING RAISING cx_static_check. + +ENDCLASS. + +CLASS ltcl_unit_test_abap_api IMPLEMENTATION. + + + METHOD test_assign. + + DATA(lo_app) = NEW ltcl_test_app( ). + FIELD-SYMBOLS TYPE any. + + lo_app->mv_val = `ABC`. + + DATA(lv_assign) = `LO_APP->` && 'MV_VAL'. + ASSIGN (lv_assign) TO . + + cl_abap_unit_assert=>assert_equals( + act = + exp = `ABC` ). + + ENDMETHOD. + + + METHOD test_classdescr. + + DATA(lo_app) = NEW ltcl_test_app( ). + + DATA(lt_attri) = CAST cl_abap_classdescr( cl_abap_objectdescr=>describe_by_object_ref( lo_app ) )->attributes. + + DATA(lv_test) = lt_attri[ name = `MS_TAB` ]. + lv_test = lt_attri[ name = `MT_TAB` ]. + lv_test = lt_attri[ name = `MV_VAL` ]. + lv_test = lt_attri[ name = `SS_TAB` ]. + lv_test = lt_attri[ name = `ST_TAB` ]. + lv_test = lt_attri[ name = `SV_STATUS` ]. + lv_test = lt_attri[ name = `SV_VAR` ]. + + ENDMETHOD. + + METHOD test_eledescr_rel_name. + + DATA(lo_ele) = CAST cl_abap_elemdescr( cl_abap_elemdescr=>describe_by_data( abap_true ) ). + + cl_abap_unit_assert=>assert_equals( + act = lo_ele->get_relative_name( ) + exp = `ABAP_BOOL` ). + + ENDMETHOD. + + METHOD test_substring_after. + + cl_abap_unit_assert=>assert_equals( + act = substring_after( val = 'this is a string' sub = 'a' ) + exp = ` string` ). + + ENDMETHOD. + + METHOD test_substring_before. + + cl_abap_unit_assert=>assert_equals( + act = substring_before( val = 'this is a string' sub = 'a' ) + exp = `this is ` ). + + ENDMETHOD. + + METHOD test_string_shift. + + cl_abap_unit_assert=>assert_equals( + act = shift_left( shift_right( val = ` string ` sub = ` ` ) ) + exp = `string` ). + + ENDMETHOD. + + METHOD test_string_replace. + + DATA(lv_search) = replace( val = `one two three` + sub = `two` + with = 'ABC' + occ = 0 ) ##NEEDED. + + cl_abap_unit_assert=>assert_equals( + act = replace( val = `one two three` sub = `two` with = 'ABC' occ = 0 ) + exp = `one ABC three` ). + + ENDMETHOD. + + METHOD test_raise_error. + + TRY. + IF 1 = 1. + RAISE EXCEPTION TYPE z2ui5_cx_util_error. + ENDIF. + cl_abap_unit_assert=>fail( ). + + CATCH z2ui5_cx_util_error INTO DATA(lx). + cl_abap_unit_assert=>assert_bound( lx ). + ENDTRY. + + ENDMETHOD. + + METHOD test_xsdbool. + + DATA(lv_xsdbool) = xsdbool( 1 = 1 ). + IF lv_xsdbool = abap_false. + cl_abap_unit_assert=>assert_equals( + act = lv_xsdbool + exp = abap_false ). + ENDIF. + + IF xsdbool( 1 = 1 ) = abap_false. + cl_abap_unit_assert=>fail( ). + ENDIF. + + ENDMETHOD. + + METHOD test_xsdbool_nested. + + DATA(lv_xsdbool) = check_input( xsdbool( 1 = 1 ) ). + IF lv_xsdbool = abap_false. + cl_abap_unit_assert=>assert_equals( + act = lv_xsdbool + exp = abap_false ). + ENDIF. + + IF check_input( abap_false ). + cl_abap_unit_assert=>fail( ). + ENDIF. + + IF check_input( xsdbool( 1 = 1 ) ) = abap_false. + cl_abap_unit_assert=>fail( ). + ENDIF. + + ENDMETHOD. + + METHOD check_input. + + result = val. + + ENDMETHOD. + +ENDCLASS. + +CLASS ltcl_unit_test IMPLEMENTATION. + + METHOD test_boolean_check. + + DATA(lv_bool) = xsdbool( 1 = 1 ). + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util=>boolean_check_by_data( lv_bool ) + exp = abap_true ). + + lv_bool = xsdbool( 1 = 2 ). + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util=>boolean_check_by_data( lv_bool ) + exp = abap_true ). + + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util=>boolean_check_by_data( abap_true ) + exp = abap_true ). + + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util=>boolean_check_by_data( abap_false ) + exp = abap_true ). + + ENDMETHOD. + + METHOD test_create. + + DATA(lo_test) = NEW z2ui5_cl_util( ) ##NEEDED. + + ENDMETHOD. + + METHOD test_rtti_get_classname_by_ref. + + DATA(lo_test) = NEW z2ui5_cl_util( ). + DATA(lv_name) = z2ui5_cl_util=>rtti_get_classname_by_ref( lo_test ). + cl_abap_unit_assert=>assert_equals( exp = `Z2UI5_CL_UTIL` + act = lv_name ). + + DATA(lo_test2) = NEW ltcl_test_app( ). + DATA(lv_name2) = z2ui5_cl_util=>rtti_get_classname_by_ref( lo_test2 ). + cl_abap_unit_assert=>assert_equals( exp = `LTCL_TEST_APP` + act = lv_name2 ). + + ENDMETHOD. + + METHOD test_check_bound_a_not_inital. + + DATA(lv_test) = `test`. + DATA(lr_test) = REF #( lv_test ). + + cl_abap_unit_assert=>assert_true( z2ui5_cl_util_api=>check_bound_a_not_inital( lr_test ) ). + CLEAR lv_test. + cl_abap_unit_assert=>assert_false( z2ui5_cl_util_api=>check_bound_a_not_inital( lr_test ) ). + CLEAR lr_test. + cl_abap_unit_assert=>assert_false( z2ui5_cl_util_api=>check_bound_a_not_inital( lr_test ) ). + + ENDMETHOD. + + METHOD test_check_unassign_inital. + + DATA(lv_test) = `test`. + DATA(lr_test) = REF #( lv_test ). + + cl_abap_unit_assert=>assert_false( z2ui5_cl_util_api=>check_unassign_inital( lr_test ) ). + + CLEAR lv_test. + cl_abap_unit_assert=>assert_true( z2ui5_cl_util_api=>check_unassign_inital( lr_test ) ). + + ENDMETHOD. + + METHOD rtti_check_ref_data. + + DATA(lv_test) = `test`. + DATA lr_data TYPE REF TO data. + GET REFERENCE OF lv_test INTO lr_data. + + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util_api=>rtti_check_ref_data( lr_data ) + exp = abap_true ). + + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util_api=>rtti_check_ref_data( lv_test ) + exp = abap_false ). + + ENDMETHOD. + + METHOD conv_copy_ref_data. + + DATA(lv_test) = `test`. + DATA lr_data TYPE REF TO data. + GET REFERENCE OF lv_test INTO lr_data. + + DATA(lr_test2) = z2ui5_cl_util_api=>conv_copy_ref_data( lr_data ). + + FIELD-SYMBOLS TYPE data. + ASSIGN lr_test2->* TO . + + cl_abap_unit_assert=>assert_equals( + act = + exp = lv_test ). + + ENDMETHOD. + + METHOD test_boolean_abap_2_json. + + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util=>boolean_abap_2_json( `{ABCD}` ) + exp = `{ABCD}`). + + ENDMETHOD. + + METHOD test_time_get_timestampl. + + DATA(lv_time) = z2ui5_cl_util=>time_get_timestampl( ). + + DATA(lv_time2) = z2ui5_cl_util=>time_substract_seconds( + time = lv_time + seconds = 60 * 60 * 4 ). + + IF lv_time IS INITIAL OR lv_time2 IS INITIAL. + cl_abap_unit_assert=>fail( ). + ENDIF. + + IF lv_time < lv_time2. + cl_abap_unit_assert=>fail( ). + ENDIF. + + ENDMETHOD. + + METHOD test_time_substract_seconds. + + DATA(lv_time) = z2ui5_cl_util=>time_get_timestampl( ). + DATA(lv_time2) = z2ui5_cl_util=>time_get_timestampl( ). + + IF lv_time IS INITIAL OR lv_time2 IS INITIAL. + cl_abap_unit_assert=>fail( ). + ENDIF. + + IF lv_time2 < lv_time. + cl_abap_unit_assert=>fail( ). + ENDIF. + + ENDMETHOD. + + METHOD test_c_trim. + + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util=>c_trim( ` JsadfHHs ` ) + exp = `JsadfHHs` ). + + ENDMETHOD. + + METHOD test_c_trim_lower. + + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util=>c_trim_lower( ` JsadfHHs ` ) + exp = `jsadfhhs` ). + + ENDMETHOD. + + METHOD test_c_trim_upper. + + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util=>c_trim_upper( ` JsadfHHs ` ) + exp = `JSADFHHS` ). + + ENDMETHOD. + + METHOD test_func_get_user_tech. + + cl_abap_unit_assert=>assert_equals( + act = sy-uname + exp = z2ui5_cl_util=>user_get_tech( ) ). + + cl_abap_unit_assert=>assert_not_initial( z2ui5_cl_util=>user_get_tech( ) ). + + ENDMETHOD. + + METHOD test_x_raise. + + TRY. + z2ui5_cl_util=>x_raise( ). + cl_abap_unit_assert=>fail( ). + CATCH cx_root. + ENDTRY. + + ENDMETHOD. + + + METHOD test_x_check_raise. + + TRY. + z2ui5_cl_util=>x_check_raise( xsdbool( 1 = 1 ) ). + cl_abap_unit_assert=>fail( ). + CATCH cx_root. + ENDTRY. + + TRY. + z2ui5_cl_util=>x_check_raise( xsdbool( 1 = 3 ) ). + CATCH cx_root. + cl_abap_unit_assert=>fail( ). + ENDTRY. + + ENDMETHOD. + + + METHOD test_trans_json_any_2__w_struc. + + TYPES: + BEGIN OF ty_row, + title TYPE string, + value TYPE string, + selected TYPE abap_bool, + END OF ty_row. + DATA(ls_row) = VALUE ty_row( title = `test` ). + + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util=>json_stringify( ls_row ) + exp = `{"selected":false,"title":"test","value":""}` ). + + ENDMETHOD. + + + METHOD test_url_param_create_url. + + DATA(lt_param) = z2ui5_cl_util=>url_param_get_tab( `https://url.com/rvice_for_ui?sap-client=100&app_start=z2ui5_cl_app_hello_world` ). + DATA(lv_url) = z2ui5_cl_util=>url_param_create_url( lt_param ). + + cl_abap_unit_assert=>assert_equals( + act = lv_url + exp = `sap-client=100&app_start=z2ui5_cl_app_hello_world` ). + + ENDMETHOD. + + METHOD test_url_param_get. + + DATA(lv_param) = z2ui5_cl_util=>url_param_get( + val = `app_start` + url = `https://url.com/rvice_for_ui?sap-client=100&app_start=z2ui5_cl_app_hello_world` ). + + cl_abap_unit_assert=>assert_equals( + act = lv_param + exp = `z2ui5_cl_app_hello_world` ). + + ENDMETHOD. + + METHOD test_url_param_get_tab. + + DATA(lt_param) = z2ui5_cl_util=>url_param_get_tab( `https://url.com/rvice_for_ui?sap-client=100&app_start=z2ui5_cl_app_hello_world` ). + + cl_abap_unit_assert=>assert_equals( + act = lt_param[ n = `sap-client` ]-v + exp = `100` ). + + cl_abap_unit_assert=>assert_equals( + act = lt_param[ n = `app_start` ]-v + exp = `z2ui5_cl_app_hello_world` ). + + ENDMETHOD. + + METHOD test_url_param_set. + + DATA(lv_param) = z2ui5_cl_util=>url_param_set( + name = `app_start` + value = `z2ui5_cl_app_hello_world2` + url = `https://url.com/rvice_for_ui?sap-client=100&app_start=z2ui5_cl_app_hello_world` ). + + cl_abap_unit_assert=>assert_equals( + act = lv_param + exp = `sap-client=100&app_start=z2ui5_cl_app_hello_world2` ). + + ENDMETHOD. + + METHOD test_x_check_raise_not. + + TRY. + z2ui5_cl_util=>x_check_raise( xsdbool( 1 = 2 ) ). + CATCH z2ui5_cx_util_error. + cl_abap_unit_assert=>fail( ). + ENDTRY. + ENDMETHOD. + + METHOD test_rtti_get_type_name. + + DATA(lv_xsdbool) = VALUE xsdboolean( ). + DATA(lv_name) = z2ui5_cl_util=>rtti_get_type_name( lv_xsdbool ). + cl_abap_unit_assert=>assert_equals( + act = lv_name + exp = `XSDBOOLEAN` ). + + ENDMETHOD. + + METHOD test_rtti_get_type_kind. + + DATA(lv_string) = VALUE string( ). + + DATA(lv_type_kind) = z2ui5_cl_util=>rtti_get_type_kind( lv_string ). + DATA lr_string TYPE REF TO string. + cl_abap_unit_assert=>assert_equals( + act = lv_type_kind + exp = cl_abap_typedescr=>typekind_string ). + + + CREATE DATA lr_string. + lv_type_kind = z2ui5_cl_util=>rtti_get_type_kind( lr_string ). + cl_abap_unit_assert=>assert_equals( + act = lv_type_kind + exp = cl_abap_typedescr=>typekind_dref ). + + ENDMETHOD. + + METHOD test_rtti_check_type_kind. + + DATA(lv_string) = VALUE string( ). + DATA lr_string TYPE REF TO string. + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util=>rtti_check_type_kind_dref( lv_string ) + exp = abap_false ). + + + CREATE DATA lr_string. + cl_abap_unit_assert=>assert_equals( + act = z2ui5_cl_util=>rtti_check_type_kind_dref( lr_string ) + exp = abap_true ). + + ENDMETHOD. + + METHOD test_rtti_get_t_attri_by_obj. + + DATA(lo_obj) = NEW ltcl_test_app( ). + DATA(lt_attri) = z2ui5_cl_util=>rtti_get_t_attri_by_oref( lo_obj ). + + IF lines( lt_attri ) <> 7. + cl_abap_unit_assert=>fail( ). + ENDIF. + + IF NOT line_exists( lt_attri[ name = `MS_TAB` ] ). + cl_abap_unit_assert=>fail( ). + ENDIF. + + IF NOT line_exists( lt_attri[ name = `SS_TAB` type_kind = `v` ] ). + cl_abap_unit_assert=>fail( ). + ENDIF. + + IF NOT line_exists( lt_attri[ name = `SV_VAR` type_kind = `g` is_class = abap_true ] ). + cl_abap_unit_assert=>fail( ). + ENDIF. + + IF NOT line_exists( lt_attri[ name = `SV_STATUS` type_kind = `g` is_class = abap_true is_constant = `X` ] ). + cl_abap_unit_assert=>fail( ). + ENDIF. + + ENDMETHOD. + + METHOD test_rtti_get_t_comp_by_struc. + + TYPES: + BEGIN OF ty_row, + title TYPE string, + value TYPE string, + descr TYPE string, + icon TYPE string, + info TYPE string, + selected TYPE abap_bool, + checkbox TYPE abap_bool, + END OF ty_row. + + DATA(ls_row) = VALUE ty_row( ). + + DATA(lt_comp) = z2ui5_cl_util=>rtti_get_t_attri_by_struc( ls_row ). + + IF lines( lt_comp ) <> 7. + cl_abap_unit_assert=>fail( ). + ENDIF. + + IF NOT line_exists( lt_comp[ name = `TITLE` ] ). + cl_abap_unit_assert=>fail( ). + ENDIF. + + IF NOT line_exists( lt_comp[ name = `VALUE` ] ). + cl_abap_unit_assert=>fail( ). + ENDIF. + + IF NOT line_exists( lt_comp[ name = `SELECTED` ] ). + cl_abap_unit_assert=>fail( ). + ENDIF. + + IF NOT line_exists( lt_comp[ name = `CHECKBOX` ] ). + cl_abap_unit_assert=>fail( ). + ENDIF. + + DATA(ls_title) = lt_comp[ 1 ]. + + IF ls_title-type->type_kind <> `g`. + cl_abap_unit_assert=>fail( ). + ENDIF. + + ENDMETHOD. + + METHOD test_trans_xml_any_2__w_obj. + + DATA(lo_obj) = NEW ltcl_test_app( ). + DATA(lv_xml) = z2ui5_cl_util=>xml_stringify( lo_obj ). + + IF lv_xml IS INITIAL. + cl_abap_unit_assert=>fail( ). + ENDIF. + ENDMETHOD. + + METHOD test_trans_xml_2_any__w_obj. + + DATA(lo_obj) = NEW ltcl_test_app( ). + DATA(lv_xml) = z2ui5_cl_util=>xml_stringify( lo_obj ). + + CLEAR lo_obj. + z2ui5_cl_util=>xml_parse( + EXPORTING + xml = lv_xml + IMPORTING + any = lo_obj ). + + IF lo_obj IS NOT BOUND. + cl_abap_unit_assert=>fail( ). + ENDIF. + + ENDMETHOD. + + METHOD test_trans_xml_any_2__w_data. + + TYPES: + BEGIN OF ty_row, + title TYPE string, + value TYPE string, + descr TYPE string, + icon TYPE string, + info TYPE string, + selected TYPE abap_bool, + checkbox TYPE abap_bool, + END OF ty_row. + + DATA(ls_row) = VALUE ty_row( ). + ls_row-value = `test`. + + DATA(lv_xml) = z2ui5_cl_util=>xml_stringify( ls_row ). + + IF lv_xml IS INITIAL. + cl_abap_unit_assert=>fail( ). + ENDIF. + + ENDMETHOD. + + METHOD test_trans_xml_2_any__w_data. + + TYPES: + BEGIN OF ty_row, + title TYPE string, + value TYPE string, + descr TYPE string, + icon TYPE string, + info TYPE string, + selected TYPE abap_bool, + checkbox TYPE abap_bool, + END OF ty_row. + + DATA(ls_row) = VALUE ty_row( ). + DATA(ls_row2) = VALUE ty_row( ). + ls_row-value = `test`. + + DATA(lv_xml) = z2ui5_cl_util=>xml_stringify( ls_row ). + + z2ui5_cl_util=>xml_parse( + EXPORTING + xml = lv_xml + IMPORTING + any = ls_row2 ). + + cl_abap_unit_assert=>assert_equals( + act = ls_row + exp = ls_row2 ). + + ENDMETHOD. + + + METHOD test_c_trim_horizontal_tab. + + IF z2ui5_cl_util=>c_trim( |{ cl_abap_char_utilities=>horizontal_tab }| + && |JsadfHHs| + && |{ cl_abap_char_utilities=>horizontal_tab }| ) <> `JsadfHHs`. + cl_abap_unit_assert=>fail( ). + + ENDIF. + + ENDMETHOD. + +ENDCLASS. diff --git a/src/01/02/01/z2ui5_cl_core_bind_srv.clas.abap b/src/01/02/01/z2ui5_cl_core_bind_srv.clas.abap index 0e1e5cf4..b7f5d892 100644 --- a/src/01/02/01/z2ui5_cl_core_bind_srv.clas.abap +++ b/src/01/02/01/z2ui5_cl_core_bind_srv.clas.abap @@ -197,7 +197,12 @@ CLASS z2ui5_cl_core_bind_srv IMPLEMENTATION. ms_config = config. mv_type = type. - mr_attri = mo_app->attri_get_by_data( val ). + + DATA(lo_model) = NEW z2ui5_cl_core_model_srv( + attri = REF #( mo_app->mt_attri ) + app = mo_app->mo_app ). + + mr_attri = lo_model->search_a_dissolve_attribute( val ). IF mr_attri->bind_type IS NOT INITIAL. check_raise_existing( ). @@ -244,24 +249,25 @@ CLASS z2ui5_cl_core_bind_srv IMPLEMENTATION. METHOD main_local. TRY. + DATA(lo_json) = CAST z2ui5_if_ajson( z2ui5_cl_ajson=>new( ) ). + lo_json->set( iv_path = `/` iv_val = val ). + IF config-custom_mapper IS BOUND. - DATA(ajson) = CAST z2ui5_if_ajson( z2ui5_cl_ajson=>create_empty( ii_custom_mapping = config-custom_mapper ) ). + lo_json = lo_json->map( config-custom_mapper ). ELSE. - ajson = CAST z2ui5_if_ajson( z2ui5_cl_ajson=>create_empty( ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_upper_case( ) ) ). + lo_json = lo_json->map( z2ui5_cl_ajson_mapping=>create_upper_case( ) ). ENDIF. - ajson->set( iv_path = `/` iv_val = val ). - IF config-custom_filter IS BOUND. - ajson = ajson->filter( config-custom_filter ). + lo_json = lo_json->filter( config-custom_filter ). ELSE. - ajson = ajson->filter( z2ui5_cl_ajson_filter_lib=>create_empty_filter( ) ). + lo_json = lo_json->filter( z2ui5_cl_ajson_filter_lib=>create_empty_filter( ) ). ENDIF. DATA(lv_id) = to_upper( z2ui5_cl_util=>uuid_get_c22( ) ). INSERT VALUE #( name_client = |/{ lv_id }| name = lv_id - json_bind_local = ajson + json_bind_local = lo_json bind_type = z2ui5_if_core_types=>cs_bind_type-one_time ) INTO TABLE mo_app->mt_attri. diff --git a/src/01/02/01/z2ui5_cl_core_bind_srv.clas.testclasses.abap b/src/01/02/01/z2ui5_cl_core_bind_srv.clas.testclasses.abap index a0bdba5b..af191b08 100644 --- a/src/01/02/01/z2ui5_cl_core_bind_srv.clas.testclasses.abap +++ b/src/01/02/01/z2ui5_cl_core_bind_srv.clas.testclasses.abap @@ -1,327 +1,374 @@ -* -*CLASS ltcl_test_bind DEFINITION DEFERRED. -*CLASS z2ui5_cl_core_bind_srv DEFINITION LOCAL FRIENDS ltcl_test_bind. -* -*CLASS ltcl_test_app DEFINITION FINAL FOR TESTING -* DURATION MEDIUM -* RISK LEVEL HARMLESS. -* -* PUBLIC SECTION. -* -* TYPES: -* BEGIN OF s_01, -* input TYPE string, -* BEGIN OF s_02, -* input TYPE string, -* BEGIN OF s_03, -* input TYPE string, -* BEGIN OF s_04, -* input TYPE string, -* END OF s_04, -* END OF s_03, -* END OF s_02, -* END OF s_01. -* -* DATA ms_struc TYPE s_01 ##NEEDED. -* DATA mv_value TYPE string ##NEEDED. -* DATA mr_value TYPE REF TO data ##NEEDED. -* DATA mr_struc TYPE REF TO s_01 ##NEEDED. -* DATA mo_app TYPE REF TO ltcl_test_bind ##NEEDED. -* -* DATA xx TYPE string. -*ENDCLASS. -* -*CLASS ltcl_test_bind DEFINITION FINAL FOR TESTING -* DURATION MEDIUM -* RISK LEVEL HARMLESS. -* -* PUBLIC SECTION. -* PROTECTED SECTION. -* PRIVATE SECTION. -* METHODS test_one_way FOR TESTING RAISING cx_static_check. -* METHODS test_one_way_w_x_error FOR TESTING RAISING cx_static_check. -* METHODS test_error_diff FOR TESTING RAISING cx_static_check. -* METHODS test_two_way FOR TESTING RAISING cx_static_check. -* -*ENDCLASS. -* -*CLASS ltcl_test_bind IMPLEMENTATION. -* -* METHOD test_one_way_w_x_error. -* -* DATA(lo_app_client) = NEW ltcl_test_app( ). -* DATA(lo_app) = NEW z2ui5_cl_core_app( ). -* lo_app->mo_app = lo_app_client. -* -* DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). -* -* TRY. -* lo_bind->main( -* val = REF #( lo_app_client->xx ) -* type = z2ui5_if_core_types=>cs_bind_type-one_way ). -* -* cl_abap_unit_assert=>abort( ). -* -* CATCH cx_root. -* ENDTRY. -* -* ENDMETHOD. -* -* METHOD test_one_way. -* -* DATA(lo_app_client) = NEW ltcl_test_app( ). -* DATA(lo_app) = NEW z2ui5_cl_core_app( ). -* lo_app->mo_app = lo_app_client. -* -* DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). -* -* DATA(lv_bind) = lo_bind->main( -* val = REF #( lo_app_client->mv_value ) -* type = z2ui5_if_core_types=>cs_bind_type-one_way ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_bind -* exp = `{/MV_VALUE}` ). -* -* cl_abap_unit_assert=>assert_not_initial( lv_bind ). -* -* ENDMETHOD. -* -* METHOD test_error_diff. -* -* DATA(lo_app_client) = NEW ltcl_test_app( ). -* DATA(lo_app) = NEW z2ui5_cl_core_app( ). -* lo_app->mo_app = lo_app_client. -* -* DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). -* -* lo_bind->main( -* val = REF #( lo_app_client->mv_value ) -* type = z2ui5_if_core_types=>cs_bind_type-one_way ). -* -* TRY. -* lo_bind->main( -* val = REF #( lo_app_client->mv_value ) -* type = z2ui5_if_core_types=>cs_bind_type-two_way ). -* -* cl_abap_unit_assert=>abort( ). -* -* CATCH cx_root. -* ENDTRY. -* -* ENDMETHOD. -* -* -* METHOD test_two_way. -* -* DATA(lo_app_client) = NEW ltcl_test_app( ). -* DATA(lo_app) = NEW z2ui5_cl_core_app( ). -* lo_app->mo_app = lo_app_client. -* -* DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). -* -* DATA(lv_bind) = lo_bind->main( -* val = REF #( lo_app_client->mv_value ) -* type = z2ui5_if_core_types=>cs_bind_type-two_way ). -* -* DATA(lv_bind2) = lo_bind->main( -* val = REF #( lo_app_client->mv_value ) -* type = z2ui5_if_core_types=>cs_bind_type-two_way ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_bind -* exp = lv_bind2 ). -* -* cl_abap_unit_assert=>assert_not_initial( lv_bind ). -* -* ENDMETHOD. -*ENDCLASS. -* -* -*CLASS ltcl_test_main_structure DEFINITION FINAL FOR TESTING -* DURATION MEDIUM -* RISK LEVEL HARMLESS. -* -* PUBLIC SECTION. -* -* TYPES: -* BEGIN OF s_01, -* input TYPE string, -* BEGIN OF s_02, -* input TYPE string, -* BEGIN OF s_03, -* input TYPE string, -* BEGIN OF s_04, -* input TYPE string, -* END OF s_04, -* END OF s_03, -* END OF s_02, -* END OF s_01. -* -* DATA ms_struc TYPE s_01. -* -* PRIVATE SECTION. -* -* METHODS test_one_way_lev1 FOR TESTING RAISING cx_static_check. -* METHODS test_one_way_lev2 FOR TESTING RAISING cx_static_check. -* METHODS test_one_way_lev3 FOR TESTING RAISING cx_static_check. -* METHODS test_one_way_lev4_long_name FOR TESTING RAISING cx_static_check. -* -* -*ENDCLASS. -* -*CLASS ltcl_test_main_structure IMPLEMENTATION. -* -* METHOD test_one_way_lev1. -* -* DATA(lo_test_app) = NEW ltcl_test_main_structure( ). -* DATA(lo_app) = NEW z2ui5_cl_core_app( ). -* lo_app->mo_app = lo_test_app. -* -* DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). -* DATA(lv_result) = lo_bind->main( -* val = REF #( lo_test_app->ms_struc-input ) -* type = z2ui5_if_core_types=>cs_bind_type-one_way ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_result -* exp = `{/MS_STRUC/INPUT}` ). -* -* lv_result = lo_bind->main( -* val = REF #( lo_test_app->ms_struc-input ) -* config = VALUE #( path_only = abap_true ) -* type = z2ui5_if_core_types=>cs_bind_type-one_way ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_result -* exp = `/MS_STRUC/INPUT` ). -* -* ENDMETHOD. -* -* METHOD test_one_way_lev2. -* -* DATA(lo_test_app) = NEW ltcl_test_main_structure( ). -* DATA(lo_app) = NEW z2ui5_cl_core_app( ). -* lo_app->mo_app = lo_test_app. -* -* DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). -* DATA(lv_result) = lo_bind->main( -* val = REF #( lo_test_app->ms_struc-s_02-input ) -* type = z2ui5_if_core_types=>cs_bind_type-one_way ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_result -* exp = `{/MS_STRUC/S_02-INPUT}` ). -* -* ENDMETHOD. -* -* METHOD test_one_way_lev3. -* -* DATA(lo_test_app) = NEW ltcl_test_main_structure( ). -* DATA(lo_app) = NEW z2ui5_cl_core_app( ). -* lo_app->mo_app = lo_test_app. -* -* DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). -* DATA(lv_result) = lo_bind->main( -* val = REF #( lo_test_app->ms_struc-s_02-s_03-input ) -* type = z2ui5_if_core_types=>cs_bind_type-one_way ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_result -* exp = `{/MS_STRUC/S_02-S_03-INPUT}` ). -* -* ENDMETHOD. -* -* METHOD test_one_way_lev4_long_name. -* -* DATA(lo_test_app) = NEW ltcl_test_main_structure( ). -* DATA(lo_app) = NEW z2ui5_cl_core_app( ). -* lo_app->mo_app = lo_test_app. -* -* DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). -* DATA(lv_result) = lo_bind->main( -* val = REF #( lo_test_app->ms_struc-s_02-s_03-s_04-input ) -* type = z2ui5_if_core_types=>cs_bind_type-one_way ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_result -* exp = `{/MS_STRUC/S_02-S_03-S_04-INPUT}` ). -* -* ENDMETHOD. -* -*ENDCLASS. -* -* -*CLASS ltcl_test_main_object DEFINITION FINAL FOR TESTING -* DURATION MEDIUM -* RISK LEVEL HARMLESS. -* -* PUBLIC SECTION. -* -* DATA mo_obj TYPE REF TO ltcl_test_main_object. -* DATA mv_value TYPE string. -* -* TYPES: -* BEGIN OF s_01, -* input TYPE string, -* BEGIN OF s_02, -* input TYPE string, -* BEGIN OF s_03, -* input TYPE string, -* BEGIN OF s_04, -* input TYPE string, -* END OF s_04, -* END OF s_03, -* END OF s_02, -* END OF s_01. -* -* DATA ms_struc TYPE s_01. -* -* PRIVATE SECTION. -* -* METHODS test_one_way_value FOR TESTING RAISING cx_static_check. -* METHODS test_one_way_struc FOR TESTING RAISING cx_static_check. -* -* -*ENDCLASS. -* -*CLASS ltcl_test_main_object IMPLEMENTATION. -* -* METHOD test_one_way_value. -* -* DATA(lo_test_app) = NEW ltcl_test_main_object( ). -* lo_test_app->mo_obj = NEW #( ). -* lo_test_app->mo_obj->mv_value = `test`. -* DATA(lo_app) = NEW z2ui5_cl_core_app( ). -* lo_app->mo_app = lo_test_app. -* -* DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). -* DATA(lv_result) = lo_bind->main( -* val = REF #( lo_test_app->mo_obj->mv_value ) -* type = z2ui5_if_core_types=>cs_bind_type-one_way ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_result -* exp = `{/MO_OBJ/MV_VALUE}` ). -* -* ENDMETHOD. -* -* METHOD test_one_way_struc. -* -* DATA(lo_test_app) = NEW ltcl_test_main_object( ). -* lo_test_app->mo_obj = NEW #( ). -* DATA(lo_app) = NEW z2ui5_cl_core_app( ). -* lo_app->mo_app = lo_test_app. -* -* DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). -* DATA(lv_result) = lo_bind->main( -* val = REF #( lo_test_app->mo_obj->ms_struc-input ) -* type = z2ui5_if_core_types=>cs_bind_type-one_way ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lv_result -* exp = `{/MO_OBJ/MS_STRUC-INPUT}` ). -* -* ENDMETHOD. -* -*ENDCLASS. + +CLASS ltcl_test_bind DEFINITION DEFERRED. +CLASS z2ui5_cl_core_bind_srv DEFINITION LOCAL FRIENDS ltcl_test_bind. + +CLASS ltcl_test_app DEFINITION FINAL FOR TESTING + DURATION MEDIUM + RISK LEVEL HARMLESS. + + PUBLIC SECTION. + + TYPES: + BEGIN OF s_01, + input TYPE string, + BEGIN OF s_02, + input TYPE string, + BEGIN OF s_03, + input TYPE string, + BEGIN OF s_04, + input TYPE string, + END OF s_04, + END OF s_03, + END OF s_02, + END OF s_01. + + DATA ms_struc TYPE s_01 ##NEEDED. + DATA mv_value TYPE string ##NEEDED. + DATA mr_value TYPE REF TO data ##NEEDED. + DATA mr_struc TYPE REF TO s_01 ##NEEDED. + DATA mo_app TYPE REF TO ltcl_test_bind ##NEEDED. + + DATA xx TYPE string ##NEEDED. + METHODS constructor. +ENDCLASS. + +CLASS ltcl_test_app IMPLEMENTATION. + + METHOD constructor. + + ENDMETHOD. + +ENDCLASS. + +CLASS ltcl_test_bind DEFINITION FINAL FOR TESTING + DURATION MEDIUM + RISK LEVEL HARMLESS. + + PUBLIC SECTION. + PROTECTED SECTION. + PRIVATE SECTION. + METHODS test_one_way FOR TESTING RAISING cx_static_check. + METHODS test_one_way_w_x_error FOR TESTING RAISING cx_static_check. + METHODS test_error_diff FOR TESTING RAISING cx_static_check. + METHODS test_two_way FOR TESTING RAISING cx_static_check. + +ENDCLASS. + +CLASS ltcl_test_bind IMPLEMENTATION. + + METHOD test_one_way_w_x_error. + + IF sy-sysid = 'ABC'. + RETURN. + ENDIF. + + DATA(lo_app_client) = NEW ltcl_test_app( ). + DATA(lo_app) = NEW z2ui5_cl_core_app( ). + lo_app->mo_app = lo_app_client. + + DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). + + TRY. + lo_bind->main( + val = REF #( lo_app_client->xx ) + type = z2ui5_if_core_types=>cs_bind_type-one_way ). + + cl_abap_unit_assert=>abort( ). + + CATCH cx_root. + ENDTRY. + + ENDMETHOD. + + METHOD test_one_way. + + IF sy-sysid = 'ABC'. + RETURN. + ENDIF. + + DATA(lo_app_client) = NEW ltcl_test_app( ). + DATA(lo_app) = NEW z2ui5_cl_core_app( ). + lo_app->mo_app = lo_app_client. + + DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). + + DATA(lv_bind) = lo_bind->main( + val = REF #( lo_app_client->mv_value ) + type = z2ui5_if_core_types=>cs_bind_type-one_way ). + + cl_abap_unit_assert=>assert_equals( + act = lv_bind + exp = `{/MV_VALUE}` ). + + ENDMETHOD. + + METHOD test_error_diff. + + IF sy-sysid = 'ABC'. + RETURN. + ENDIF. + + DATA(lo_app_client) = NEW ltcl_test_app( ). + DATA(lo_app) = NEW z2ui5_cl_core_app( ). + lo_app->mo_app = lo_app_client. + + DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). + + lo_bind->main( + val = REF #( lo_app_client->mv_value ) + type = z2ui5_if_core_types=>cs_bind_type-one_way ). + + TRY. + lo_bind->main( + val = REF #( lo_app_client->mv_value ) + type = z2ui5_if_core_types=>cs_bind_type-two_way ). + + cl_abap_unit_assert=>abort( ). + + CATCH cx_root. + ENDTRY. + + ENDMETHOD. + + + METHOD test_two_way. + + IF sy-sysid = 'ABC'. + RETURN. + ENDIF. + + DATA(lo_app_client) = NEW ltcl_test_app( ). + DATA(lo_app) = NEW z2ui5_cl_core_app( ). + lo_app->mo_app = lo_app_client. + + DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). + + DATA(lv_bind) = lo_bind->main( + val = REF #( lo_app_client->mv_value ) + type = z2ui5_if_core_types=>cs_bind_type-two_way ). + + DATA(lv_bind2) = lo_bind->main( + val = REF #( lo_app_client->mv_value ) + type = z2ui5_if_core_types=>cs_bind_type-two_way ). + + cl_abap_unit_assert=>assert_equals( + act = lv_bind + exp = lv_bind2 ). + + cl_abap_unit_assert=>assert_not_initial( lv_bind ). + + ENDMETHOD. +ENDCLASS. + + +CLASS ltcl_test_main_structure DEFINITION FINAL FOR TESTING + DURATION MEDIUM + RISK LEVEL HARMLESS. + + PUBLIC SECTION. + + TYPES: + BEGIN OF s_01, + input TYPE string, + BEGIN OF s_02, + input TYPE string, + BEGIN OF s_03, + input TYPE string, + BEGIN OF s_04, + input TYPE string, + END OF s_04, + END OF s_03, + END OF s_02, + END OF s_01. + + DATA ms_struc TYPE s_01. + + PRIVATE SECTION. + + METHODS test_one_way_lev1 FOR TESTING RAISING cx_static_check. + METHODS test_one_way_lev2 FOR TESTING RAISING cx_static_check. + METHODS test_one_way_lev3 FOR TESTING RAISING cx_static_check. + METHODS test_one_way_lev4_long_name FOR TESTING RAISING cx_static_check. + + +ENDCLASS. + +CLASS ltcl_test_main_structure IMPLEMENTATION. + + METHOD test_one_way_lev1. + + IF sy-sysid = 'ABC'. + RETURN. + ENDIF. + + DATA(lo_test_app) = NEW ltcl_test_main_structure( ). + DATA(lo_app) = NEW z2ui5_cl_core_app( ). + lo_app->mo_app = lo_test_app. + + DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). + DATA(lv_result) = lo_bind->main( + val = REF #( lo_test_app->ms_struc-input ) + type = z2ui5_if_core_types=>cs_bind_type-one_way ). + + cl_abap_unit_assert=>assert_equals( + act = lv_result + exp = `{/MS_STRUC/INPUT}` ). + + lv_result = lo_bind->main( + val = REF #( lo_test_app->ms_struc-input ) + config = VALUE #( path_only = abap_true ) + type = z2ui5_if_core_types=>cs_bind_type-one_way ). + + cl_abap_unit_assert=>assert_equals( + act = lv_result + exp = `/MS_STRUC/INPUT` ). + + ENDMETHOD. + + METHOD test_one_way_lev2. + + IF sy-sysid = 'ABC'. + RETURN. + ENDIF. + + DATA(lo_test_app) = NEW ltcl_test_main_structure( ). + DATA(lo_app) = NEW z2ui5_cl_core_app( ). + lo_app->mo_app = lo_test_app. + + DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). + DATA(lv_result) = lo_bind->main( + val = REF #( lo_test_app->ms_struc-s_02-input ) + type = z2ui5_if_core_types=>cs_bind_type-one_way ). + + cl_abap_unit_assert=>assert_equals( + act = lv_result + exp = `{/MS_STRUC/S_02-INPUT}` ). + + ENDMETHOD. + + METHOD test_one_way_lev3. + + IF sy-sysid = 'ABC'. + RETURN. + ENDIF. + + DATA(lo_test_app) = NEW ltcl_test_main_structure( ). + DATA(lo_app) = NEW z2ui5_cl_core_app( ). + lo_app->mo_app = lo_test_app. + + DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). + DATA(lv_result) = lo_bind->main( + val = REF #( lo_test_app->ms_struc-s_02-s_03-input ) + type = z2ui5_if_core_types=>cs_bind_type-one_way ). + + cl_abap_unit_assert=>assert_equals( + act = lv_result + exp = `{/MS_STRUC/S_02-S_03-INPUT}` ). + + ENDMETHOD. + + METHOD test_one_way_lev4_long_name. + + IF sy-sysid = 'ABC'. + RETURN. + ENDIF. + + DATA(lo_test_app) = NEW ltcl_test_main_structure( ). + DATA(lo_app) = NEW z2ui5_cl_core_app( ). + lo_app->mo_app = lo_test_app. + + DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). + DATA(lv_result) = lo_bind->main( + val = REF #( lo_test_app->ms_struc-s_02-s_03-s_04-input ) + type = z2ui5_if_core_types=>cs_bind_type-one_way ). + + cl_abap_unit_assert=>assert_equals( + act = lv_result + exp = `{/MS_STRUC/S_02-S_03-S_04-INPUT}` ). + + ENDMETHOD. + +ENDCLASS. + + +CLASS ltcl_test_main_object DEFINITION FINAL FOR TESTING + DURATION MEDIUM + RISK LEVEL HARMLESS. + + PUBLIC SECTION. + + DATA mo_obj TYPE REF TO ltcl_test_main_object. + DATA mv_value TYPE string. + + TYPES: + BEGIN OF s_01, + input TYPE string, + BEGIN OF s_02, + input TYPE string, + BEGIN OF s_03, + input TYPE string, + BEGIN OF s_04, + input TYPE string, + END OF s_04, + END OF s_03, + END OF s_02, + END OF s_01. + + DATA ms_struc TYPE s_01. + + PRIVATE SECTION. + + METHODS test_one_way_value FOR TESTING RAISING cx_static_check. + METHODS test_one_way_struc FOR TESTING RAISING cx_static_check. + + +ENDCLASS. + +CLASS ltcl_test_main_object IMPLEMENTATION. + + METHOD test_one_way_value. + + IF sy-sysid = 'ABC'. + RETURN. + ENDIF. + + DATA(lo_test_app) = NEW ltcl_test_main_object( ). + lo_test_app->mo_obj = NEW #( ). + lo_test_app->mo_obj->mv_value = `test`. + DATA(lo_app) = NEW z2ui5_cl_core_app( ). + lo_app->mo_app = lo_test_app. + + DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). + DATA(lv_result) = lo_bind->main( + val = REF #( lo_test_app->mo_obj->mv_value ) + type = z2ui5_if_core_types=>cs_bind_type-one_way ). + + cl_abap_unit_assert=>assert_equals( + act = lv_result + exp = `{/MO_OBJ/MV_VALUE}` ). + + ENDMETHOD. + + METHOD test_one_way_struc. + + IF sy-sysid = 'ABC'. + RETURN. + ENDIF. + + DATA(lo_test_app) = NEW ltcl_test_main_object( ). + lo_test_app->mo_obj = NEW #( ). + DATA(lo_app) = NEW z2ui5_cl_core_app( ). + lo_app->mo_app = lo_test_app. + + DATA(lo_bind) = NEW z2ui5_cl_core_bind_srv( lo_app ). + DATA(lv_result) = lo_bind->main( + val = REF #( lo_test_app->mo_obj->ms_struc-input ) + type = z2ui5_if_core_types=>cs_bind_type-one_way ). + + cl_abap_unit_assert=>assert_equals( + act = lv_result + exp = `{/MO_OBJ/MS_STRUC-INPUT}` ). + + ENDMETHOD. + +ENDCLASS. diff --git a/src/01/02/01/z2ui5_cl_core_json_srv.clas.testclasses.abap b/src/01/02/01/z2ui5_cl_core_json_srv.clas.testclasses.abap index 0d7c1f79..7fafde5c 100644 --- a/src/01/02/01/z2ui5_cl_core_json_srv.clas.testclasses.abap +++ b/src/01/02/01/z2ui5_cl_core_json_srv.clas.testclasses.abap @@ -4,7 +4,6 @@ CLASS ltcl_test DEFINITION FINAL FOR TESTING PRIVATE SECTION. METHODS request_json_to_abap FOR TESTING RAISING cx_static_check. - METHODS model_front_to_back FOR TESTING RAISING cx_static_check. ENDCLASS. @@ -13,46 +12,35 @@ CLASS ltcl_test IMPLEMENTATION. METHOD request_json_to_abap. -* DATA(lv_payload) = `{"EDIT":{"NAME":"test"},"ARGUMENTS":[],"S_FRONTEND":{"ID":"ID_NR","EDIT":{"NAME":"test"},"ORIGIN":"ORIGIN","PATHNAME":"PATHNAME","SEARCH":"SEARCH"` && -* `,"VIEW":"MAIN","EVENT":"BUTTON_POST","T_EVENT_ARG":[]}}`. -* -* DATA(lo_mapper) = NEW z2ui5_cl_core_json_srv( ). -* DATA(ls_result) = lo_mapper->request_json_to_abap( lv_payload ). -* -* DATA(ls_exp) = VALUE z2ui5_if_core_types=>ty_s_http_request_post( -* s_frontend = VALUE #( -* id = `ID_NR` -* view = `MAIN` -* origin = `ORIGIN` -* pathname = `PATHNAME` -* search = `SEARCH` -* event = `BUTTON_POST` -* ) ). -* -* cl_abap_unit_assert=>assert_equals( -* act = ls_result-s_frontend -* exp = ls_exp-s_frontend ). -* -* DATA lt_tree TYPE z2ui5_if_ajson_types=>ty_nodes_ts. -* lt_tree = ls_result-o_model->mt_json_tree. -* -* cl_abap_unit_assert=>assert_equals( -* act = lt_tree[ name = `NAME` ]-value -* exp = `test` ). -* -* cl_abap_unit_assert=>assert_equals( -* act = lines( lt_tree ) -* exp = 2 ). + DATA(lv_payload) = `{"XX":{"NAME":"test"},"S_FRONT":{"ID":"ID_NR","EDIT":{"NAME":"test"},"ORIGIN":"ORIGIN","PATHNAME":"PATHNAME","SEARCH":"SEARCH"` && + `,"VIEW":"MAIN","EVENT":"BUTTON_POST","T_EVENT_ARG":[]}}`. - ENDMETHOD. + DATA(lo_mapper) = NEW z2ui5_cl_core_json_srv( ). + DATA(ls_result) = lo_mapper->request_json_to_abap( lv_payload ). - METHOD model_front_to_back. + DATA(ls_exp) = VALUE z2ui5_if_core_types=>ty_s_http_request_post( + s_front = VALUE #( + id = `ID_NR` + view = `MAIN` + origin = `ORIGIN` + pathname = `PATHNAME` + search = `SEARCH` + event = `BUTTON_POST` ) ). -* NEW z2ui5_cl_core_json_srv( )->model_front_to_back( -* viewname = `MAIN` -* app = lo_ap -* t_attri = lt_attri -* model = lo_ajson ). + cl_abap_unit_assert=>assert_equals( + act = ls_result-s_front + exp = ls_exp-s_front ). + + DATA lt_tree TYPE z2ui5_if_ajson_types=>ty_nodes_ts. + lt_tree = ls_result-o_model->mt_json_tree. + + cl_abap_unit_assert=>assert_equals( + act = lt_tree[ name = `NAME` ]-value + exp = `test` ). + + cl_abap_unit_assert=>assert_equals( + act = lines( lt_tree ) + exp = 3 ). ENDMETHOD. diff --git a/src/01/02/01/z2ui5_cl_core_model_srv.clas.abap b/src/01/02/01/z2ui5_cl_core_model_srv.clas.abap index 64d9ff58..0b8d861c 100644 --- a/src/01/02/01/z2ui5_cl_core_model_srv.clas.abap +++ b/src/01/02/01/z2ui5_cl_core_model_srv.clas.abap @@ -1,26 +1,33 @@ CLASS z2ui5_cl_core_model_srv DEFINITION - PUBLIC - FINAL + PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. DATA mt_attri TYPE REF TO z2ui5_if_core_types=>ty_t_attri. - DATA mo_app TYPE REF TO object. + DATA mo_app TYPE REF TO object. METHODS constructor IMPORTING attri TYPE REF TO z2ui5_if_core_types=>ty_t_attri app TYPE REF TO object. - - METHODS dissolve. METHODS attri_refs_update. METHODS attri_before_save. METHODS attri_after_load. + METHODS search_a_dissolve_attribute + IMPORTING + val TYPE REF TO data + RETURNING + VALUE(result) TYPE REF TO z2ui5_if_core_types=>ty_s_attri. + PROTECTED SECTION. + METHODS dissolve. + METHODS dissolve_main. + METHODS dissolve_init. + METHODS attri_get_val_ref IMPORTING iv_path TYPE clike @@ -40,38 +47,40 @@ CLASS z2ui5_cl_core_model_srv DEFINITION VALUE(result) TYPE z2ui5_if_core_types=>ty_t_attri. METHODS diss_oref + IMPORTING ir_attri TYPE REF TO z2ui5_if_core_types=>ty_s_attri + RETURNING VALUE(result) TYPE z2ui5_if_core_types=>ty_t_attri. + + METHODS search_attribute IMPORTING - ir_attri TYPE REF TO z2ui5_if_core_types=>ty_s_attri + val TYPE REF TO data RETURNING - VALUE(result) TYPE z2ui5_if_core_types=>ty_t_attri. + VALUE(result) TYPE REF TO z2ui5_if_core_types=>ty_s_attri. - METHODS dissolve_main. - - METHODS dissolve_init. - - PRIVATE SECTION. + METHODS get_new_attri + IMPORTING + name TYPE string + RETURNING + VALUE(result) TYPE z2ui5_if_core_types=>ty_s_attri. ENDCLASS. - CLASS z2ui5_cl_core_model_srv IMPLEMENTATION. - METHOD attri_after_load. LOOP AT mt_attri->* REFERENCE INTO DATA(lr_attri) - WHERE data_rtti IS NOT INITIAL - AND type_kind = cl_abap_classdescr=>typekind_dref. + WHERE data_rtti IS NOT INITIAL + AND type_kind = cl_abap_classdescr=>typekind_dref. lr_attri->r_ref = attri_get_val_ref( lr_attri->name ). - ASSIGN lr_attri->r_ref->* TO FIELD-SYMBOL(). + z2ui5_cl_util=>xml_srtti_parse( EXPORTING - rtti_data = lr_attri->data_rtti - IMPORTING - e_data = ). + rtti_data = lr_attri->data_rtti + IMPORTING + e_data = ). CLEAR lr_attri->data_rtti. ENDLOOP. @@ -80,7 +89,6 @@ CLASS z2ui5_cl_core_model_srv IMPLEMENTATION. ENDMETHOD. - METHOD attri_before_save. LOOP AT mt_attri->* REFERENCE INTO DATA(lr_attri). @@ -103,15 +111,36 @@ CLASS z2ui5_cl_core_model_srv IMPLEMENTATION. CLEAR . CLEAR . CLEAR lr_attri->r_ref. + ENDLOOP. ENDMETHOD. + METHOD search_a_dissolve_attribute. + + result = search_attribute( val ). + IF result IS BOUND. + RETURN. + ENDIF. + + DO 5 TIMES. + dissolve( ). + result = search_attribute( val ). + IF result IS BOUND. + RETURN. + ENDIF. + ENDDO. + + RAISE EXCEPTION TYPE z2ui5_cx_util_error + EXPORTING + val = `BINDING_ERROR - No class attribute for binding found - Please check if the binded values are public attributes of your class or switch to bind_local`. + + ENDMETHOD. METHOD attri_get_val_ref. - FIELD-SYMBOLS TYPE any. - ASSIGN mo_app->(iv_path) TO . + ASSIGN mo_app->(iv_path) TO FIELD-SYMBOL(). + IF sy-subrc <> 0. RAISE EXCEPTION TYPE z2ui5_cx_util_error EXPORTING @@ -125,44 +154,46 @@ CLASS z2ui5_cl_core_model_srv IMPLEMENTATION. ENDMETHOD. - METHOD attri_refs_update. LOOP AT mt_attri->* REFERENCE INTO DATA(lr_attri) - WHERE bind_type <> z2ui5_if_core_types=>cs_bind_type-one_time. - + WHERE bind_type <> z2ui5_if_core_types=>cs_bind_type-one_time. lr_attri->r_ref = attri_get_val_ref( lr_attri->name ). ENDLOOP. ENDMETHOD. - METHOD constructor. - me->mt_attri = attri. - me->mo_app = app. + mt_attri = attri. + mo_app = app. ENDMETHOD. - METHOD dissolve. IF mt_attri->* IS INITIAL. dissolve_init( ). RETURN. ENDIF. - dissolve_main( ). ENDMETHOD. + METHOD dissolve_init. + + DATA(ls_attri) = VALUE z2ui5_if_core_types=>ty_s_attri( r_ref = REF #( mo_app ) ). + DATA(lt_init) = diss_oref( REF #( ls_attri ) ). + INSERT LINES OF lt_init INTO TABLE mt_attri->*. + + ENDMETHOD. METHOD dissolve_main. DATA(lt_attri_new) = VALUE z2ui5_if_core_types=>ty_t_attri( ). LOOP AT mt_attri->* REFERENCE INTO DATA(lr_attri) - WHERE check_dissolved = abap_false. + WHERE check_dissolved = abap_false. lr_attri->check_dissolved = abap_true. @@ -186,67 +217,58 @@ CLASS z2ui5_cl_core_model_srv IMPLEMENTATION. ENDCASE. ENDLOOP. - INSERT LINES OF lt_attri_new INTO TABLE mt_attri->*. ENDMETHOD. - METHOD diss_dref. - FIELD-SYMBOLS TYPE any. - ASSIGN ir_attri->r_ref->* TO . - - IF IS INITIAL. + DATA(lr_ref) = z2ui5_cl_util=>unassign_data( ir_attri->r_ref ). + IF lr_ref IS INITIAL. RETURN. ENDIF. DATA(ls_attri2) = VALUE z2ui5_if_core_types=>ty_s_attri( ). - ls_attri2-o_typedescr = cl_abap_datadescr=>describe_by_data_ref( ). - ls_attri2-type_kind = z2ui5_cl_util=>rtti_get_type_kind_by_descr( ls_attri2-o_typedescr ). + ls_attri2-o_typedescr = cl_abap_datadescr=>describe_by_data_ref( lr_ref ). + ls_attri2-type_kind = z2ui5_cl_util=>rtti_get_type_kind_by_descr( ls_attri2-o_typedescr ). CASE ls_attri2-o_typedescr->type_kind. - WHEN cl_abap_datadescr=>typekind_struct1 OR - cl_abap_datadescr=>typekind_struct2. + WHEN cl_abap_datadescr=>typekind_struct1 + OR cl_abap_datadescr=>typekind_struct2. DATA(lt_attri) = diss_struc( ir_attri ). INSERT LINES OF lt_attri INTO TABLE result. WHEN OTHERS. - ls_attri2-name = ir_attri->name && `->*`. - ls_attri2-r_ref = attri_get_val_ref( ls_attri2-name ). + ls_attri2-name = ir_attri->name && `->*`. + ls_attri2-r_ref = attri_get_val_ref( ls_attri2-name ). INSERT ls_attri2 INTO TABLE result. ENDCASE. ENDMETHOD. - METHOD diss_oref. IF z2ui5_cl_util=>check_unassign_inital( ir_attri->r_ref ). RETURN. ENDIF. - DATA(lt_attri) = z2ui5_cl_util=>rtti_get_t_attri_by_oref( - z2ui5_cl_util=>unassign_object( ir_attri->r_ref ) ). + DATA(lv_name) = COND #( WHEN ir_attri->name IS NOT INITIAL THEN ir_attri->name && `->` ). + + DATA(lr_ref) = z2ui5_cl_util=>unassign_object( ir_attri->r_ref ). + DATA(lt_attri) = z2ui5_cl_util=>rtti_get_t_attri_by_oref( lr_ref ). LOOP AT lt_attri REFERENCE INTO DATA(lr_attri) - WHERE visibility = cl_abap_objectdescr=>public - AND is_interface = abap_false - AND is_constant = abap_false. + WHERE visibility = cl_abap_objectdescr=>public + AND is_interface = abap_false + AND is_constant = abap_false. TRY. - DATA(lv_name) = COND #( WHEN ir_attri->name IS NOT INITIAL THEN ir_attri->name && `->` ). - lv_name = lv_name && lr_attri->name. - DATA(ls_attri2) = VALUE z2ui5_if_core_types=>ty_s_attri( ). - ls_attri2-name = lv_name. - ls_attri2-r_ref = attri_get_val_ref( ls_attri2-name ). - ls_attri2-o_typedescr = cl_abap_datadescr=>describe_by_data_ref( ls_attri2-r_ref ). - ls_attri2-type_kind = z2ui5_cl_util=>rtti_get_type_kind_by_descr( ls_attri2-o_typedescr ). - INSERT ls_attri2 INTO TABLE result. + DATA(ls_new) = get_new_attri( lv_name && lr_attri->name ). + INSERT ls_new INTO TABLE result. CATCH cx_root. ENDTRY. @@ -254,43 +276,51 @@ CLASS z2ui5_cl_core_model_srv IMPLEMENTATION. ENDMETHOD. - METHOD diss_struc. - FIELD-SYMBOLS TYPE any. - CASE ir_attri->type_kind. - WHEN cl_abap_typedescr=>typekind_struct1 - OR cl_abap_typedescr=>typekind_struct2. - DATA(lv_name) = ir_attri->name && `-`. - ASSIGN ir_attri->r_ref TO . - WHEN cl_abap_typedescr=>typekind_dref. - lv_name = ir_attri->name && `->`. - ASSIGN ir_attri->r_ref->* TO . - ENDCASE. + IF ir_attri->type_kind = cl_abap_typedescr=>typekind_dref. + DATA(lv_name) = ir_attri->name && `->`. + DATA(lr_ref) = z2ui5_cl_util=>unassign_data( ir_attri->r_ref ). + ELSE. + lv_name = ir_attri->name && `-`. + lr_ref = ir_attri->r_ref. + ENDIF. - - DATA(lt_attri) = z2ui5_cl_util=>rtti_get_t_attri_by_struc( ). + DATA(lt_attri) = z2ui5_cl_util=>rtti_get_t_attri_by_struc( lr_ref ). LOOP AT lt_attri INTO DATA(ls_attri). - - DATA(ls_attri2) = VALUE z2ui5_if_core_types=>ty_s_attri( ). - ls_attri2-name = lv_name && ls_attri-name. - ls_attri2-r_ref = attri_get_val_ref( lv_name && ls_attri-name ). - ls_attri2-o_typedescr = cl_abap_datadescr=>describe_by_data_ref( ls_attri2-r_ref ). - ls_attri2-type_kind = z2ui5_cl_util=>rtti_get_type_kind_by_descr( ls_attri2-o_typedescr ). - INSERT ls_attri2 INTO TABLE result. - + DATA(ls_new) = get_new_attri( lv_name && ls_attri-name ). + INSERT ls_new INTO TABLE result. ENDLOOP. ENDMETHOD. - METHOD dissolve_init. + METHOD search_attribute. - DATA(ls_attri) = VALUE z2ui5_if_core_types=>ty_s_attri( r_ref = REF #( mo_app ) ). - DATA(lt_init) = diss_oref( REF #( ls_attri ) ). - INSERT LINES OF lt_init INTO TABLE mt_attri->*. +* result = REF #( mt_attri->*[ r_ref = val ] OPTIONAL ). + + LOOP AT mt_attri->* REFERENCE INTO DATA(lr_attri) + WHERE type_kind <> cl_abap_typedescr=>typekind_dref + AND type_kind <> cl_abap_typedescr=>typekind_oref. + + IF lr_attri->r_ref = val. + result = lr_attri. + RETURN. + ENDIF. + ENDLOOP. + + ENDMETHOD. + + METHOD get_new_attri. + + result = VALUE z2ui5_if_core_types=>ty_s_attri( ). + result-name = name. + result-r_ref = attri_get_val_ref( name ). + result-o_typedescr = cl_abap_datadescr=>describe_by_data_ref( result-r_ref ). + result-type_kind = z2ui5_cl_util=>rtti_get_type_kind_by_descr( result-o_typedescr ). ENDMETHOD. ENDCLASS. + diff --git a/src/01/02/01/z2ui5_cl_core_model_srv.clas.testclasses.abap b/src/01/02/01/z2ui5_cl_core_model_srv.clas.testclasses.abap index 5bd00f04..9d5bdc58 100644 --- a/src/01/02/01/z2ui5_cl_core_model_srv.clas.testclasses.abap +++ b/src/01/02/01/z2ui5_cl_core_model_srv.clas.testclasses.abap @@ -34,25 +34,46 @@ CLASS ltcl_test_dissolve DEFINITION FINAL FOR TESTING METHODS test_dissolve_struc FOR TESTING RAISING cx_static_check. METHODS test_dissolve_dref FOR TESTING RAISING cx_static_check. METHODS test_dissolve_oref FOR TESTING RAISING cx_static_check. + METHODS test_ref FOR TESTING RAISING cx_static_check. ENDCLASS. CLASS ltcl_test_dissolve IMPLEMENTATION. + METHOD test_ref. + + DATA(lo_app) = NEW ltcl_test_dissolve( ). + + DATA lt_attri TYPE z2ui5_if_core_types=>ty_t_attri. + DATA(lo_model) = NEW z2ui5_cl_core_model_srv( + attri = REF #( lt_attri ) + app = lo_app ). + + lo_model->dissolve( ). + + DATA(ls_attri) = lt_attri[ name = `MV_VALUE` ]. + GET REFERENCE OF lo_app->mv_value INTO DATA(lr_ref). + + IF ls_attri-r_ref <> lr_ref. + cl_abap_unit_assert=>abort( ). + ENDIF. + + ENDMETHOD. + METHOD test_dissolve_init. DATA(lo_app) = NEW ltcl_test_dissolve( ). DATA lt_attri TYPE z2ui5_if_core_types=>ty_t_attri. - DATA(lo_bind) = NEW z2ui5_cl_core_model_srv( + DATA(lo_model) = NEW z2ui5_cl_core_model_srv( attri = REF #( lt_attri ) app = lo_app ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). cl_abap_unit_assert=>assert_not_initial( VALUE #( lt_attri[ name = `MR_STRUC` ] OPTIONAL ) ). cl_abap_unit_assert=>assert_not_initial( VALUE #( lt_attri[ name = `MR_VALUE` ] OPTIONAL ) ). @@ -68,15 +89,15 @@ CLASS ltcl_test_dissolve IMPLEMENTATION. CREATE DATA lo_app->mr_value TYPE string. DATA lt_attri TYPE z2ui5_if_core_types=>ty_t_attri. - DATA(lo_bind) = NEW z2ui5_cl_core_model_srv( + DATA(lo_model) = NEW z2ui5_cl_core_model_srv( attri = REF #( lt_attri ) app = lo_app ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). cl_abap_unit_assert=>assert_not_initial( VALUE #( lt_attri[ name = `MR_VALUE->*` ] OPTIONAL ) ). @@ -93,14 +114,14 @@ CLASS ltcl_test_dissolve IMPLEMENTATION. CREATE DATA lo_app->mo_app->mr_value TYPE string. DATA lt_attri TYPE z2ui5_if_core_types=>ty_t_attri. - DATA(lo_bind) = NEW z2ui5_cl_core_model_srv( + DATA(lo_model) = NEW z2ui5_cl_core_model_srv( attri = REF #( lt_attri ) app = lo_app2 ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). cl_abap_unit_assert=>assert_not_initial( VALUE #( lt_attri[ name = `MO_APP->MV_VALUE` ] OPTIONAL ) ). cl_abap_unit_assert=>assert_not_initial( VALUE #( lt_attri[ name = `MO_APP->MR_STRUC` ] OPTIONAL ) ). @@ -113,15 +134,15 @@ CLASS ltcl_test_dissolve IMPLEMENTATION. DATA(lo_app) = NEW ltcl_test_dissolve( ). DATA lt_attri TYPE z2ui5_if_core_types=>ty_t_attri. - DATA(lo_bind) = NEW z2ui5_cl_core_model_srv( + DATA(lo_model) = NEW z2ui5_cl_core_model_srv( attri = REF #( lt_attri ) app = lo_app ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). - lo_bind->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). + lo_model->dissolve( ). cl_abap_unit_assert=>assert_not_initial( VALUE #( lt_attri[ name = `MS_STRUC-INPUT` ] OPTIONAL ) ). cl_abap_unit_assert=>assert_not_initial( VALUE #( lt_attri[ name = `MS_STRUC-S_02-INPUT` ] OPTIONAL ) ). @@ -130,3 +151,107 @@ CLASS ltcl_test_dissolve IMPLEMENTATION. ENDMETHOD. ENDCLASS. + + +CLASS ltcl_test_app2 DEFINITION FINAL FOR TESTING + DURATION MEDIUM + RISK LEVEL HARMLESS. + + PUBLIC SECTION. + + DATA mv_value TYPE string ##NEEDED. + DATA mr_value TYPE REF TO data. + DATA mr_value2 TYPE REF TO data. + DATA mo_app TYPE REF TO ltcl_test_app2. + + DATA xx TYPE string ##NEEDED. + METHODS constructor. +ENDCLASS. + +CLASS ltcl_test_app2 IMPLEMENTATION. + + METHOD constructor. + + ENDMETHOD. + +ENDCLASS. + +CLASS ltcl_test_search_attri DEFINITION FINAL FOR TESTING + DURATION SHORT + RISK LEVEL HARMLESS. + + PRIVATE SECTION. + METHODS first_test FOR TESTING RAISING cx_static_check. + METHODS second_test FOR TESTING RAISING cx_static_check. + METHODS third_test FOR TESTING RAISING cx_static_check. + +ENDCLASS. + +CLASS z2ui5_cl_core_model_srv DEFINITION LOCAL FRIENDS ltcl_test_search_attri. + +CLASS ltcl_test_search_attri IMPLEMENTATION. + + METHOD first_test. + + DATA(lo_app_client) = NEW ltcl_test_app2( ). + DATA lr_value TYPE REF TO data. + GET REFERENCE OF lo_app_client->mv_value INTO lr_value. + + DATA(lt_attri) = VALUE z2ui5_if_core_types=>ty_t_attri( ( r_ref = lr_value ) ). + + DATA(lo_model) = NEW z2ui5_cl_core_model_srv( + attri = REF #( lt_attri ) + app = lo_app_client ). + + DATA(lr_attri) = lo_model->search_a_dissolve_attribute( REF #( lo_app_client->mv_value ) ). + + IF lr_attri->r_ref <> lr_value. + cl_abap_unit_assert=>abort( ). + ENDIF. + + ENDMETHOD. + + METHOD second_test. + + DATA(lo_app_client) = NEW ltcl_test_app2( ). + DATA lr_value TYPE REF TO data. + GET REFERENCE OF lo_app_client->mv_value INTO lr_value. + + DATA(lt_attri) = VALUE z2ui5_if_core_types=>ty_t_attri( ( r_ref = REF #( lo_app_client->mv_value ) ) ). + + DATA(lo_model) = NEW z2ui5_cl_core_model_srv( + attri = REF #( lt_attri ) + app = lo_app_client ). + + DATA(lr_attri) = lo_model->search_a_dissolve_attribute( REF #( lo_app_client->mv_value ) ). + + IF lr_attri->r_ref <> lr_value. + cl_abap_unit_assert=>abort( ). + ENDIF. + + ENDMETHOD. + + METHOD third_test. + + DATA(lo_app_client) = NEW ltcl_test_app2( ). + DATA lr_value TYPE REF TO data. + GET REFERENCE OF lo_app_client->mv_value INTO lr_value. + + lo_app_client->mo_app = NEW #( ). + + DATA(lt_attri) = VALUE z2ui5_if_core_types=>ty_t_attri( + ( name = `1` r_ref = REF #( lo_app_client->mr_value ) ) + ( name = `4` r_ref = REF #( lo_app_client->mr_value2 ) ) + ( name = `2` r_ref = REF #( lo_app_client->mo_app ) ) + ( name = `3` r_ref = REF #( lo_app_client->mv_value ) ) + ). + + DATA(lr_attri) = REF #( lt_attri[ r_ref = lr_value ] ). + IF lr_attri->r_ref <> lr_value. + cl_abap_unit_assert=>abort( ). + ENDIF. + + ENDMETHOD. + + +ENDCLASS. diff --git a/src/01/02/z2ui5_cl_core_action.clas.abap b/src/01/02/z2ui5_cl_core_action.clas.abap index 35fe9b83..0576d6de 100644 --- a/src/01/02/z2ui5_cl_core_action.clas.abap +++ b/src/01/02/z2ui5_cl_core_action.clas.abap @@ -42,6 +42,11 @@ CLASS z2ui5_cl_core_action DEFINITION val TYPE REF TO z2ui5_cl_core_http_post. PROTECTED SECTION. + METHODS prepare_app_stack + IMPORTING + val TYPE z2ui5_if_core_types=>ty_s_next-o_app_leave + RETURNING + VALUE(result) TYPE REF TO z2ui5_cl_core_action. PRIVATE SECTION. ENDCLASS. @@ -68,8 +73,8 @@ CLASS z2ui5_cl_core_action IMPLEMENTATION. result->ms_actual-view = mo_http_post->ms_request-s_front-view. result->mo_app->model_json_parse( - view = mo_http_post->ms_request-s_front-view - io_json_model = mo_http_post->ms_request-o_model ). + iv_view = mo_http_post->ms_request-s_front-view + io_model = mo_http_post->ms_request-o_model ). result->ms_actual-event = mo_http_post->ms_request-s_front-event. result->ms_actual-t_event_arg = mo_http_post->ms_request-s_front-t_event_arg. @@ -103,27 +108,7 @@ CLASS z2ui5_cl_core_action IMPLEMENTATION. METHOD factory_stack_call. - mo_app->db_save( ). - - ms_next-o_app_call->id_draft = COND string( - WHEN ms_next-o_app_call->id_draft IS INITIAL THEN z2ui5_cl_util=>uuid_get_c32( ) - ELSE ms_next-o_app_call->id_draft ). - - result = NEW #( mo_http_post ). - result->mo_app->mo_app = ms_next-o_app_call. - result->mo_app->ms_draft-id = ms_next-o_app_call->id_draft. - result->mo_app->ms_draft-id_prev = mo_app->ms_draft-id. - result->mo_app->ms_draft-id_prev_app = mo_app->ms_draft-id. - result->ms_actual-check_on_navigated = abap_true. - result->ms_next-s_set = ms_next-s_set. - - TRY. - DATA(lo_app) = z2ui5_cl_core_app=>db_load( ms_next-o_app_call->id_draft ). - result->mo_app = lo_app. - result->mo_app->mo_app = ms_next-o_app_leave. - CATCH cx_root. - ENDTRY. - + result = prepare_app_stack( ms_next-o_app_call ). result->mo_app->ms_draft-id_prev_app_stack = mo_app->ms_draft-id. ENDMETHOD. @@ -131,35 +116,7 @@ CLASS z2ui5_cl_core_action IMPLEMENTATION. METHOD factory_stack_leave. - mo_app->db_save( ). - - ms_next-o_app_leave->id_draft = COND string( - WHEN ms_next-o_app_leave->id_draft IS INITIAL THEN z2ui5_cl_util=>uuid_get_c32( ) - ELSE ms_next-o_app_leave->id_draft ). - - result = NEW #( mo_http_post ). - result->mo_app->mo_app = ms_next-o_app_leave. - - TRY. - - DATA(lo_app) = z2ui5_cl_core_app=>db_load( ms_next-o_app_leave->id_draft ). - result->mo_app = lo_app. - result->mo_app->mo_app = ms_next-o_app_leave. - - DATA(lo_model) = NEW z2ui5_cl_core_model_srv( - attri = REF #( result->mo_app->mt_attri ) - app = result->mo_app->mo_app ). - - lo_model->attri_refs_update( ). - - CATCH cx_root. - ENDTRY. - - result->mo_app->ms_draft-id = ms_next-o_app_leave->id_draft. - result->mo_app->ms_draft-id_prev = mo_app->ms_draft-id. - result->mo_app->ms_draft-id_prev_app = mo_app->ms_draft-id. - result->ms_actual-check_on_navigated = abap_true. - result->ms_next-s_set = ms_next-s_set. + result = prepare_app_stack( ms_next-o_app_leave ). ENDMETHOD. @@ -189,4 +146,28 @@ CLASS z2ui5_cl_core_action IMPLEMENTATION. li_app->id_draft = result->mo_app->ms_draft-id. ENDMETHOD. + + METHOD prepare_app_stack. + + mo_app->db_save( ). + + val->id_draft = COND string( WHEN val->id_draft IS INITIAL + THEN z2ui5_cl_util=>uuid_get_c32( ) + ELSE ms_next-o_app_leave->id_draft ). + + result = NEW #( mo_http_post ). + TRY. + result->mo_app = z2ui5_cl_core_app=>db_load_by_app( val ). + CATCH cx_root. + result->mo_app->mo_app = val. + ENDTRY. + result->mo_app->ms_draft-id = val->id_draft. + + result->mo_app->ms_draft-id_prev = mo_app->ms_draft-id. + result->mo_app->ms_draft-id_prev_app = mo_app->ms_draft-id. + result->ms_actual-check_on_navigated = abap_true. + result->ms_next-s_set = ms_next-s_set. + + ENDMETHOD. + ENDCLASS. diff --git a/src/01/02/z2ui5_cl_core_action.clas.testclasses.abap b/src/01/02/z2ui5_cl_core_action.clas.testclasses.abap index e4f14132..e7614af9 100644 --- a/src/01/02/z2ui5_cl_core_action.clas.testclasses.abap +++ b/src/01/02/z2ui5_cl_core_action.clas.testclasses.abap @@ -7,6 +7,7 @@ CLASS ltcl_test DEFINITION FINAL FOR TESTING first_test FOR TESTING RAISING cx_static_check. ENDCLASS. +CLASS z2ui5_cl_core_action DEFINITION LOCAL FRIENDS ltcl_test. CLASS ltcl_test IMPLEMENTATION. diff --git a/src/01/02/z2ui5_cl_core_app.clas.abap b/src/01/02/z2ui5_cl_core_app.clas.abap index c99d06ee..975d3277 100644 --- a/src/01/02/z2ui5_cl_core_app.clas.abap +++ b/src/01/02/z2ui5_cl_core_app.clas.abap @@ -5,17 +5,11 @@ CLASS z2ui5_cl_core_app DEFINITION PUBLIC SECTION. - INTERFACES if_serializable_object . + INTERFACES if_serializable_object. - DATA mt_attri TYPE z2ui5_if_core_types=>ty_t_attri . - DATA mo_app TYPE REF TO object . - DATA ms_draft TYPE z2ui5_if_types=>ty_s_get-s_draft . - - METHODS attri_get_by_data - IMPORTING - !val TYPE REF TO data - RETURNING - VALUE(result) TYPE REF TO z2ui5_if_core_types=>ty_s_attri . + DATA mt_attri TYPE z2ui5_if_core_types=>ty_t_attri. + DATA mo_app TYPE REF TO object. + DATA ms_draft TYPE z2ui5_if_types=>ty_s_get-s_draft. METHODS model_json_stringify RETURNING @@ -23,24 +17,30 @@ CLASS z2ui5_cl_core_app DEFINITION METHODS model_json_parse IMPORTING - !view TYPE string - !io_json_model TYPE REF TO z2ui5_if_ajson . + !iv_view TYPE string + !io_model TYPE REF TO z2ui5_if_ajson. METHODS all_xml_stringify RETURNING - VALUE(result) TYPE string . + VALUE(result) TYPE string. CLASS-METHODS all_xml_parse IMPORTING - !val TYPE string + !xml TYPE string RETURNING - VALUE(result) TYPE REF TO z2ui5_cl_core_app . + VALUE(result) TYPE REF TO z2ui5_cl_core_app. CLASS-METHODS db_load IMPORTING !id TYPE string RETURNING - VALUE(result) TYPE REF TO z2ui5_cl_core_app . + VALUE(result) TYPE REF TO z2ui5_cl_core_app. + + CLASS-METHODS db_load_by_app + IMPORTING + app TYPE REF TO z2ui5_if_app + RETURNING + VALUE(result) TYPE REF TO z2ui5_cl_core_app. METHODS db_save. @@ -57,16 +57,10 @@ CLASS z2ui5_cl_core_app IMPLEMENTATION. z2ui5_cl_util=>xml_parse( EXPORTING - xml = val + xml = xml IMPORTING any = result ). - DATA(lo_model) = NEW z2ui5_cl_core_model_srv( - attri = REF #( result->mt_attri ) - app = result->mo_app ). - - lo_model->attri_after_load( ). - ENDMETHOD. @@ -76,7 +70,7 @@ CLASS z2ui5_cl_core_app IMPLEMENTATION. DATA(lo_model) = NEW z2ui5_cl_core_model_srv( attri = REF #( mt_attri ) - app = me->mo_app ). + app = mo_app ). lo_model->attri_before_save( ). result = z2ui5_cl_util=>xml_stringify( me ). @@ -92,49 +86,40 @@ CLASS z2ui5_cl_core_app IMPLEMENTATION. ENDMETHOD. - METHOD attri_get_by_data. - - TRY. - result = REF #( mt_attri[ r_ref = val ] ). - RETURN. - CATCH cx_root. - ENDTRY. - - DATA(lo_model) = NEW z2ui5_cl_core_model_srv( - attri = REF #( mt_attri ) - app = mo_app ). - - DO 5 TIMES. - - lo_model->dissolve( ). - - TRY. - result = REF #( mt_attri[ r_ref = val ] ). - RETURN. - CATCH cx_root. - ENDTRY. - - ENDDO. - - RAISE EXCEPTION TYPE z2ui5_cx_util_error - EXPORTING - val = `BINDING_ERROR - No class attribute for binding found - Please check if the binded values are public attributes of your class or switch to bind_local`. - - ENDMETHOD. - - METHOD db_load. DATA(lo_db) = NEW z2ui5_cl_core_draft_srv( ). DATA(ls_db) = lo_db->read_draft( id ). result = all_xml_parse( ls_db-data ). + DATA(lo_model) = NEW z2ui5_cl_core_model_srv( + attri = REF #( result->mt_attri ) + app = result->mo_app ). + + lo_model->attri_after_load( ). + + ENDMETHOD. + + + METHOD db_load_by_app. + + DATA(lo_db) = NEW z2ui5_cl_core_draft_srv( ). + DATA(ls_db) = lo_db->read_draft( app->id_draft ). + result = all_xml_parse( ls_db-data ). + + result->mo_app = app. + + DATA(lo_model) = NEW z2ui5_cl_core_model_srv( + attri = REF #( result->mt_attri ) + app = result->mo_app ). + + lo_model->attri_refs_update( ). + ENDMETHOD. METHOD db_save. - IF mo_app IS BOUND. CAST z2ui5_if_app( mo_app )->id_draft = ms_draft-id. ENDIF. @@ -151,9 +136,9 @@ CLASS z2ui5_cl_core_app IMPLEMENTATION. DATA(lo_json_mapper) = NEW z2ui5_cl_core_json_srv( ). lo_json_mapper->model_client_to_server( - view = view + view = iv_view t_attri = REF #( mt_attri ) - model = io_json_model ). + model = io_model ). ENDMETHOD. diff --git a/src/01/02/z2ui5_cl_core_app.clas.testclasses.abap b/src/01/02/z2ui5_cl_core_app.clas.testclasses.abap new file mode 100644 index 00000000..45f9d46d --- /dev/null +++ b/src/01/02/z2ui5_cl_core_app.clas.testclasses.abap @@ -0,0 +1,20 @@ +CLASS ltcl_test DEFINITION FINAL FOR TESTING + DURATION SHORT + RISK LEVEL HARMLESS. + + PRIVATE SECTION. + METHODS: + first_test FOR TESTING RAISING cx_static_check. +ENDCLASS. + +CLASS z2ui5_cl_core_app DEFINITION LOCAL FRIENDS ltcl_test. + +CLASS ltcl_test IMPLEMENTATION. + + METHOD first_test. + + DATA(lo_action) = NEW z2ui5_cl_core_app( ) ##NEEDED. + + ENDMETHOD. + +ENDCLASS. diff --git a/src/01/02/z2ui5_cl_core_app.clas.xml b/src/01/02/z2ui5_cl_core_app.clas.xml index b52ccc44..f423bec7 100644 --- a/src/01/02/z2ui5_cl_core_app.clas.xml +++ b/src/01/02/z2ui5_cl_core_app.clas.xml @@ -10,6 +10,7 @@ X X X + X diff --git a/src/01/02/z2ui5_cl_core_http_get.clas.abap b/src/01/02/z2ui5_cl_core_http_get.clas.abap index 40d2ae2a..818cb6f2 100644 --- a/src/01/02/z2ui5_cl_core_http_get.clas.abap +++ b/src/01/02/z2ui5_cl_core_http_get.clas.abap @@ -299,7 +299,9 @@ CLASS z2ui5_cl_core_http_get IMPLEMENTATION. ` return;` && |\n| && ` }` && |\n| && ` BusyIndicator.show();` && |\n| && + ` let appStart = sap.z2ui5.oBody.APP_START;` && |\n| && ` sap.z2ui5.oBody = {};` && |\n| && + ` sap.z2ui5.oBody.APP_START = appStart;` && |\n| && ` if ( sap.z2ui5.oController == this ) {` && |\n| && ` sap.z2ui5.oBody.XX = sap.z2ui5.oView.getModel().getData().XX;` && |\n| && ` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| && @@ -405,6 +407,7 @@ CLASS z2ui5_cl_core_http_get IMPLEMENTATION. ` } else {` && |\n| && ` const responseData = await response.json();` && |\n| && ` sap.z2ui5.responseData = responseData;` && |\n| && + ` if( !sap.z2ui5.oBody.APP_START ) { sap.z2ui5.oBody.APP_START = sap.z2ui5.responseData.S_FRONT.APP; }` && |\n| && ` sap.z2ui5.oController.responseSuccess({` && |\n| && ` ID : responseData.S_FRONT.ID,` && |\n| && ` PARAMS : responseData.S_FRONT.PARAMS,` && |\n| && diff --git a/src/01/02/z2ui5_cl_core_http_post.clas.testclasses.abap b/src/01/02/z2ui5_cl_core_http_post.clas.testclasses.abap index d167d834..227ee17a 100644 --- a/src/01/02/z2ui5_cl_core_http_post.clas.testclasses.abap +++ b/src/01/02/z2ui5_cl_core_http_post.clas.testclasses.abap @@ -33,75 +33,3 @@ CLASS ltcl_test_handler_post IMPLEMENTATION. ENDMETHOD. ENDCLASS. - -*CLASS ltcl_unit_test DEFINITION FINAL FOR TESTING -* DURATION LONG -* RISK LEVEL HARMLESS. -* -* PRIVATE SECTION. -* METHODS test_req_begin_fw_start FOR TESTING RAISING cx_static_check. -* METHODS test_req_begin_app_start FOR TESTING RAISING cx_static_check. -* METHODS test_req_end FOR TESTING RAISING cx_static_check. -* -*ENDCLASS. -* -*CLASS z2ui5_cl_fw_controller DEFINITION LOCAL FRIENDS ltcl_unit_test. -* -*CLASS ltcl_unit_test IMPLEMENTATION. -* -* METHOD test_req_begin_fw_start. -* -* DATA(lv_body) = `{"OLOCATION":{"ORIGIN":"https:/url.abap-web.us10.hana.ondemand.com","PATHNAME":"/sap/bc/http/sap/z_http_service_for_ui","SEARCH":"?sap-client=100","VERSION":"com.sap.ui5.dist:sapui5-sdk-dist:1.115.0:war"}}`. -* -* DATA(lo_handler) = z2ui5_cl_fw_controller=>request_begin( lv_body ). -* -* cl_abap_unit_assert=>assert_bound( lo_handler->ms_db-app ). -* -* DATA(lo_app_fw) = CAST z2ui5_cl_fw_app_startup( lo_handler->ms_db-app ) ##NEEDED. -* -* ENDMETHOD. -* -* METHOD test_req_begin_app_start. -* -* DATA(lv_body) = `{"OLOCATION":{"ORIGIN":"https://url.abap-web.us10.hana.ondemand.com","PATHNAME":"/sap/bc/http/sap/z_http_service_for_ui","SEARCH":"?sap-client=100&app_start=z2ui5_cl_app_hello_world","VERSION":"c` && -* `om.sap.ui5.dist:sapui5-sdk-dist:1.115.0:war"}}`. -* -* DATA(lo_handler) = z2ui5_cl_fw_controller=>request_begin( lv_body ). -* -* cl_abap_unit_assert=>assert_bound( lo_handler->ms_db-app ). -* -* DATA(lo_app_fw) = CAST z2ui5_cl_app_hello_world( lo_handler->ms_db-app ) ##NEEDED. -* -* ENDMETHOD. -* -* -* METHOD test_req_end. -* -* DATA(lv_body) = `{"OLOCATION":{"ORIGIN":"https://url.abap-web.us10.hana.ondemand.com","PATHNAME":"/sap/bc/http/sap/z_http_service_for_ui","SEARCH":"?sap-client=100&app_start=z2ui5_cl_app_hello_world","VERSION":"c` && -* `om.sap.ui5.dist:sapui5-sdk-dist:1.115.0:war"}}`. -* -* DATA(lo_handler) = z2ui5_cl_fw_controller=>request_begin( lv_body ). -* -* CAST z2ui5_if_app( lo_handler->ms_db-app )->main( NEW z2ui5_cl_fw_client( lo_handler ) ). -* -* DATA(lv_resp) = lo_handler->request_end( ). -* -* IF lv_resp NS `NAME`. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF lv_resp NS `EDIT`. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF lv_resp NS `ID`. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* IF lv_resp NS `mvc:View`. -* cl_abap_unit_assert=>fail( ). -* ENDIF. -* -* ENDMETHOD. -* -*ENDCLASS. diff --git a/src/01/02/z2ui5_if_core_types.intf.abap b/src/01/02/z2ui5_if_core_types.intf.abap index 1fb19685..c5614509 100644 --- a/src/01/02/z2ui5_if_core_types.intf.abap +++ b/src/01/02/z2ui5_if_core_types.intf.abap @@ -32,15 +32,10 @@ INTERFACE z2ui5_if_core_types name TYPE string, name_client TYPE string, type_kind TYPE string, - type TYPE string, bind_type TYPE string, - data_stringify TYPE string, data_rtti TYPE string, - check_ready TYPE abap_bool, check_dissolved TYPE abap_bool, - check_temp TYPE abap_bool, view TYPE string, - depth TYPE i, json_bind_local TYPE REF TO z2ui5_if_ajson, custom_filter TYPE REF TO z2ui5_if_ajson_filter, custom_filter_back TYPE REF TO z2ui5_if_ajson_filter, @@ -48,7 +43,6 @@ INTERFACE z2ui5_if_core_types custom_mapper_back TYPE REF TO z2ui5_if_ajson_mapping, r_ref TYPE REF TO data, o_typedescr type ref to cl_abap_typedescr, - s_rtti_descr type abap_componentdescr, END OF ty_s_attri. TYPES ty_t_attri TYPE SORTED TABLE OF ty_s_attri WITH UNIQUE KEY name. diff --git a/src/01/03/z2ui5_cl_core_app_info.clas.abap b/src/01/03/z2ui5_cl_core_app_info.clas.abap index 7e184c0d..76ab9efb 100644 --- a/src/01/03/z2ui5_cl_core_app_info.clas.abap +++ b/src/01/03/z2ui5_cl_core_app_info.clas.abap @@ -43,10 +43,14 @@ CLASS z2ui5_cl_core_app_info IMPLEMENTATION. METHOD view_display_start. - DATA(page2) = z2ui5_cl_xml_view=>factory( )->shell( )->page( - shownavbutton = abap_false ). + DATA(page2) = z2ui5_cl_xml_view=>factory_popup( + )->dialog( + stretch = abap_true + title = `abap2UI5 - System Information` + afterclose = client->_event( `CLOSE` ) + ). - page2->header_content( )->text( )->title( `abap2UI5 - System Information` )->toolbar_spacer( ). +* page2->header_content( )->text( )->title( `abap2UI5 - System Information` )->toolbar_spacer( ). page2->_z2ui5( )->info_frontend( * device_browser = client->_bind( mv_device_browser ) @@ -93,14 +97,21 @@ CLASS z2ui5_cl_core_app_info IMPLEMENTATION. simple_form2->label( `ABAP for Cloud` ). simple_form2->checkbox( enabled = abap_false selected = z2ui5_cl_util=>rtti_check_lang_version_cloud( ) ). - data(lv_count) = conv string( new z2ui5_cl_core_draft_srv( )->count( ) ). + DATA(lv_count) = CONV string( NEW z2ui5_cl_core_draft_srv( )->count( ) ). simple_form2->toolbar( )->title( `abap2UI5` ). simple_form2->label( `Version ` ). simple_form2->text( z2ui5_if_app=>version ). simple_form2->label( `Draft Entries ` ). simple_form2->text( lv_count ). - client->view_display( page2->stringify( ) ). + page2->footer( )->overflow_toolbar( + )->toolbar_spacer( + )->button( + text = 'close' + press = client->_event( 'CLOSE' ) + type = 'Emphasized' ). + + client->popup_display( page2->stringify( ) ). ENDMETHOD. @@ -122,13 +133,20 @@ CLASS z2ui5_cl_core_app_info IMPLEMENTATION. ENDIF. z2ui5_on_event( ). - view_display_start( ). +* view_display_start( ). ENDMETHOD. METHOD z2ui5_on_event. + CASE client->get( )-event. + + WHEN `CLOSE`. + client->popup_destroy( ). + client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ). + + ENDCASE. ENDMETHOD. diff --git a/src/01/03/z2ui5_cl_core_app_startup.clas.abap b/src/01/03/z2ui5_cl_core_app_startup.clas.abap index e063fd64..16d1b72c 100644 --- a/src/01/03/z2ui5_cl_core_app_startup.clas.abap +++ b/src/01/03/z2ui5_cl_core_app_startup.clas.abap @@ -80,17 +80,18 @@ CLASS z2ui5_cl_core_app_startup IMPLEMENTATION. shownavbutton = abap_false ). - DATA(lv_url_info) = z2ui5_cl_util=>app_get_url( - client = client - classname = 'z2ui5_cl_core_app_info' ). +* DATA(lv_url_info) = z2ui5_cl_util=>app_get_url( +* client = client +* classname = 'z2ui5_cl_core_app_info' ). page2->header_content( )->text( )->title( `abap2UI5 - Developing UI5 Apps Purely in ABAP` )->toolbar_spacer( )->button( text = `System` icon = `sap-icon://information` - press = client->_event_client( val = client->cs_event-open_new_tab - t_arg = VALUE #( ( lv_url_info ) ) ) ). + press = client->_event( `OPEN_INFO` ) ). +* press = client->_event_client( val = client->cs_event-open_new_tab +* t_arg = VALUE #( ( lv_url_info ) ) ) ). DATA(simple_form2) = page2->simple_form( editable = abap_true @@ -238,6 +239,10 @@ CLASS z2ui5_cl_core_app_startup IMPLEMENTATION. CASE client->get( )-event. + WHEN `OPEN_INFO`. + client->nav_app_call( z2ui5_cl_core_app_info=>factory( ) ). + RETURN. + WHEN `BUTTON_CHECK`. IF ms_home-class_editable = abap_false. ms_home-btn_text = `check`. diff --git a/src/02/03/z2ui5_cl_popup_file_download.clas.abap b/src/02/03/z2ui5_cl_popup_file_download.clas.abap index 0c895977..e91bfefd 100644 --- a/src/02/03/z2ui5_cl_popup_file_download.clas.abap +++ b/src/02/03/z2ui5_cl_popup_file_download.clas.abap @@ -54,7 +54,7 @@ CLASS Z2UI5_CL_POPUP_FILE_DOWNLOAD IMPLEMENTATION. r_result->button_text_confirm = i_button_text_confirm. r_result->button_text_cancel = i_button_text_cancel. r_result->mv_value = i_file. - r_result->mv_size = CONV i( strlen( i_file ) / 1000 ). + r_result->mv_size = strlen( i_file ) / 1000. ENDMETHOD.