ajson, Automatic Update (#5764)

This commit is contained in:
github-actions[bot] 2022-09-19 07:20:50 +02:00 committed by GitHub
parent 29622bdf7b
commit b60007c752
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 94 additions and 7 deletions

View File

@ -608,6 +608,7 @@ CLASS lcl_json_to_abap DEFINITION FINAL.
METHODS constructor
IMPORTING
!iv_corresponding TYPE abap_bool DEFAULT abap_false
!ii_custom_mapping TYPE REF TO zif_abapgit_ajson_mapping OPTIONAL.
METHODS to_abap
@ -648,6 +649,7 @@ CLASS lcl_json_to_abap DEFINITION FINAL.
DATA mr_nodes TYPE REF TO zif_abapgit_ajson=>ty_nodes_ts.
DATA mi_custom_mapping TYPE REF TO zif_abapgit_ajson_mapping.
DATA mv_corresponding TYPE abap_bool.
METHODS any_to_abap
IMPORTING
@ -682,6 +684,7 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
METHOD constructor.
mi_custom_mapping = ii_custom_mapping.
mv_corresponding = iv_corresponding.
ENDMETHOD.
METHOD to_abap.
@ -748,7 +751,12 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
EXCEPTIONS
component_not_found = 4 ).
IF sy-subrc <> 0.
zcx_abapgit_ajson_error=>raise( |Path not found| ).
IF mv_corresponding = abap_false.
zcx_abapgit_ajson_error=>raise( |Path not found| ).
ELSE.
CLEAR rs_node_type.
RETURN.
ENDIF.
ENDIF.
WHEN ''. " Root node
@ -814,9 +822,15 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
" Get or create type cache record
IF is_parent_type-type_kind <> lif_kind=>table OR ls_node_type-type_kind IS INITIAL.
" table records are the same, no need to refetch twice
ls_node_type = get_node_type(
is_node = <n>
is_parent_type = is_parent_type ).
IF mv_corresponding = abap_true AND ls_node_type IS INITIAL.
CONTINUE.
ENDIF.
ENDIF.
" Validate node type
@ -1034,7 +1048,13 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
zcx_abapgit_ajson_error=>raise( 'Unexpected error calculating timestamp' ).
ENDTRY.
rv_result = lv_timestamp.
IF lv_timestamp IS NOT INITIAL.
cl_abap_tstmp=>move(
EXPORTING
tstmp_src = lv_timestamp
IMPORTING
tstmp_tgt = rv_result ).
ENDIF.
ENDMETHOD.

View File

