All files / src/json zcl_abapgit_ajson_utilities.clas.testclasses.abap

100% Statements 548/548
100% Branches 7/7
100% Functions 7/7
100% Lines 548/548

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 5491x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 36x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
**********************************************************************
* UTIL
**********************************************************************
 
CLASS lcl_nodes_helper DEFINITION FINAL.
  PUBLIC SECTION.
 
    DATA mt_nodes TYPE zif_abapgit_ajson_types=>ty_nodes_tt READ-ONLY.
 
    METHODS add
      IMPORTING
        iv_str TYPE string.
    METHODS sorted
      RETURNING
        VALUE(rt_nodes) TYPE zif_abapgit_ajson_types=>ty_nodes_ts.
 
ENDCLASS.
 
CLASS lcl_nodes_helper IMPLEMENTATION.
  METHOD add.
 
    FIELD-SYMBOLS <n> LIKE LINE OF mt_nodes.
    DATA lv_children TYPE string.
    DATA lv_index TYPE string.
 
    APPEND INITIAL LINE TO mt_nodes ASSIGNING <n>.
 
    SPLIT iv_str AT '|' INTO
      <n>-path
      <n>-name
      <n>-type
      <n>-value
      lv_index
      lv_children.
    CONDENSE <n>-path.
    CONDENSE <n>-name.
    CONDENSE <n>-type.
    CONDENSE <n>-value.
    <n>-index = lv_index.
    <n>-children = lv_children.
 
  ENDMETHOD.
 
  METHOD sorted.
    rt_nodes = mt_nodes.
  ENDMETHOD.
ENDCLASS.
 
**********************************************************************
* PARSER
**********************************************************************
 
CLASS ltcl_parser_test DEFINITION FINAL
  FOR TESTING
  RISK LEVEL HARMLESS
  DURATION SHORT.
 
  PUBLIC SECTION.
 
    CLASS-METHODS sample_json
      IMPORTING
        iv_separator   TYPE string OPTIONAL
      RETURNING
        VALUE(rv_json) TYPE string.
 
ENDCLASS.
 
CLASS ltcl_parser_test IMPLEMENTATION.
 
  METHOD sample_json.
 
    rv_json =
      '{\n' &&
      '  "string": "abc",\n' &&
      '  "number": 123,\n' &&
      '  "float": 123.45,\n' &&
      '  "boolean": true,\n' &&
      '  "false": false,\n' &&
      '  "null": null,\n' &&
      '  "date": "2020-03-15",\n' &&
      '  "issues": [\n' &&
      '    {\n' &&
      '      "message": "Indentation problem ...",\n' &&
      '      "key": "indentation",\n' &&
      '      "start": {\n' &&
      '        "row": 4,\n' &&
      '        "col": 3\n' &&
      '      },\n' &&
      '      "end": {\n' &&
      '        "row": 4,\n' &&
      '        "col": 26\n' &&
      '      },\n' &&
      '      "filename": "./zxxx.prog.abap"\n' &&
      '    },\n' &&
      '    {\n' &&
      '      "message": "Remove space before XXX",\n' &&
      '      "key": "space_before_dot",\n' &&
      '      "start": {\n' &&
      '        "row": 3,\n' &&
      '        "col": 21\n' &&
      '      },\n' &&
      '      "end": {\n' &&
      '        "row": 3,\n' &&
      '        "col": 22\n' &&
      '      },\n' &&
      '      "filename": "./zxxx.prog.abap"\n' &&
      '    }\n' &&
      '  ]\n' &&
      '}'.
 
    REPLACE ALL OCCURRENCES OF '\n' IN rv_json WITH iv_separator.
 
  ENDMETHOD.
 
ENDCLASS.
 
**********************************************************************
* JSON UTILITIES
**********************************************************************
 
