Skip to content

Commit

Permalink
Add additional example for pattern test type
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Sobotta committed Jun 21, 2024
1 parent a8d2446 commit 86d74f4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
21 changes: 17 additions & 4 deletions src/zcl_aff_test_types.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,28 @@ CLASS zcl_aff_test_types DEFINITION
default_link TYPE default_link,
END OF struc_link_wrong_type.

TYPES:
"! $pattern '[a-Z]*'
ty_string TYPE string.

TYPES:
"! <p class="shorttext">Structure With Pattern Annotation</p>
"! Structure with pattern annotation
BEGIN OF string_pattern_complex,
"! <p class="shorttext">String with pattern</p>
"! description
string_pattern TYPE ty_string,
END OF string_pattern_complex.

TYPES:
"! <p class="shorttext">Structure With Pattern Annotation</p>
"! Structure with pattern annotation
BEGIN OF string_pattern,
BEGIN OF string_pattern_simple,
"! <p class="shorttext">String with pattern</p>
"! description
"! $pattern '[a-Z]*'
string_pattern TYPE string,
END OF string_pattern.
"! $PATTERN '[a-Z]*'
string_pattern_simple TYPE string,
END OF string_pattern_simple.

TYPES:
"! in ST val(I()) only allow integers
Expand Down
3 changes: 3 additions & 0 deletions src/zcl_aff_writer.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ CLASS zcl_aff_writer IMPLEMENTATION.
IF abap_doc_base-content_media_type IS INITIAL.
abap_doc_base-content_media_type = abap_doc_additional-content_media_type.
ENDIF.
IF abap_doc_base-pattern IS INITIAL.
abap_doc_base-pattern = abap_doc_additional-pattern.
ENDIF.
ENDMETHOD.


Expand Down
33 changes: 30 additions & 3 deletions src/zcl_aff_writer_json_schema.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ CLASS ltcl_json_writer_abap_doc DEFINITION FINAL FOR TESTING
content_media_type_integer FOR TESTING RAISING cx_static_check,
content_media_type_string FOR TESTING RAISING cx_static_check,
encoding_type_next_level FOR TESTING RAISING cx_static_check,
pattern FOR TESTING RAISING cx_static_check.
pattern_simple FOR TESTING RAISING cx_static_check,
pattern_complex FOR TESTING RAISING cx_static_check.

ENDCLASS.

Expand Down Expand Up @@ -2790,8 +2791,34 @@ CLASS ltcl_json_writer_abap_doc IMPLEMENTATION.
ENDMETHOD.


METHOD pattern.
DATA(act_schema) = test_generator->generate_type( VALUE zcl_aff_test_types=>string_pattern( ) ).
METHOD pattern_simple.
DATA(act_schema) = test_generator->generate_type( VALUE zcl_aff_test_types=>string_pattern_simple( ) ).
DATA(exp_schema) = VALUE string_table(
( ` { ` )
( | "$comment": "This file is autogenerated, do not edit manually, see { zcl_aff_writer_json_schema=>c_link_to_repository } for more information.", | )
( | "$schema": "{ zcl_aff_writer_json_schema=>c_schema_specification }",| )
( | "$id": "{ schema_id }",| )
( ` "title": "Structure With Pattern Annotation", ` )
( ` "description": "Structure with pattern annotation", ` )
( ` "type": "object", ` )
( ` "properties": { ` )
( ` "stringPattern": { ` )
( ` "title": "String with pattern",` )
( ` "description": "description",` )
( ` "type": "string", ` )
( ` "pattern": "[a-Z]*" ` )
( ` } ` )
( ` }, ` )
( ` "additionalProperties": false ` )
( ` } ` )
( ) ).
zcl_aff_tools_unit_test_helper=>assert_equals_ignore_spaces( act_data = act_schema exp_data = exp_schema ).
log = cut->zif_aff_writer~get_log( ).
zcl_aff_tools_unit_test_helper=>assert_log_has_no_message( log = log message_severity_threshold = zif_aff_log=>c_message_type-info ).
ENDMETHOD.

METHOD pattern_complex.

Check failure on line 2820 in src/zcl_aff_writer_json_schema.clas.testclasses.abap

View check run for this annotation

abaplint / abaplint

Indentation problem, expected 2 spaces

https://rules.abaplint.org/indentation
DATA(act_schema) = test_generator->generate_type( VALUE zcl_aff_test_types=>string_pattern_complex( ) ).
DATA(exp_schema) = VALUE string_table(
( ` { ` )
( | "$comment": "This file is autogenerated, do not edit manually, see { zcl_aff_writer_json_schema=>c_link_to_repository } for more information.", | )
Expand Down

0 comments on commit 86d74f4

Please sign in to comment.