@ -1373,6 +1373,12 @@ CLASS ltcl_json_to_abap DEFINITION
METHODS to_abap_negative
FOR TESTING
RAISING zcx_abapgit_ajson_error.
METHODS to_abap_corresponding
FOR TESTING
RAISING zcx_abapgit_ajson_error.
METHODS to_abap_corresponding_negative
FOR TESTING
RAISING zcx_abapgit_ajson_error.
ENDCLASS.
@ -1869,6 +1875,68 @@ CLASS ltcl_json_to_abap IMPLEMENTATION.
ENDMETHOD.
METHOD to_abap_corresponding.
DATA lo_cut TYPE REF TO lcl_json_to_abap.
DATA ls_act TYPE ty_struc.
DATA ls_exp TYPE ty_struc.
DATA lo_nodes TYPE REF TO lcl_nodes_helper.
CREATE OBJECT lo_nodes.
lo_nodes->add( ' | |object | | ' ).
lo_nodes->add( '/ |a |str |test | ' ).
lo_nodes->add( '/ |c |num |24022022 | ' ).
ls_exp-a = 'test'.
CREATE OBJECT lo_cut
EXPORTING
iv_corresponding = abap_true.
lo_cut->to_abap(
EXPORTING
it_nodes = lo_nodes->sorted( )
CHANGING
c_container = ls_act ).
cl_abap_unit_assert=>assert_equals(
act = ls_act
exp = ls_exp ).
ENDMETHOD.
METHOD to_abap_corresponding_negative.
DATA lo_cut TYPE REF TO lcl_json_to_abap.
DATA ls_act TYPE ty_struc.
DATA ls_exp TYPE ty_struc.
DATA lo_nodes TYPE REF TO lcl_nodes_helper.
DATA lx TYPE REF TO zcx_abapgit_ajson_error.
CREATE OBJECT lo_nodes.
lo_nodes->add( ' | |object | | ' ).
lo_nodes->add( '/ |a |str |test | ' ).
lo_nodes->add( '/ |c |num |24022022 | ' ).
ls_exp-a = 'test'.
ls_exp-b = 24022022.
TRY.
CREATE OBJECT lo_cut.
lo_cut->to_abap(
EXPORTING
it_nodes = lo_nodes->sorted( )
CHANGING
c_container = ls_act ).
cl_abap_unit_assert=>fail( ).
CATCH zcx_abapgit_ajson_error INTO lx.
cl_abap_unit_assert=>assert_equals(
act = lx->message
exp = 'Path not found' ).
ENDTRY.
ENDMETHOD.
ENDCLASS.
**********************************************************************
@ -3562,13 +3630,14 @@ CLASS ltcl_abap_to_json IMPLEMENTATION.
DATA lo_nodes_exp TYPE REF TO lcl_nodes_helper.
DATA lt_nodes TYPE zif_abapgit_ajson=>ty_nodes_tt.
DATA lv_timezone TYPE tzonref-tzone VALUE ''.
DATA lv_timestamp TYPE timestamp.
CREATE OBJECT lo_nodes_exp.
lo_nodes_exp->add( ' | |str |2022-08-31T00:00:00Z||' ).
CONVERT DATE '20220831' TIME '000000'
INTO TIME STAMP lv_timestamp TIME ZONE ''.
INTO TIME STAMP lv_timestamp TIME ZONE lv_timezone.
lt_nodes = lcl_abap_to_json=>convert( lcl_abap_to_json=>format_timestamp( lv_timestamp ) ).
cl_abap_unit_assert=>assert_equals(

View File

@ -127,22 +127,20 @@
{"object": "ZCL_ABAPGIT_FOLDER_LOGIC", "class": "ltcl_folder_logic", "method": "full3", "note": "??"},
{"object": "ZCL_ABAPGIT_AJSON", "class": "ltcl_json_to_abap", "method": "to_abap_array_of_arrays", "note": "Expected table to contain 2 rows, got 4"},
{"object": "ZCL_ABAPGIT_AJSON", "class": "ltcl_writer_test", "method": "overwrite_w_keep_order_touch", "note": "some sorting"},
{"object": "ZCL_ABAPGIT_AJSON", "class": "ltcl_writer_test", "method": "overwrite_w_keep_order_set", "note": "some sorting"},
{"object": "ZCL_ABAPGIT_AJSON", "class": "ltcl_writer_test", "method": "set_tab_hashed", "note": "runtime error, SortByLengthZero"},
{"object": "ZCL_ABAPGIT_AJSON", "class": "ltcl_integrated", "method": "reader", "note": "Path not found @/false"},
{"object": "ZCL_ABAPGIT_AJSON", "class": "ltcl_integrated", "method": "array_index", "note": "Expected '[object Object]', got '[object Object]"},
{"object": "ZCL_ABAPGIT_AJSON", "class": "ltcl_integrated", "method": "array_simple", "note": "sorting is wrong"},
{"object": "ZCL_ABAPGIT_AJSON", "class": "ltcl_integrated", "method": "item_order_integrated", "note": "some sorting"},
{"object": "ZCL_ABAPGIT_AJSON", "class": "ltcl_integrated", "method": "stringify"},
{"object": "ZCL_ABAPGIT_AJSON", "class": "ltcl_abap_to_json", "method": "set_value_timestamp", "note": " https://github.com/sbcgua/ajson/pull/131 "},
{"object": "ZCL_ABAPGIT_AJSON_MAPPING", "class": "ltcl_camel_case", "method": "to_abap", "note": "secondary key fields? READ WITH KEY, Path not found @/FieldData"},
{"object": "ZCL_ABAPGIT_UI_INJECTOR", "class": "ltcl_no_dependency_injection", "method": "no_injection", "note": "RTTI? class absolute_name"},
{"object": "ZCL_ABAPGIT_UI_INJECTOR", "class": "ltcl_simple_dependency_inject", "method": "simple_injection", "note": "RTTI?"},
{"object": "ZCL_ABAPGIT_AJSON_MAPPING", "class": "ltcl_camel_case", "method": "to_abap", "note": "secondary key fields? READ WITH KEY, Path not found @/FieldData"},
{"object": "ZCL_ABAPGIT_REQUIREMENT_HELPER", "class": "ltcl_lower_release", "method": "empty_patch", "note": "Void type: CVERS_SDU"},
{"object": "ZCL_ABAPGIT_REQUIREMENT_HELPER", "class": "ltcl_lower_release", "method": "lower_patch", "note": "Void type: CVERS_SDU"},
{"object": "ZCL_ABAPGIT_REQUIREMENT_HELPER", "class": "ltcl_lower_release", "method": "same_patch", "note": "Void type: CVERS_SDU"},