CLASS ltcl_json_utils DEFINITION
  FOR TESTING
  RISK LEVEL HARMLESS
  DURATION SHORT
  FINAL.
 
  PRIVATE SECTION.
 
    METHODS json_diff FOR TESTING RAISING zcx_abapgit_ajson_error.
    METHODS json_diff_types FOR TESTING RAISING zcx_abapgit_ajson_error.
    METHODS json_diff_arrays FOR TESTING RAISING zcx_abapgit_ajson_error.
    METHODS json_merge FOR TESTING RAISING zcx_abapgit_ajson_error.
    METHODS json_sort FOR TESTING RAISING zcx_abapgit_ajson_error.
    METHODS is_equal FOR TESTING RAISING zcx_abapgit_ajson_error.
 
ENDCLASS.
 
CLASS ltcl_json_utils IMPLEMENTATION.
 
  METHOD json_diff.
 
    DATA:
      lv_json       TYPE string,
      lo_util       TYPE REF TO zcl_abapgit_ajson_utilities,
      lo_insert     TYPE REF TO zif_abapgit_ajson,
      lo_delete     TYPE REF TO zif_abapgit_ajson,
      lo_change     TYPE REF TO zif_abapgit_ajson,
      lo_insert_exp TYPE REF TO lcl_nodes_helper,
      lo_delete_exp TYPE REF TO lcl_nodes_helper,
      lo_change_exp TYPE REF TO lcl_nodes_helper.
 
    lv_json =
      '{\n' &&
      '  "string": "abc",\n' && " no changes
      '  "number": 789,\n' &&   " changed value
      '  "float": 123.45,\n' &&
      '  "boolean": "true",\n' && " changed type
      '  "true": true,\n' &&    " insert
*      '  "false": false,\n' &&    " delete
      '  "null": null,\n' &&
      '  "date": "2020-03-15",\n' &&
      '  "issues": [\n' &&
      '    {\n' &&
      '      "message": "Indentation problem ...",\n' &&
      '      "key": "indentation",\n' &&
      '      "start": {\n' &&
      '        "row": 5,\n' &&  " array change
      '        "col": 3\n' &&
      '      },\n' &&
      '      "end": {\n' &&
      '        "new": 1,\n' &&  " array insert
