abap2UI5/src/00/z2ui5_cl_fw_utility_json.clas.testclasses.abap
oblomov b38a9af146
new binding (#503)
* update

* new binding

* update

* new binding

* abaplint

* updates

* update binding

* Update abaplint.jsonc

* Update abaplint.jsonc

* update

* Update abaplint.jsonc

* Update abaplint.jsonc

* Update abaplint.jsonc

* update

* update binding

* abaplint fixes

* abaplint fixes

* added unit tests

* abaplint fixes

* added unit tests

* Update abaplint.jsonc

* more unit tests

* more unit tests

* Update src/00/z2ui5_cl_fw_utility.clas.abap

Co-authored-by: Lars Hvam <larshp@hotmail.com>

* Update src/00/z2ui5_cl_fw_utility.clas.abap

Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com>

* update unit tests

* update

* refactoring binding main

* abaplint fixes

* exception renamind and bind_local

* Delete z2ui5_cl_fw_error.clas.abap

* Delete z2ui5_cl_fw_handler.clas.testclasses.abap

* Delete z2ui5_cl_fw_error.clas.xml

* update refactoring

* refactoring binding

* update

* update binding

* refactoring and unit tests

* abaplint fixes

* unit test cx_fw_error

* abaplint fixes

* abaplint fixes

* refactoring

* Update abaplint.jsonc

* update

* updates

* refactoring and more unit tests

* abaplint fixes

* downport readiness

* downport readiness

* unit test one time binding

* update versions

* refactor bind method

* update unit test order

* unit test order

* unit test order

* unit test order

* unit test order

* unit test order

* unit test order

* update version

* fix one way binding

* refactoring json to any

* bugfix dissolve object ref

* update xml_view->get and unit test naming

* cleanup unit tests

* add check binding with dereferenced data

* nested models fixes

* update xml view with refactored method names

* error handling, exception texts

* fix xml transformation bug

* add more exceptions

* refactoring char to string

* unit test

* unit tests

* unit tests order

* unit test order

* unit test order

* unit test order

* update handling generic data references

* adjust binding, no more auto local binding

* update binding

* abapgit small diffs

* update unit tests

* update unit tests

* update unit tests

* unit tests

* abaplint fixes

---------

Co-authored-by: Lars Hvam <larshp@hotmail.com>
Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com>
2023-08-27 14:39:52 +02:00

85 lines
2.3 KiB
ABAP

CLASS ltcl_unit_01_json DEFINITION FINAL FOR TESTING
DURATION long
RISK LEVEL harmless.
PRIVATE SECTION.
METHODS test_json_attri FOR TESTING RAISING cx_static_check.
METHODS test_json_object FOR TESTING RAISING cx_static_check.
METHODS test_json_struc FOR TESTING RAISING cx_static_check.
METHODS test_create_json FOR TESTING RAISING cx_static_check.
ENDCLASS.
CLASS ltcl_unit_01_json IMPLEMENTATION.
METHOD test_json_attri.
DATA(lo_tree) = NEW z2ui5_cl_fw_utility_json( ).
lo_tree->add_attribute( n = `AAA`
v = `BBB` ).
DATA(lv_result) = lo_tree->stringify( ).
IF `{"AAA":"BBB"}` <> lv_result.
cl_abap_unit_assert=>fail( 'json tree - wrong stringify attributes' ).
ENDIF.
ENDMETHOD.
METHOD test_json_object.
DATA(lo_tree) = NEW z2ui5_cl_fw_utility_json( ).
lo_tree->add_attribute_object( `CCC` )->add_attribute( n = `AAA`
v = `BBB` ).
DATA(lv_result) = lo_tree->stringify( ).
IF `{"CCC":{"AAA":"BBB"}}` <> lv_result.
cl_abap_unit_assert=>fail( 'json tree - wrong stringify object attributes' ).
ENDIF.
ENDMETHOD.
METHOD test_json_struc.
DATA(lo_tree) = NEW z2ui5_cl_fw_utility_json( ).
TYPES:
BEGIN OF ty_s_test,
comp1 TYPE string,
comp2 TYPE string,
END OF ty_s_test.
DATA(ls_test) = VALUE ty_s_test( comp1 = `AAA` comp2 = `BBB` ).
lo_tree->add_attribute_object( `CCC` )->add_attribute_struc( ls_test ).
DATA(lv_result) = lo_tree->stringify( ).
IF `{"CCC":{"COMP1":"AAA","COMP2":"BBB"}}` <> lv_result.
cl_abap_unit_assert=>fail( 'json tree - wrong stringify structure' ).
ENDIF.
ENDMETHOD.
METHOD test_create_json.
DATA(lo_json) = z2ui5_cl_fw_utility_json=>factory( `{"CCC":{"COMP1":"AAA","COMP2":"BBB"}}` ).
DATA(lo_attri) = lo_json->get_attribute( `CCC` )->get_attribute( `COMP2` ).
DATA lr_ref TYPE REF TO data.
lr_ref = lo_attri->get_val_ref( ).
FIELD-SYMBOLS <any> TYPE any.
ASSIGN lr_ref->* TO <any>.
IF <any> <> `BBB`.
cl_abap_unit_assert=>fail( quit = 5 ).
ENDIF.
DATA(lv_val) = lo_attri->get_val( ).
IF lv_val <> `BBB`.
cl_abap_unit_assert=>fail( quit = 5 ).
ENDIF.
ENDMETHOD.
ENDCLASS.