Skip to content

Commit 86d74f4

Browse files
author
Jonas Sobotta
committed
Add additional example for pattern test type
1 parent a8d2446 commit 86d74f4

3 files changed

+50
-7
lines changed

src/zcl_aff_test_types.clas.abap

+17-4
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,28 @@ CLASS zcl_aff_test_types DEFINITION
6767
default_link TYPE default_link,
6868
END OF struc_link_wrong_type.
6969

70+
TYPES:
71+
"! $pattern '[a-Z]*'
72+
ty_string TYPE string.
73+
74+
TYPES:
75+
"! <p class="shorttext">Structure With Pattern Annotation</p>
76+
"! Structure with pattern annotation
77+
BEGIN OF string_pattern_complex,
78+
"! <p class="shorttext">String with pattern</p>
79+
"! description
80+
string_pattern TYPE ty_string,
81+
END OF string_pattern_complex.
82+
7083
TYPES:
7184
"! <p class="shorttext">Structure With Pattern Annotation</p>
7285
"! Structure with pattern annotation
73-
BEGIN OF string_pattern,
86+
BEGIN OF string_pattern_simple,
7487
"! <p class="shorttext">String with pattern</p>
7588
"! description
76-
"! $pattern '[a-Z]*'
77-
string_pattern TYPE string,
78-
END OF string_pattern.
89+
"! $PATTERN '[a-Z]*'
90+
string_pattern_simple TYPE string,
91+
END OF string_pattern_simple.
7992

8093
TYPES:
8194
"! in ST val(I()) only allow integers

src/zcl_aff_writer.clas.abap

+3
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@ CLASS zcl_aff_writer IMPLEMENTATION.
567567
IF abap_doc_base-content_media_type IS INITIAL.
568568
abap_doc_base-content_media_type = abap_doc_additional-content_media_type.
569569
ENDIF.
570+
IF abap_doc_base-pattern IS INITIAL.
571+
abap_doc_base-pattern = abap_doc_additional-pattern.
572+
ENDIF.
570573
ENDMETHOD.
571574

572575

src/zcl_aff_writer_json_schema.clas.testclasses.abap

+30-3
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@ CLASS ltcl_json_writer_abap_doc DEFINITION FINAL FOR TESTING
560560
content_media_type_integer FOR TESTING RAISING cx_static_check,
561561
content_media_type_string FOR TESTING RAISING cx_static_check,
562562
encoding_type_next_level FOR TESTING RAISING cx_static_check,
563-
pattern FOR TESTING RAISING cx_static_check.
563+
pattern_simple FOR TESTING RAISING cx_static_check,
564+
pattern_complex FOR TESTING RAISING cx_static_check.
564565

565566
ENDCLASS.
566567

@@ -2790,8 +2791,34 @@ CLASS ltcl_json_writer_abap_doc IMPLEMENTATION.
27902791
ENDMETHOD.
27912792

27922793

2793-
METHOD pattern.
2794-
DATA(act_schema) = test_generator->generate_type( VALUE zcl_aff_test_types=>string_pattern( ) ).
2794+
METHOD pattern_simple.
2795+
DATA(act_schema) = test_generator->generate_type( VALUE zcl_aff_test_types=>string_pattern_simple( ) ).
2796+
DATA(exp_schema) = VALUE string_table(
2797+
( ` { ` )
2798+
( | "$comment": "This file is autogenerated, do not edit manually, see { zcl_aff_writer_json_schema=>c_link_to_repository } for more information.", | )
2799+
( | "$schema": "{ zcl_aff_writer_json_schema=>c_schema_specification }",| )
2800+
( | "$id": "{ schema_id }",| )
2801+
( ` "title": "Structure With Pattern Annotation", ` )
2802+
( ` "description": "Structure with pattern annotation", ` )
2803+
( ` "type": "object", ` )
2804+
( ` "properties": { ` )
2805+
( ` "stringPattern": { ` )
2806+
( ` "title": "String with pattern",` )
2807+
( ` "description": "description",` )
2808+
( ` "type": "string", ` )
2809+
( ` "pattern": "[a-Z]*" ` )
2810+
( ` } ` )
2811+
( ` }, ` )
2812+
( ` "additionalProperties": false ` )
2813+
( ` } ` )
2814+
( ) ).
2815+
zcl_aff_tools_unit_test_helper=>assert_equals_ignore_spaces( act_data = act_schema exp_data = exp_schema ).
2816+
log = cut->zif_aff_writer~get_log( ).
2817+
zcl_aff_tools_unit_test_helper=>assert_log_has_no_message( log = log message_severity_threshold = zif_aff_log=>c_message_type-info ).
2818+
ENDMETHOD.
2819+
2820+
METHOD pattern_complex.
2821+
DATA(act_schema) = test_generator->generate_type( VALUE zcl_aff_test_types=>string_pattern_complex( ) ).
27952822
DATA(exp_schema) = VALUE string_table(
27962823
( ` { ` )
27972824
( | "$comment": "This file is autogenerated, do not edit manually, see { zcl_aff_writer_json_schema=>c_link_to_repository } for more information.", | )

0 commit comments

Comments
 (0)