*      '        "row": 4,\n' && " array delete
      '        "col": 26\n' &&
      '      },\n' &&
      '      "filename": "./zxxx.prog.abap"\n' &&
      '    },\n' &&
      '    {\n' &&
      '      "message": "Remove space before XXX",\n' &&
      '      "key": "space_before_dot",\n' &&
      '      "start": {\n' &&
      '        "row": 3,\n' &&
      '        "col": 21\n' &&
      '      },\n' &&
      '      "end": {\n' &&
      '        "row": 3,\n' &&
      '        "col": 22\n' &&
      '      },\n' &&
      '      "filename": "./zxxx.prog.abap"\n' &&
      '    }\n' &&
      '  ]\n' &&
      '}'.
 
    REPLACE ALL OCCURRENCES OF '\n' IN lv_json WITH cl_abap_char_utilities=>newline.
 
    CREATE OBJECT lo_insert_exp.
    lo_insert_exp->add( '                |        |object |        |0|3' ).
    lo_insert_exp->add( '/               |boolean |str    |true    |0|0' ). " changed type (insert new)
    lo_insert_exp->add( '/               |issues  |array  |        |0|1' ).
    lo_insert_exp->add( '/               |true    |bool   |true    |0|0' ). " insert
    lo_insert_exp->add( '/issues/        |1       |object |        |1|1' ).
    lo_insert_exp->add( '/issues/1/      |end     |object |        |0|1' ).
    lo_insert_exp->add( '/issues/1/end/  |new     |num    |1       |0|0' ). " array insert
 
    CREATE OBJECT lo_delete_exp.
    lo_delete_exp->add( '                |        |object |        |0|3' ).
    lo_delete_exp->add( '/               |boolean |bool   |true    |0|0' ). " changed type (delete old)
    lo_delete_exp->add( '/               |false   |bool   |false   |0|0' ). " delete
    lo_delete_exp->add( '/               |issues  |array  |        |0|1' ).
    lo_delete_exp->add( '/issues/        |1       |object |        |1|1' ).
    lo_delete_exp->add( '/issues/1/      |end     |object |        |0|1' ).
    lo_delete_exp->add( '/issues/1/end/  |row     |num    |4       |0|0' ). " array delete
 
    CREATE OBJECT lo_change_exp.
    lo_change_exp->add( '                |        |object |        |0|2' ).
    lo_change_exp->add( '/               |issues  |array  |        |0|1' ).
    lo_change_exp->add( '/               |number  |num    |789     |0|0' ). " changed value
    lo_change_exp->add( '/issues/        |1       |object |        |1|1' ).
    lo_change_exp->add( '/issues/1/      |start   |object |        |0|1' ).
    lo_change_exp->add( '/issues/1/start/|row     |num    |5       |0|0' ). " array change
 
    CREATE OBJECT lo_util.
 
    lo_util->diff(
      EXPORTING
        iv_json_a = ltcl_parser_test=>sample_json( )
        iv_json_b = lv_json
      IMPORTING
        eo_insert = lo_insert
        eo_delete = lo_delete
        eo_change = lo_change ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lo_insert->mt_json_tree
      exp = lo_insert_exp->mt_nodes ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lo_delete->mt_json_tree
      exp = lo_delete_exp->mt_nodes ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lo_change->mt_json_tree
      exp = lo_change_exp->mt_nodes ).
 
  ENDMETHOD.
 
  METHOD json_diff_types.
 
    DATA:
      lv_json_a     TYPE string,
      lv_json_b     TYPE string,
      lo_util       TYPE REF TO zcl_abapgit_ajson_utilities,
      lo_insert     TYPE REF TO zif_abapgit_ajson,
      lo_delete     TYPE REF TO zif_abapgit_ajson,
      lo_change     TYPE REF TO zif_abapgit_ajson,
      lo_insert_exp TYPE REF TO lcl_nodes_helper,
      lo_delete_exp TYPE REF TO lcl_nodes_helper.
 
    " Change single value to array
    lv_json_a =
      '{\n' &&
      '  "string": "abc",\n' &&
      '  "number": 123\n' &&
      '}'.
 
    lv_json_b =
      '{\n' &&
      '  "string": [\n' &&
      '    "a",\n' &&
      '    "b",\n' &&
      '    "c"\n' &&
      '  ],\n' &&
      '  "number": 123\n' &&
      '}'.
 
    REPLACE ALL OCCURRENCES OF '\n' IN lv_json_a WITH cl_abap_char_utilities=>newline.
    REPLACE ALL OCCURRENCES OF '\n' IN lv_json_b WITH cl_abap_char_utilities=>newline.
 
    CREATE OBJECT lo_insert_exp.
    lo_insert_exp->add( '                |        |object |        |0|1' ).
    lo_insert_exp->add( '/               |string  |array  |        |0|3' ).
    lo_insert_exp->add( '/string/        |1       |str    |a       |1|0' ).
    lo_insert_exp->add( '/string/        |2       |str    |b       |2|0' ).
    lo_insert_exp->add( '/string/        |3       |str    |c       |3|0' ).
 
    CREATE OBJECT lo_delete_exp.
    lo_delete_exp->add( '                |        |object |        |0|1' ).
    lo_delete_exp->add( '/               |string  |str    |abc     |0|0' ).
 
    CREATE OBJECT lo_util.
 
    lo_util->diff(
      EXPORTING
        iv_json_a = lv_json_a
        iv_json_b = lv_json_b
      IMPORTING
        eo_insert = lo_insert
        eo_delete = lo_delete
        eo_change = lo_change ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lo_insert->mt_json_tree
      exp = lo_insert_exp->mt_nodes ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lo_delete->mt_json_tree
      exp = lo_delete_exp->mt_nodes ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( lo_change->mt_json_tree )
      exp = 0 ).
 
    " Change array to single value
    lo_util->diff(
      EXPORTING
        iv_json_a = lv_json_b
        iv_json_b = lv_json_a
      IMPORTING
        eo_insert = lo_insert
        eo_delete = lo_delete
        eo_change = lo_change ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lo_insert->mt_json_tree
      exp = lo_delete_exp->mt_nodes ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lo_delete->mt_json_tree
      exp = lo_insert_exp->mt_nodes ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( lo_change->mt_json_tree )
      exp = 0 ).
 
  ENDMETHOD.
 
  METHOD json_diff_arrays.
 
    DATA:
      lv_json_a     TYPE string,
      lv_json_b     TYPE string,
      lo_util       TYPE REF TO zcl_abapgit_ajson_utilities,
      lo_insert     TYPE REF TO zif_abapgit_ajson,
      lo_delete     TYPE REF TO zif_abapgit_ajson,
      lo_change     TYPE REF TO zif_abapgit_ajson,
      lo_insert_exp TYPE REF TO lcl_nodes_helper.
 
    " Add empty array
    lv_json_a =
      '{\n' &&
      '  "number": 123\n' &&
      '}'.
 
    lv_json_b =
      '{\n' &&
      '  "names": [],\n' &&
      '  "number": 123\n' &&
      '}'.
 
    REPLACE ALL OCCURRENCES OF '\n' IN lv_json_a WITH cl_abap_char_utilities=>newline.
    REPLACE ALL OCCURRENCES OF '\n' IN lv_json_b WITH cl_abap_char_utilities=>newline.
 
    CREATE OBJECT lo_util.
 
    " Empty arrays are ignored by default
    lo_util->diff(
      EXPORTING
        iv_json_a = lv_json_a
        iv_json_b = lv_json_b
      IMPORTING
        eo_insert = lo_insert
        eo_delete = lo_delete
        eo_change = lo_change ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( lo_insert->mt_json_tree )
      exp = 0 ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( lo_delete->mt_json_tree )
      exp = 0 ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( lo_change->mt_json_tree )
      exp = 0 ).
 
    " Keep empty arrays
    lo_util->diff(
      EXPORTING
        iv_json_a = lv_json_a
        iv_json_b = lv_json_b
        iv_keep_empty_arrays = abap_true
      IMPORTING
        eo_insert = lo_insert
        eo_delete = lo_delete
        eo_change = lo_change ).
 
    CREATE OBJECT lo_insert_exp.
    lo_insert_exp->add( '                |        |object |        |0|1' ).
    lo_insert_exp->add( '/               |names   |array  |        |0|0' ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lo_insert->mt_json_tree
      exp = lo_insert_exp->mt_nodes ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( lo_delete->mt_json_tree )
      exp = 0 ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lines( lo_change->mt_json_tree )
      exp = 0 ).
 
  ENDMETHOD.
 
  METHOD json_merge.
 
    DATA:
      lv_json_a    TYPE string,
      lv_json_b    TYPE string,
      lo_util      TYPE REF TO zcl_abapgit_ajson_utilities,
      lo_merge     TYPE REF TO zif_abapgit_ajson,
      lo_merge_exp TYPE REF TO lcl_nodes_helper.
 
    " Merge new value of b into a
    lv_json_a =
      '{\n' &&
      '  "string": [\n' &&
      '    "a",\n' &&
      '    "c"\n' &&
      '  ],\n' &&
      '  "number": 123\n' &&
      '}'.
 
    lv_json_b =
      '{\n' &&
      '  "string": [\n' &&
      '    "a",\n' &&
      '    "b"\n' && " new array value
      '  ],\n' &&
      '  "number": 456,\n' && " existing values are not overwritten
      '  "float": 123.45\n' &&
      '}'.
 
    REPLACE ALL OCCURRENCES OF '\n' IN lv_json_a WITH cl_abap_char_utilities=>newline.
    REPLACE ALL OCCURRENCES OF '\n' IN lv_json_b WITH cl_abap_char_utilities=>newline.
 
    CREATE OBJECT lo_merge_exp.
    lo_merge_exp->add( '                |        |object |        |0|3' ).
    lo_merge_exp->add( '/               |float   |num    |123.45  |0|0' ).
    lo_merge_exp->add( '/               |number  |num    |123     |0|0' ).
    lo_merge_exp->add( '/               |string  |array  |        |0|3' ).
    lo_merge_exp->add( '/string/        |1       |str    |a       |1|0' ).
    lo_merge_exp->add( '/string/        |2       |str    |c       |2|0' ).
    lo_merge_exp->add( '/string/        |3       |str    |b       |3|0' ).
 
    CREATE OBJECT lo_util.
 
    lo_merge = lo_util->merge(
      iv_json_a = lv_json_a
      iv_json_b = lv_json_b ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lo_merge->mt_json_tree
      exp = lo_merge_exp->mt_nodes ).
 
  ENDMETHOD.
 
  METHOD json_sort.
 
    DATA:
      lv_json       TYPE string,
      lo_util       TYPE REF TO zcl_abapgit_ajson_utilities,
      lv_sorted     TYPE string,
      lv_sorted_exp TYPE string.
 
    lv_json =
      '{\n' &&
      '  "string": "abc",\n' &&
      '  "number": 789,\n' &&
      '  "float": 123.45,\n' &&
      '  "boolean": "true",\n' &&
      '  "true": true,\n' &&
      '  "false": false,\n' &&
      '  "null": null,\n' &&
      '  "date": "2020-03-15"\n' &&
      '}'.
 
    REPLACE ALL OCCURRENCES OF '\n' IN lv_json WITH cl_abap_char_utilities=>newline.
 
    lv_sorted_exp =
      '{\n' &&
      '  "boolean": "true",\n' &&
      '  "date": "2020-03-15",\n' &&
      '  "false": false,\n' &&
      '  "float": 123.45,\n' &&
      '  "null": null,\n' &&
      '  "number": 789,\n' &&
      '  "string": "abc",\n' &&
      '  "true": true\n' &&
      '}'.
 
    REPLACE ALL OCCURRENCES OF '\n' IN lv_sorted_exp WITH cl_abap_char_utilities=>newline.
 
    CREATE OBJECT lo_util.
 
    lv_sorted = lo_util->sort( iv_json = lv_json ).
 
    cl_abap_unit_assert=>assert_equals(
      act = lv_sorted
      exp = lv_sorted_exp ).
 
  ENDMETHOD.
 
  METHOD is_equal.
 
    cl_abap_unit_assert=>assert_equals(
      act = zcl_abapgit_ajson_utilities=>new( )->is_equal(
        ii_json_a = zcl_abapgit_ajson=>parse( '{"a":1,"b":2}' )
        ii_json_b = zcl_abapgit_ajson=>parse( '{"a":1,"b":2}' ) )
      exp = abap_true ).
 
    cl_abap_unit_assert=>assert_equals(
      act = zcl_abapgit_ajson_utilities=>new( )->is_equal(
        iv_json_a = '{"a":1,"b":2}'
        iv_json_b = '{"a":1,"b":2}' )
      exp = abap_true ).
 
    cl_abap_unit_assert=>assert_equals(
      act = zcl_abapgit_ajson_utilities=>new( )->is_equal(
        iv_json_a = '{"a":1,"b":2}'
        iv_json_b = '{"a":1,"b":3}' )
      exp = abap_false ).
 
    cl_abap_unit_assert=>assert_equals(
      act = zcl_abapgit_ajson_utilities=>new( )->is_equal(
        iv_json_a = '{"a":1,"b":2}'
        iv_json_b = '{"a":1,"b":2,"c":3}' )
      exp = abap_false ).
 
    cl_abap_unit_assert=>assert_equals(
      act = zcl_abapgit_ajson_utilities=>new( )->is_equal(
        iv_json_a = '{"a":1,"b":2,"c":3}'
        iv_json_b = '{"a":1,"b":2}' )
      exp = abap_false ).
 
  ENDMETHOD.
 
ENDCLASS.