Harness: runner, generator, tasks T01 T13 T14 T15, CLAUDE.md
This commit is contained in:
64
tasks/T15/hidden/t15_hidden.clas.abap
Normal file
64
tasks/T15/hidden/t15_hidden.clas.abap
Normal file
@@ -0,0 +1,64 @@
|
||||
CLASS {{p}}t15_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
CLASS-DATA go_env TYPE REF TO if_cds_test_environment.
|
||||
CLASS-METHODS class_setup.
|
||||
CLASS-METHODS class_teardown.
|
||||
METHODS setup.
|
||||
METHODS totals FOR TESTING.
|
||||
METHODS item_counts FOR TESTING.
|
||||
METHODS order_without_items FOR TESTING.
|
||||
METHODS customer_shown FOR TESTING.
|
||||
METHODS decimals FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t15_hidden IMPLEMENTATION.
|
||||
METHOD class_setup.
|
||||
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_ORDER_TOTAL' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD class_teardown.
|
||||
go_env->destroy( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD setup.
|
||||
DATA lt_ord TYPE STANDARD TABLE OF {{p}}ord WITH EMPTY KEY.
|
||||
DATA lt_itm TYPE STANDARD TABLE OF {{p}}itm WITH EMPTY KEY.
|
||||
go_env->clear_doubles( ).
|
||||
lt_ord = VALUE #( ( order_id = 'O1' customer = 'ALPHA' )
|
||||
( order_id = 'O2' customer = 'BETA' )
|
||||
( order_id = 'O3' customer = 'GAMMA' ) ).
|
||||
lt_itm = VALUE #( ( order_id = 'O1' item_no = 1 quantity = 3 price = '10.00' )
|
||||
( order_id = 'O1' item_no = 2 quantity = 1 price = '2.50' )
|
||||
( order_id = 'O1' item_no = 3 quantity = 4 price = '0.25' )
|
||||
( order_id = 'O2' item_no = 1 quantity = 10 price = '1.99' ) ).
|
||||
go_env->insert_test_data( lt_ord ).
|
||||
go_env->insert_test_data( lt_itm ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD totals.
|
||||
SELECT SINGLE total_amount FROM {{p}}i_order_total WHERE order_id = 'O1' INTO @DATA(lv_total).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '33.50' ) act = CONV decfloat34( lv_total ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD item_counts.
|
||||
SELECT SINGLE item_count FROM {{p}}i_order_total WHERE order_id = 'O1' INTO @DATA(lv_count).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_count ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD order_without_items.
|
||||
SELECT COUNT(*) FROM {{p}}i_order_total INTO @DATA(lv_rows).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_rows ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD customer_shown.
|
||||
SELECT SINGLE customer FROM {{p}}i_order_total WHERE order_id = 'O2' INTO @DATA(lv_customer).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 'BETA' act = lv_customer ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD decimals.
|
||||
SELECT SINGLE total_amount FROM {{p}}i_order_total WHERE order_id = 'O2' INTO @DATA(lv_total).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '19.90' ) act = CONV decfloat34( lv_total ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
14
tasks/T15/reference/i_order_total.ddls.asddls
Normal file
14
tasks/T15/reference/i_order_total.ddls.asddls
Normal file
@@ -0,0 +1,14 @@
|
||||
@AccessControl.authorizationCheck: #NOT_REQUIRED
|
||||
@EndUserText.label: 'Order totals'
|
||||
define view entity {{P}}I_ORDER_TOTAL
|
||||
as select from {{p}}ord as head
|
||||
inner join {{p}}itm as item on item.order_id = head.order_id
|
||||
{
|
||||
key head.order_id as order_id,
|
||||
head.customer as customer,
|
||||
count( * ) as item_count,
|
||||
sum( cast( item.quantity as abap.dec( 10, 0 ) ) * item.price ) as total_amount
|
||||
}
|
||||
group by
|
||||
head.order_id,
|
||||
head.customer
|
||||
38
tasks/T15/reference/t15_test.clas.abap
Normal file
38
tasks/T15/reference/t15_test.clas.abap
Normal file
@@ -0,0 +1,38 @@
|
||||
CLASS {{p}}t15_test DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
CLASS-DATA go_env TYPE REF TO if_cds_test_environment.
|
||||
CLASS-METHODS class_setup.
|
||||
CLASS-METHODS class_teardown.
|
||||
METHODS setup.
|
||||
METHODS total_of_one_order FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t15_test IMPLEMENTATION.
|
||||
METHOD class_setup.
|
||||
go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_ORDER_TOTAL' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD class_teardown.
|
||||
go_env->destroy( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD setup.
|
||||
go_env->clear_doubles( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD total_of_one_order.
|
||||
DATA lt_ord TYPE STANDARD TABLE OF {{p}}ord WITH EMPTY KEY.
|
||||
DATA lt_itm TYPE STANDARD TABLE OF {{p}}itm WITH EMPTY KEY.
|
||||
lt_ord = VALUE #( ( order_id = 'A' customer = 'C1' ) ).
|
||||
lt_itm = VALUE #( ( order_id = 'A' item_no = 1 quantity = 2 price = '1.50' )
|
||||
( order_id = 'A' item_no = 2 quantity = 1 price = '4.00' ) ).
|
||||
go_env->insert_test_data( lt_ord ).
|
||||
go_env->insert_test_data( lt_itm ).
|
||||
SELECT SINGLE item_count, total_amount FROM {{p}}i_order_total WHERE order_id = 'A'
|
||||
INTO @DATA(ls_total).
|
||||
cl_abap_unit_assert=>assert_equals( exp = 2 act = ls_total-item_count ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 7 ) act = CONV decfloat34( ls_total-total_amount ) ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
13
tasks/T15/seed/itm.tabl.asabap
Normal file
13
tasks/T15/seed/itm.tabl.asabap
Normal file
@@ -0,0 +1,13 @@
|
||||
@EndUserText.label : 'Order item'
|
||||
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
|
||||
@AbapCatalog.tableCategory : #TRANSPARENT
|
||||
@AbapCatalog.deliveryClass : #A
|
||||
@AbapCatalog.dataMaintenance : #RESTRICTED
|
||||
define table {{p}}itm {
|
||||
key client : abap.clnt not null;
|
||||
key order_id : abap.char(10) not null;
|
||||
key item_no : abap.int4 not null;
|
||||
product : abap.char(10);
|
||||
quantity : abap.int4;
|
||||
price : abap.dec(15,2);
|
||||
}
|
||||
11
tasks/T15/seed/ord.tabl.asabap
Normal file
11
tasks/T15/seed/ord.tabl.asabap
Normal file
@@ -0,0 +1,11 @@
|
||||
@EndUserText.label : 'Order header'
|
||||
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
|
||||
@AbapCatalog.tableCategory : #TRANSPARENT
|
||||
@AbapCatalog.deliveryClass : #A
|
||||
@AbapCatalog.dataMaintenance : #RESTRICTED
|
||||
define table {{p}}ord {
|
||||
key client : abap.clnt not null;
|
||||
key order_id : abap.char(10) not null;
|
||||
customer : abap.char(10);
|
||||
order_date : abap.dats;
|
||||
}
|
||||
33
tasks/T15/spec.md
Normal file
33
tasks/T15/spec.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# 1. Goal
|
||||
Give the total value of each order. A report and an OData service will read the
|
||||
totals, so the calculation must be in the database, in a CDS view.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- Table {{P}}ORD (order header), package $TMP. Key: ORDER_ID (CHAR 10).
|
||||
Fields: CUSTOMER (CHAR 10), ORDER_DATE (DATS).
|
||||
- Table {{P}}ITM (order item), package $TMP. Key: ORDER_ID (CHAR 10), ITEM_NO (INT4).
|
||||
Fields: PRODUCT (CHAR 10), QUANTITY (INT4), PRICE (DEC 15,2, price for one unit).
|
||||
|
||||
# 4. Contract
|
||||
- Create the CDS view entity {{P}}I_ORDER_TOTAL in package $TMP.
|
||||
- Elements, with these names: ORDER_ID (key), CUSTOMER, ITEM_COUNT, TOTAL_AMOUNT.
|
||||
- No authorization check (#NOT_REQUIRED).
|
||||
|
||||
# 5. Business rules
|
||||
1. Show one row for each order that has at least one item. Do not show an order
|
||||
without items.
|
||||
2. ITEM_COUNT is the number of items of the order.
|
||||
3. TOTAL_AMOUNT is the sum of QUANTITY multiplied by PRICE for all items of the
|
||||
order, with 2 decimals.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: 7.58.
|
||||
- Out of scope: do not change {{P}}ORD and {{P}}ITM.
|
||||
|
||||
# 7. Acceptance
|
||||
- The view is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write ABAP Unit tests with CL_CDS_TEST_ENVIRONMENT in a global test class.
|
||||
22
tasks/T15/task.json
Normal file
22
tasks/T15/task.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"id": "T15", "category": "B", "object_type": "DDLS", "difficulty": 2,
|
||||
"release_target": "v758", "expected_outcome": "implement",
|
||||
"budget": {"max_tool_calls": 40, "max_activations": 10},
|
||||
"seed": [
|
||||
{"type": "TABL", "name": "{{P}}ORD", "file": "seed/ord.tabl.asabap", "description": "Order header"},
|
||||
{"type": "TABL", "name": "{{P}}ITM", "file": "seed/itm.tabl.asabap", "description": "Order item"}
|
||||
],
|
||||
"contract": [
|
||||
{"type": "DDLS", "name": "{{P}}I_ORDER_TOTAL",
|
||||
"fields": ["ORDER_ID", "CUSTOMER", "ITEM_COUNT", "TOTAL_AMOUNT"]}
|
||||
],
|
||||
"out_of_scope": ["{{P}}ORD", "{{P}}ITM"],
|
||||
"hidden_tests": [{"type": "CLAS", "name": "{{P}}T15_HIDDEN", "file": "hidden/t15_hidden.clas.abap",
|
||||
"description": "T15 hidden tests"}],
|
||||
"reference": [
|
||||
{"type": "DDLS", "name": "{{P}}I_ORDER_TOTAL", "file": "reference/i_order_total.ddls.asddls",
|
||||
"description": "Order totals"},
|
||||
{"type": "CLAS", "name": "{{P}}T15_TEST", "file": "reference/t15_test.clas.abap", "description": "T15 own tests"}
|
||||
],
|
||||
"craft_checks": []
|
||||
}
|
||||
Reference in New Issue
Block a user