Fix coverage with several contract classes; table annotation and file path checks; clean task dir on write
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
33
tasks_gen/eval/G0130/generation.json
Normal file
33
tasks_gen/eval/G0130/generation.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"id": "G0130",
|
||||
"pool": "eval",
|
||||
"object_type": "CLAS",
|
||||
"category": "D",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"seed/drug_master.clas.abap line 15: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"METHODS\""
|
||||
],
|
||||
"by_check": {
|
||||
"abaplint": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
}
|
||||
],
|
||||
"accepted": false
|
||||
}
|
||||
156
tasks_gen/eval/G0130/hidden/t02_hidden.clas.abap
Normal file
156
tasks_gen/eval/G0130/hidden/t02_hidden.clas.abap
Normal file
@@ -0,0 +1,156 @@
|
||||
CLASS {{p}}t02_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}prescription_check.
|
||||
|
||||
METHODS setup.
|
||||
METHODS empty_prescription FOR TESTING.
|
||||
METHODS expired_prescription FOR TESTING.
|
||||
METHODS valid_on_last_day FOR TESTING.
|
||||
METHODS unknown_drug FOR TESTING.
|
||||
METHODS zero_quantity FOR TESTING.
|
||||
METHODS zero_daily_dose FOR TESTING.
|
||||
METHODS dose_above_max FOR TESTING.
|
||||
METHODS duplicate_drug FOR TESTING.
|
||||
METHODS expired_before_quantity FOR TESTING.
|
||||
METHODS dose_before_duplicate FOR TESTING.
|
||||
METHODS valid_prescription FOR TESTING.
|
||||
METHODS message_texts FOR TESTING.
|
||||
|
||||
METHODS valid_item
|
||||
RETURNING VALUE(rt_item) TYPE {{p}}prescription_check=>tt_item.
|
||||
METHODS expect_reason
|
||||
IMPORTING iv_reason TYPE {{p}}cx_presc_error=>ty_reason
|
||||
it_item TYPE {{p}}prescription_check=>tt_item
|
||||
iv_as_of TYPE d DEFAULT '20240110'.
|
||||
METHODS expect_no_error
|
||||
IMPORTING it_item TYPE {{p}}prescription_check=>tt_item
|
||||
iv_as_of TYPE d DEFAULT '20240110'.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t02_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}prescription_check( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_item.
|
||||
rt_item = VALUE #( ( drug_id = 'PARA500' quantity = 20 daily_dose = 1000 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD expect_reason.
|
||||
DATA lv_raised TYPE abap_bool.
|
||||
TRY.
|
||||
mo_cut->validate( iv_issue_date = '20240101'
|
||||
iv_valid_days = 30
|
||||
iv_as_of_date = iv_as_of
|
||||
it_item = it_item ).
|
||||
CATCH {{p}}cx_presc_error INTO DATA(lx_error).
|
||||
lv_raised = abap_true.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_reason
|
||||
act = lx_error->get_reason( ) ).
|
||||
ENDTRY.
|
||||
cl_abap_unit_assert=>assert_true( act = lv_raised
|
||||
msg = |No exception with reason { iv_reason }| ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD expect_no_error.
|
||||
DATA lv_raised TYPE abap_bool.
|
||||
TRY.
|
||||
mo_cut->validate( iv_issue_date = '20240101'
|
||||
iv_valid_days = 30
|
||||
iv_as_of_date = iv_as_of
|
||||
it_item = it_item ).
|
||||
CATCH {{p}}cx_presc_error.
|
||||
lv_raised = abap_true.
|
||||
ENDTRY.
|
||||
cl_abap_unit_assert=>assert_false( act = lv_raised ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_prescription.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-empty
|
||||
it_item = VALUE {{p}}prescription_check=>tt_item( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD expired_prescription.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-expired
|
||||
it_item = valid_item( )
|
||||
iv_as_of = '20240201' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_on_last_day.
|
||||
expect_no_error( it_item = valid_item( )
|
||||
iv_as_of = '20240131' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_drug.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-unknown
|
||||
it_item = VALUE #( ( drug_id = 'XXXXXX' quantity = 5 daily_dose = 10 ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_quantity.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-quantity
|
||||
it_item = VALUE #( ( drug_id = 'PARA500' quantity = 0 daily_dose = 1000 ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_daily_dose.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-dose
|
||||
it_item = VALUE #( ( drug_id = 'PARA500' quantity = 5 daily_dose = 0 ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dose_above_max.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-dose
|
||||
it_item = VALUE #( ( drug_id = 'META50' quantity = 5 daily_dose = 250 ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD duplicate_drug.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-duplicate
|
||||
it_item = VALUE #( ( drug_id = 'PARA500' quantity = 5 daily_dose = 1000 )
|
||||
( drug_id = 'PARA500' quantity = 5 daily_dose = 1000 ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD expired_before_quantity.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-expired
|
||||
it_item = VALUE #( ( drug_id = 'PARA500' quantity = 0 daily_dose = 1000 ) )
|
||||
iv_as_of = '20240201' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dose_before_duplicate.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-dose
|
||||
it_item = VALUE #( ( drug_id = 'META50' quantity = 5 daily_dose = 250 )
|
||||
( drug_id = 'META50' quantity = 5 daily_dose = 100 ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_prescription.
|
||||
expect_no_error( it_item = VALUE #( ( drug_id = 'PARA500' quantity = 20 daily_dose = 4000 )
|
||||
( drug_id = 'IBU400' quantity = 10 daily_dose = 1200 ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD message_texts.
|
||||
DATA lo_error TYPE REF TO {{p}}cx_presc_error.
|
||||
|
||||
lo_error = NEW #( iv_reason = {{p}}cx_presc_error=>c_reason-empty ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'The prescription has no items'
|
||||
act = lo_error->get_message_text( ) ).
|
||||
|
||||
lo_error = NEW #( iv_reason = {{p}}cx_presc_error=>c_reason-expired ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'The prescription is expired'
|
||||
act = lo_error->get_message_text( ) ).
|
||||
|
||||
lo_error = NEW #( iv_reason = {{p}}cx_presc_error=>c_reason-quantity ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'The quantity is not positive'
|
||||
act = lo_error->get_message_text( ) ).
|
||||
|
||||
lo_error = NEW #( iv_reason = {{p}}cx_presc_error=>c_reason-unknown ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'The drug is not in the drug master'
|
||||
act = lo_error->get_message_text( ) ).
|
||||
|
||||
lo_error = NEW #( iv_reason = {{p}}cx_presc_error=>c_reason-dose ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'The daily dose is not allowed'
|
||||
act = lo_error->get_message_text( ) ).
|
||||
|
||||
lo_error = NEW #( iv_reason = {{p}}cx_presc_error=>c_reason-duplicate ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'The drug appears more than once'
|
||||
act = lo_error->get_message_text( ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
60
tasks_gen/eval/G0130/reference/cx_presc_error.clas.abap
Normal file
60
tasks_gen/eval/G0130/reference/cx_presc_error.clas.abap
Normal file
@@ -0,0 +1,60 @@
|
||||
CLASS {{p}}cx_presc_error DEFINITION
|
||||
PUBLIC
|
||||
INHERITING FROM cx_root
|
||||
FINAL
|
||||
CREATE PUBLIC.
|
||||
|
||||
PUBLIC SECTION.
|
||||
TYPES ty_reason TYPE c LENGTH 12.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
empty TYPE ty_reason VALUE 'EMPTY',
|
||||
expired TYPE ty_reason VALUE 'EXPIRED',
|
||||
quantity TYPE ty_reason VALUE 'QUANTITY',
|
||||
unknown TYPE ty_reason VALUE 'UNKNOWN',
|
||||
dose TYPE ty_reason VALUE 'DOSE',
|
||||
duplicate TYPE ty_reason VALUE 'DUPLICATE',
|
||||
END OF c_reason.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING iv_reason TYPE ty_reason.
|
||||
|
||||
METHODS get_reason
|
||||
RETURNING VALUE(rv_reason) TYPE ty_reason.
|
||||
|
||||
METHODS get_message_text
|
||||
RETURNING VALUE(rv_text) TYPE string.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA mv_reason TYPE ty_reason.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}cx_presc_error IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
super->constructor( ).
|
||||
mv_reason = iv_reason.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_reason.
|
||||
rv_reason = mv_reason.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_message_text.
|
||||
CASE mv_reason.
|
||||
WHEN c_reason-empty.
|
||||
rv_text = 'The prescription has no items'.
|
||||
WHEN c_reason-expired.
|
||||
rv_text = 'The prescription is expired'.
|
||||
WHEN c_reason-quantity.
|
||||
rv_text = 'The quantity is not positive'.
|
||||
WHEN c_reason-unknown.
|
||||
rv_text = 'The drug is not in the drug master'.
|
||||
WHEN c_reason-dose.
|
||||
rv_text = 'The daily dose is not allowed'.
|
||||
WHEN c_reason-duplicate.
|
||||
rv_text = 'The drug appears more than once'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
103
tasks_gen/eval/G0130/reference/prescription_check.clas.abap
Normal file
103
tasks_gen/eval/G0130/reference/prescription_check.clas.abap
Normal file
@@ -0,0 +1,103 @@
|
||||
CLASS {{p}}prescription_check DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES ty_drug_id TYPE c LENGTH 10.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_item,
|
||||
drug_id TYPE ty_drug_id,
|
||||
quantity TYPE i,
|
||||
daily_dose TYPE i,
|
||||
END OF ty_item,
|
||||
tt_item TYPE STANDARD TABLE OF ty_item WITH EMPTY KEY.
|
||||
|
||||
METHODS constructor.
|
||||
|
||||
METHODS validate
|
||||
IMPORTING iv_issue_date TYPE d
|
||||
iv_valid_days TYPE i
|
||||
iv_as_of_date TYPE d
|
||||
it_item TYPE tt_item
|
||||
RAISING {{p}}cx_presc_error.
|
||||
|
||||
PRIVATE SECTION.
|
||||
DATA mo_drug_master TYPE REF TO {{p}}drug_master.
|
||||
|
||||
METHODS expiry_date
|
||||
IMPORTING iv_issue_date TYPE d
|
||||
iv_valid_days TYPE i
|
||||
RETURNING VALUE(rv_expiry) TYPE d.
|
||||
|
||||
METHODS check_items
|
||||
IMPORTING it_item TYPE tt_item
|
||||
RAISING {{p}}cx_presc_error.
|
||||
|
||||
METHODS check_item
|
||||
IMPORTING is_item TYPE ty_item
|
||||
RAISING {{p}}cx_presc_error.
|
||||
|
||||
METHODS check_duplicates
|
||||
IMPORTING it_item TYPE tt_item
|
||||
RAISING {{p}}cx_presc_error.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}prescription_check IMPLEMENTATION.
|
||||
METHOD constructor.
|
||||
mo_drug_master = NEW {{p}}drug_master( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD validate.
|
||||
IF it_item IS INITIAL.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_presc_error
|
||||
EXPORTING iv_reason = {{p}}cx_presc_error=>c_reason-empty.
|
||||
ENDIF.
|
||||
|
||||
IF iv_as_of_date > expiry_date( iv_issue_date = iv_issue_date
|
||||
iv_valid_days = iv_valid_days ).
|
||||
RAISE EXCEPTION TYPE {{p}}cx_presc_error
|
||||
EXPORTING iv_reason = {{p}}cx_presc_error=>c_reason-expired.
|
||||
ENDIF.
|
||||
|
||||
check_items( it_item ).
|
||||
check_duplicates( it_item ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD expiry_date.
|
||||
rv_expiry = iv_issue_date + iv_valid_days.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_items.
|
||||
LOOP AT it_item INTO DATA(ls_item).
|
||||
check_item( ls_item ).
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_item.
|
||||
IF is_item-quantity < 1.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_presc_error
|
||||
EXPORTING iv_reason = {{p}}cx_presc_error=>c_reason-quantity.
|
||||
ENDIF.
|
||||
|
||||
DATA(ls_drug) = mo_drug_master->get_drug( is_item-drug_id ).
|
||||
IF ls_drug IS INITIAL.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_presc_error
|
||||
EXPORTING iv_reason = {{p}}cx_presc_error=>c_reason-unknown.
|
||||
ENDIF.
|
||||
|
||||
IF is_item-daily_dose < 1 OR is_item-daily_dose > ls_drug-max_daily_dose.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_presc_error
|
||||
EXPORTING iv_reason = {{p}}cx_presc_error=>c_reason-dose.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_duplicates.
|
||||
DATA lt_seen TYPE HASHED TABLE OF ty_item WITH UNIQUE KEY drug_id.
|
||||
LOOP AT it_item INTO DATA(ls_item).
|
||||
INSERT ls_item INTO TABLE lt_seen.
|
||||
IF sy-subrc <> 0.
|
||||
RAISE EXCEPTION TYPE {{p}}cx_presc_error
|
||||
EXPORTING iv_reason = {{p}}cx_presc_error=>c_reason-duplicate.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,104 @@
|
||||
CLASS ltc_presc_check DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}prescription_check.
|
||||
|
||||
METHODS setup.
|
||||
METHODS valid_prescription FOR TESTING.
|
||||
METHODS empty_prescription FOR TESTING.
|
||||
METHODS expired_prescription FOR TESTING.
|
||||
METHODS unknown_drug FOR TESTING.
|
||||
METHODS bad_quantity FOR TESTING.
|
||||
METHODS bad_dose FOR TESTING.
|
||||
METHODS duplicate_drug FOR TESTING.
|
||||
METHODS message_of_empty FOR TESTING.
|
||||
|
||||
METHODS valid_item
|
||||
RETURNING VALUE(rt_item) TYPE {{p}}prescription_check=>tt_item.
|
||||
METHODS expect_reason
|
||||
IMPORTING iv_reason TYPE {{p}}cx_presc_error=>ty_reason
|
||||
it_item TYPE {{p}}prescription_check=>tt_item.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_presc_check IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}prescription_check( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_item.
|
||||
rt_item = VALUE #( ( drug_id = 'IBU400' quantity = 10 daily_dose = 1200 ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD expect_reason.
|
||||
DATA lv_raised TYPE abap_bool.
|
||||
TRY.
|
||||
mo_cut->validate( iv_issue_date = '20240101'
|
||||
iv_valid_days = 30
|
||||
iv_as_of_date = '20240110'
|
||||
it_item = it_item ).
|
||||
CATCH {{p}}cx_presc_error INTO DATA(lx_error).
|
||||
lv_raised = abap_true.
|
||||
cl_abap_unit_assert=>assert_equals( exp = iv_reason
|
||||
act = lx_error->get_reason( ) ).
|
||||
ENDTRY.
|
||||
cl_abap_unit_assert=>assert_true( act = lv_raised ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valid_prescription.
|
||||
TRY.
|
||||
mo_cut->validate( iv_issue_date = '20240101'
|
||||
iv_valid_days = 30
|
||||
iv_as_of_date = '20240110'
|
||||
it_item = valid_item( ) ).
|
||||
CATCH {{p}}cx_presc_error.
|
||||
cl_abap_unit_assert=>fail( msg = 'Unexpected exception' ).
|
||||
ENDTRY.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_prescription.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-empty
|
||||
it_item = VALUE {{p}}prescription_check=>tt_item( ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD expired_prescription.
|
||||
DATA lv_raised TYPE abap_bool.
|
||||
TRY.
|
||||
mo_cut->validate( iv_issue_date = '20240101'
|
||||
iv_valid_days = 30
|
||||
iv_as_of_date = '20240201'
|
||||
it_item = valid_item( ) ).
|
||||
CATCH {{p}}cx_presc_error INTO DATA(lx_error).
|
||||
lv_raised = abap_true.
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}cx_presc_error=>c_reason-expired
|
||||
act = lx_error->get_reason( ) ).
|
||||
ENDTRY.
|
||||
cl_abap_unit_assert=>assert_true( act = lv_raised ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD unknown_drug.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-unknown
|
||||
it_item = VALUE #( ( drug_id = 'NODRUG' quantity = 5 daily_dose = 10 ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD bad_quantity.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-quantity
|
||||
it_item = VALUE #( ( drug_id = 'IBU400' quantity = 0 daily_dose = 1200 ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD bad_dose.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-dose
|
||||
it_item = VALUE #( ( drug_id = 'META50' quantity = 5 daily_dose = 500 ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD duplicate_drug.
|
||||
expect_reason( iv_reason = {{p}}cx_presc_error=>c_reason-duplicate
|
||||
it_item = VALUE #( ( drug_id = 'IBU400' quantity = 10 daily_dose = 1200 )
|
||||
( drug_id = 'IBU400' quantity = 10 daily_dose = 1200 ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD message_of_empty.
|
||||
DATA(lo_error) = NEW {{p}}cx_presc_error( iv_reason = {{p}}cx_presc_error=>c_reason-empty ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'The prescription has no items'
|
||||
act = lo_error->get_message_text( ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
38
tasks_gen/eval/G0130/seed/drug_master.clas.abap
Normal file
38
tasks_gen/eval/G0130/seed/drug_master.clas.abap
Normal file
@@ -0,0 +1,38 @@
|
||||
CLASS {{p}}drug_master DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES ty_drug_id TYPE c LENGTH 10.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_drug,
|
||||
drug_id TYPE ty_drug_id,
|
||||
max_daily_dose TYPE i,
|
||||
END OF ty_drug,
|
||||
tt_drug TYPE STANDARD TABLE OF ty_drug WITH EMPTY KEY.
|
||||
|
||||
METHODS get_drug
|
||||
IMPORTING iv_drug_id TYPE ty_drug_id
|
||||
RETURNING VALUE(rs_drug) TYPE ty_drug.
|
||||
|
||||
PRIVATE SECTION.
|
||||
METHODS get_all_drugs
|
||||
RETURNING VALUE(rt_drug) TYPE tt_drug.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}drug_master IMPLEMENTATION.
|
||||
METHOD get_drug.
|
||||
DATA(lt_drug) = get_all_drugs( ).
|
||||
READ TABLE lt_drug INTO rs_drug WITH KEY drug_id = iv_drug_id.
|
||||
IF sy-subrc <> 0.
|
||||
CLEAR rs_drug.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_all_drugs.
|
||||
rt_drug = VALUE #( ( drug_id = 'PARA500' max_daily_dose = 4000 )
|
||||
( drug_id = 'IBU400' max_daily_dose = 1200 )
|
||||
( drug_id = 'AMOX500' max_daily_dose = 1500 )
|
||||
( drug_id = 'META50' max_daily_dose = 200 )
|
||||
( drug_id = 'SALB100' max_daily_dose = 800 ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
84
tasks_gen/eval/G0130/spec.md
Normal file
84
tasks_gen/eval/G0130/spec.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# 1. Goal
|
||||
A pharmacy dispenses prescription items. Before the pharmacy dispenses a
|
||||
prescription, it validates the prescription. The validation raises a class-based
|
||||
exception with one reason and one message for each problem. The pharmacy program
|
||||
needs the validation class and the exception class.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The class {{P}}DRUG_MASTER is in package $TMP. It is active. It is the drug
|
||||
master data of the pharmacy. Do not change it.
|
||||
- Public type TY_DRUG_ID: character, length 10.
|
||||
- Public structure TY_DRUG with the components DRUG_ID (TY_DRUG_ID) and
|
||||
MAX_DAILY_DOSE (integer, milligram).
|
||||
- Public method GET_DRUG with the importing parameter IV_DRUG_ID (TY_DRUG_ID)
|
||||
and the returning parameter RS_DRUG (TY_DRUG). If the drug is not in the
|
||||
master data, RS_DRUG is initial.
|
||||
- The drug master data contains these drugs and maximum daily doses:
|
||||
PARA500 4000, IBU400 1200, AMOX500 1500, META50 200, SALB100 800.
|
||||
- A prescription has an issue date, a number of valid days and items. Each item
|
||||
has a drug, a quantity and a daily dose.
|
||||
|
||||
# 4. Contract
|
||||
## 4.1 Exception class {{P}}CX_PRESC_ERROR
|
||||
- Create the class in package $TMP.
|
||||
- The class inherits from CX_ROOT.
|
||||
- Public type TY_REASON: character, length 12.
|
||||
- Public constant structure C_REASON with the components EMPTY, EXPIRED,
|
||||
QUANTITY, UNKNOWN, DOSE and DUPLICATE. Each component has the type TY_REASON
|
||||
and the value of its own name.
|
||||
- Public constructor with the importing parameter IV_REASON (TY_REASON).
|
||||
- Public method GET_REASON with the returning parameter RV_REASON (TY_REASON).
|
||||
- Public method GET_MESSAGE_TEXT with the returning parameter RV_TEXT (string).
|
||||
GET_MESSAGE_TEXT returns the message of the reason:
|
||||
- EMPTY: The prescription has no items
|
||||
- EXPIRED: The prescription is expired
|
||||
- QUANTITY: The quantity is not positive
|
||||
- UNKNOWN: The drug is not in the drug master
|
||||
- DOSE: The daily dose is not allowed
|
||||
- DUPLICATE: The drug appears more than once
|
||||
|
||||
## 4.2 Check class {{P}}PRESCRIPTION_CHECK
|
||||
- Create the class in package $TMP.
|
||||
- The class is public and final. It has a public constructor without parameters.
|
||||
- Public type TY_DRUG_ID: character, length 10.
|
||||
- Public structure TY_ITEM with the components DRUG_ID (TY_DRUG_ID), QUANTITY
|
||||
(integer) and DAILY_DOSE (integer).
|
||||
- Public table type TT_ITEM: standard table of TY_ITEM with empty key.
|
||||
- Public method VALIDATE with these importing parameters:
|
||||
- IV_ISSUE_DATE (type d)
|
||||
- IV_VALID_DAYS (integer)
|
||||
- IV_AS_OF_DATE (type d)
|
||||
- IT_ITEM (TT_ITEM)
|
||||
and the addition RAISING {{P}}CX_PRESC_ERROR.
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
VALIDATE applies the rules in this sequence. It raises {{P}}CX_PRESC_ERROR with
|
||||
the reason of the first rule that fails.
|
||||
1. If IT_ITEM is empty, the reason is EMPTY.
|
||||
2. If IV_AS_OF_DATE is later than IV_ISSUE_DATE plus IV_VALID_DAYS days, the
|
||||
reason is EXPIRED.
|
||||
3. Process the items in the sequence of the table. For each item:
|
||||
3.1 If QUANTITY is less than 1, the reason is QUANTITY.
|
||||
3.2 If DRUG_ID is not in the drug master data, the reason is UNKNOWN.
|
||||
3.3 If DAILY_DOSE is less than 1, or if DAILY_DOSE is greater than the
|
||||
maximum daily dose of the drug, the reason is DOSE.
|
||||
4. If one DRUG_ID occurs in more than one item, the reason is DUPLICATE.
|
||||
5. Else VALIDATE returns without an exception.
|
||||
The dates are always valid dates.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
||||
- Package: $TMP. Do not use a transport request.
|
||||
- Coding standards: Clean ABAP. Methods below 40 statements. No global
|
||||
variables. Pass large parameters by reference. No comment that restates the
|
||||
code.
|
||||
- Out of scope: do not change {{P}}DRUG_MASTER.
|
||||
|
||||
# 7. Acceptance
|
||||
- Both classes are active and have no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for {{P}}PRESCRIPTION_CHECK.
|
||||
60
tasks_gen/eval/G0130/task.json
Normal file
60
tasks_gen/eval/G0130/task.json
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"id": "G0130",
|
||||
"category": "D",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}DRUG_MASTER",
|
||||
"file": "seed/drug_master.clas.abap",
|
||||
"description": "Drug master data of the pharmacy"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_PRESC_ERROR"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}PRESCRIPTION_CHECK"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}DRUG_MASTER"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T02_HIDDEN",
|
||||
"file": "hidden/t02_hidden.clas.abap",
|
||||
"description": "T02 hidden tests"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}CX_PRESC_ERROR",
|
||||
"file": "reference/cx_presc_error.clas.abap",
|
||||
"description": "Prescription exception with reason and message"
|
||||
},
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}PRESCRIPTION_CHECK",
|
||||
"file": "reference/prescription_check.clas.abap",
|
||||
"description": "Prescription check",
|
||||
"testclasses_file": "reference/prescription_check.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"db_operation_in_loop"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user