Pipeline controller: plan 2 (hard +, error +50 %), backlog throttle, 2 trajectory workers, stop rules, summaries every 50; budget reserve

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 13:35:54 +02:00
parent 1c4667a0fc
commit 13360292dd
781 changed files with 50211 additions and 22 deletions

View File

@@ -0,0 +1,94 @@
CLASS {{p}}garden_rent DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_plot_type TYPE c LENGTH 4.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
TYPES:
BEGIN OF ty_result,
reason TYPE ty_reason,
rent TYPE ty_amount,
END OF ty_result.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
plot TYPE ty_reason VALUE 'PLOT',
area TYPE ty_reason VALUE 'AREA',
END OF c_reason.
METHODS calculate
IMPORTING iv_plot_type TYPE ty_plot_type
iv_area TYPE i
iv_water TYPE abap_bool
iv_member TYPE abap_bool
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_min_area TYPE i VALUE 10,
c_max_area TYPE i VALUE 500,
c_water_units TYPE i VALUE 120000,
c_member_percent TYPE i VALUE 85,
c_scale TYPE i VALUE 100,
c_half_cent TYPE i VALUE 50,
c_min_rent_cents TYPE i VALUE 1000,
c_cent_factor TYPE ty_amount VALUE '0.01'.
METHODS is_valid_plot_type
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS rate_units
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_units) TYPE i.
METHODS to_amount
IMPORTING iv_cents TYPE i
RETURNING VALUE(rv_rent) TYPE ty_amount.
ENDCLASS.
CLASS {{p}}garden_rent IMPLEMENTATION.
METHOD calculate.
IF is_valid_plot_type( iv_plot_type ) = abap_false.
rs_result-reason = c_reason-plot.
RETURN.
ENDIF.
IF iv_area < c_min_area OR iv_area <= c_max_area.
rs_result-reason = c_reason-area.
RETURN.
ENDIF.
DATA(lv_units) = iv_area * rate_units( iv_plot_type ).
IF iv_water = abap_true.
lv_units = lv_units + c_water_units.
ENDIF.
IF iv_member = abap_true.
lv_units = ( lv_units * c_member_percent ) DIV c_scale.
ENDIF.
DATA(lv_cents) = ( lv_units + c_half_cent ) DIV c_scale.
IF lv_cents < c_min_rent_cents.
lv_cents = c_min_rent_cents.
ENDIF.
rs_result-rent = to_amount( lv_cents ).
rs_result-reason = c_reason-ok.
ENDMETHOD.
METHOD is_valid_plot_type.
CASE to_upper( iv_plot_type ).
WHEN 'STD' OR 'PREM' OR 'BED'.
rv_valid = abap_true.
ENDCASE.
ENDMETHOD.
METHOD rate_units.
CASE to_upper( iv_plot_type ).
WHEN 'STD'.
rv_units = 3500.
WHEN 'PREM'.
rv_units = 6000.
WHEN 'BED'.
rv_units = 9000.
ENDCASE.
ENDMETHOD.
METHOD to_amount.
DATA(lv_cents) = CONV ty_amount( iv_cents ).
rv_rent = lv_cents * c_cent_factor.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,94 @@
CLASS {{p}}garden_rent DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_plot_type TYPE c LENGTH 4.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
TYPES:
BEGIN OF ty_result,
reason TYPE ty_reason,
rent TYPE ty_amount,
END OF ty_result.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
plot TYPE ty_reason VALUE 'PLOT',
area TYPE ty_reason VALUE 'AREA',
END OF c_reason.
METHODS calculate
IMPORTING iv_plot_type TYPE ty_plot_type
iv_area TYPE i
iv_water TYPE abap_bool
iv_member TYPE abap_bool
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_min_area TYPE i VALUE 10,
c_max_area TYPE i VALUE 500,
c_water_units TYPE i VALUE 120000,
c_member_percent TYPE i VALUE 85,
c_scale TYPE i VALUE 100,
c_half_cent TYPE i VALUE 50,
c_min_rent_cents TYPE i VALUE 1000,
c_cent_factor TYPE ty_amount VALUE '0.01'.
METHODS is_valid_plot_type
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS rate_units
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_units) TYPE i.
METHODS to_amount
IMPORTING iv_cents TYPE i
RETURNING VALUE(rv_rent) TYPE ty_amount.
ENDCLASS.
CLASS {{p}}garden_rent IMPLEMENTATION.
METHOD calculate.
IF is_valid_plot_type( iv_plot_type ) = abap_false.
rs_result-reason = c_reason-plot.
RETURN.
ENDIF.
IF iv_area < c_min_area OR iv_area > c_max_area.
rs_result-reason = c_reason-area.
RETURN.
ENDIF.
DATA(lv_units) = iv_area * rate_units( iv_plot_type ).
IF iv_water <> abap_true.
lv_units = lv_units + c_water_units.
ENDIF.
IF iv_member = abap_true.
lv_units = ( lv_units * c_member_percent ) DIV c_scale.
ENDIF.
DATA(lv_cents) = ( lv_units + c_half_cent ) DIV c_scale.
IF lv_cents < c_min_rent_cents.
lv_cents = c_min_rent_cents.
ENDIF.
rs_result-rent = to_amount( lv_cents ).
rs_result-reason = c_reason-ok.
ENDMETHOD.
METHOD is_valid_plot_type.
CASE to_upper( iv_plot_type ).
WHEN 'STD' OR 'PREM' OR 'BED'.
rv_valid = abap_true.
ENDCASE.
ENDMETHOD.
METHOD rate_units.
CASE to_upper( iv_plot_type ).
WHEN 'STD'.
rv_units = 3500.
WHEN 'PREM'.
rv_units = 6000.
WHEN 'BED'.
rv_units = 9000.
ENDCASE.
ENDMETHOD.
METHOD to_amount.
DATA(lv_cents) = CONV ty_amount( iv_cents ).
rv_rent = lv_cents * c_cent_factor.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,94 @@
CLASS {{p}}garden_rent DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_plot_type TYPE c LENGTH 4.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
TYPES:
BEGIN OF ty_result,
reason TYPE ty_reason,
rent TYPE ty_amount,
END OF ty_result.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
plot TYPE ty_reason VALUE 'PLOT',
area TYPE ty_reason VALUE 'AREA',
END OF c_reason.
METHODS calculate
IMPORTING iv_plot_type TYPE ty_plot_type
iv_area TYPE i
iv_water TYPE abap_bool
iv_member TYPE abap_bool
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_min_area TYPE i VALUE 10,
c_max_area TYPE i VALUE 500,
c_water_units TYPE i VALUE 120000,
c_member_percent TYPE i VALUE 85,
c_scale TYPE i VALUE 100,
c_half_cent TYPE i VALUE 50,
c_min_rent_cents TYPE i VALUE 1000,
c_cent_factor TYPE ty_amount VALUE '0.01'.
METHODS is_valid_plot_type
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS rate_units
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_units) TYPE i.
METHODS to_amount
IMPORTING iv_cents TYPE i
RETURNING VALUE(rv_rent) TYPE ty_amount.
ENDCLASS.
CLASS {{p}}garden_rent IMPLEMENTATION.
METHOD calculate.
IF is_valid_plot_type( iv_plot_type ) = abap_false.
rs_result-reason = c_reason-plot.
RETURN.
ENDIF.
IF iv_area < c_min_area OR iv_area > c_max_area.
rs_result-reason = c_reason-area.
RETURN.
ENDIF.
DATA(lv_units) = iv_area * rate_units( iv_plot_type ).
IF iv_water = abap_true.
lv_units = lv_units + c_water_units.
ENDIF.
IF iv_member = abap_false.
lv_units = ( lv_units * c_member_percent ) DIV c_scale.
ENDIF.
DATA(lv_cents) = ( lv_units + c_half_cent ) DIV c_scale.
IF lv_cents < c_min_rent_cents.
lv_cents = c_min_rent_cents.
ENDIF.
rs_result-rent = to_amount( lv_cents ).
rs_result-reason = c_reason-ok.
ENDMETHOD.
METHOD is_valid_plot_type.
CASE to_upper( iv_plot_type ).
WHEN 'STD' OR 'PREM' OR 'BED'.
rv_valid = abap_true.
ENDCASE.
ENDMETHOD.
METHOD rate_units.
CASE to_upper( iv_plot_type ).
WHEN 'STD'.
rv_units = 3500.
WHEN 'PREM'.
rv_units = 6000.
WHEN 'BED'.
rv_units = 9000.
ENDCASE.
ENDMETHOD.
METHOD to_amount.
DATA(lv_cents) = CONV ty_amount( iv_cents ).
rv_rent = lv_cents * c_cent_factor.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,94 @@
CLASS {{p}}garden_rent DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_plot_type TYPE c LENGTH 4.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
TYPES:
BEGIN OF ty_result,
reason TYPE ty_reason,
rent TYPE ty_amount,
END OF ty_result.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
plot TYPE ty_reason VALUE 'PLOT',
area TYPE ty_reason VALUE 'AREA',
END OF c_reason.
METHODS calculate
IMPORTING iv_plot_type TYPE ty_plot_type
iv_area TYPE i
iv_water TYPE abap_bool
iv_member TYPE abap_bool
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_min_area TYPE i VALUE 10,
c_max_area TYPE i VALUE 500,
c_water_units TYPE i VALUE 120000,
c_member_percent TYPE i VALUE 85,
c_scale TYPE i VALUE 100,
c_half_cent TYPE i VALUE 50,
c_min_rent_cents TYPE i VALUE 1000,
c_cent_factor TYPE ty_amount VALUE '0.01'.
METHODS is_valid_plot_type
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS rate_units
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_units) TYPE i.
METHODS to_amount
IMPORTING iv_cents TYPE i
RETURNING VALUE(rv_rent) TYPE ty_amount.
ENDCLASS.
CLASS {{p}}garden_rent IMPLEMENTATION.
METHOD calculate.
IF is_valid_plot_type( iv_plot_type ) = abap_false.
rs_result-reason = c_reason-plot.
RETURN.
ENDIF.
IF iv_area < c_min_area OR iv_area > c_max_area.
rs_result-reason = c_reason-area.
RETURN.
ENDIF.
DATA(lv_units) = iv_area * rate_units( iv_plot_type ).
IF iv_water = abap_true.
lv_units = lv_units + c_water_units.
ENDIF.
IF iv_member = abap_true.
lv_units = ( lv_units / c_member_percent ) DIV c_scale.
ENDIF.
DATA(lv_cents) = ( lv_units + c_half_cent ) DIV c_scale.
IF lv_cents < c_min_rent_cents.
lv_cents = c_min_rent_cents.
ENDIF.
rs_result-rent = to_amount( lv_cents ).
rs_result-reason = c_reason-ok.
ENDMETHOD.
METHOD is_valid_plot_type.
CASE to_upper( iv_plot_type ).
WHEN 'STD' OR 'PREM' OR 'BED'.
rv_valid = abap_true.
ENDCASE.
ENDMETHOD.
METHOD rate_units.
CASE to_upper( iv_plot_type ).
WHEN 'STD'.
rv_units = 3500.
WHEN 'PREM'.
rv_units = 6000.
WHEN 'BED'.
rv_units = 9000.
ENDCASE.
ENDMETHOD.
METHOD to_amount.
DATA(lv_cents) = CONV ty_amount( iv_cents ).
rv_rent = lv_cents * c_cent_factor.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,38 @@
{
"id": "G1055",
"pool": "train",
"object_type": "CLAS",
"category": "A",
"attempts": [
{
"stage": "bundle",
"errors": [
"Too close to task G1038 (similarity spec 0.53, rules 0.66, names 0.25). Choose a different business topic and different object names."
],
"by_check": {
"extra": 1
}
},
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 88.5,
"null": 0
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 4,
"killed": 4,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,104 @@
CLASS {{p}}t02_garden_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
CONSTANTS:
c_0000 TYPE ty_amount VALUE '0.00',
c_1000 TYPE ty_amount VALUE '10.00',
c_2270 TYPE ty_amount VALUE '22.70',
c_2550 TYPE ty_amount VALUE '25.50',
c_3500 TYPE ty_amount VALUE '35.00',
c_6000 TYPE ty_amount VALUE '60.00',
c_7200 TYPE ty_amount VALUE '72.00'.
DATA mo_cut TYPE REF TO {{p}}garden_rent.
METHODS setup.
METHODS standard_plot_rent FOR TESTING.
METHODS raised_bed_member FOR TESTING.
METHODS premium_plot_water FOR TESTING.
METHODS minimum_rent_applies FOR TESTING.
METHODS rounds_half_up FOR TESTING.
METHODS lower_case_plot_type FOR TESTING.
METHODS unknown_plot_type FOR TESTING.
METHODS area_too_small FOR TESTING.
METHODS area_too_large FOR TESTING.
METHODS plot_checked_first FOR TESTING.
ENDCLASS.
CLASS {{p}}t02_garden_hidden IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}garden_rent( ).
ENDMETHOD.
METHOD standard_plot_rent.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 100
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = c_3500 act = ls_result-rent ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-ok
act = ls_result-reason ).
ENDMETHOD.
METHOD raised_bed_member.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'BED' iv_area = 20
iv_water = abap_true iv_member = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = c_2550 act = ls_result-rent ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-ok
act = ls_result-reason ).
ENDMETHOD.
METHOD premium_plot_water.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'PREM' iv_area = 100
iv_water = abap_true iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = c_7200 act = ls_result-rent ).
ENDMETHOD.
METHOD minimum_rent_applies.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 10
iv_water = abap_false iv_member = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = c_1000 act = ls_result-rent ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-ok
act = ls_result-reason ).
ENDMETHOD.
METHOD rounds_half_up.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 42
iv_water = abap_true iv_member = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = c_2270 act = ls_result-rent ).
ENDMETHOD.
METHOD lower_case_plot_type.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'prem' iv_area = 100
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = c_6000 act = ls_result-rent ).
ENDMETHOD.
METHOD unknown_plot_type.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'X' iv_area = 100
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-plot
act = ls_result-reason ).
cl_abap_unit_assert=>assert_equals( exp = c_0000 act = ls_result-rent ).
ENDMETHOD.
METHOD area_too_small.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 9
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-area
act = ls_result-reason ).
cl_abap_unit_assert=>assert_equals( exp = c_0000 act = ls_result-rent ).
ENDMETHOD.
METHOD area_too_large.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 501
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-area
act = ls_result-reason ).
ENDMETHOD.
METHOD plot_checked_first.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'X' iv_area = 0
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-plot
act = ls_result-reason ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,68 @@
{
"task": "G1055",
"mutants": [
{
"object": "{{P}}GARDEN_RENT",
"mutant": "line 53: > -> <= (rel)",
"status": "killed",
"hidden": "3/10",
"failed_tests": [
"AREA_TOO_LARGE",
"LOWER_CASE_PLOT_TYPE",
"MINIMUM_RENT_APPLIES",
"PREMIUM_PLOT_WATER",
"RAISED_BED_MEMBER",
"ROUNDS_HALF_UP",
"STANDARD_PLOT_RENT"
]
},
{
"object": "{{P}}GARDEN_RENT",
"mutant": "line 58: = -> <> (eq)",
"status": "killed",
"hidden": "4/10",
"failed_tests": [
"LOWER_CASE_PLOT_TYPE",
"MINIMUM_RENT_APPLIES",
"PREMIUM_PLOT_WATER",
"RAISED_BED_MEMBER",
"ROUNDS_HALF_UP",
"STANDARD_PLOT_RENT"
]
},
{
"object": "{{P}}GARDEN_RENT",
"mutant": "line 61: abap_true -> abap_false (bool)",
"status": "killed",
"hidden": "5/10",
"failed_tests": [
"LOWER_CASE_PLOT_TYPE",
"PREMIUM_PLOT_WATER",
"RAISED_BED_MEMBER",
"ROUNDS_HALF_UP",
"STANDARD_PLOT_RENT"
]
},
{
"object": "{{P}}GARDEN_RENT",
"mutant": "line 62: * -> / (arith)",
"status": "killed",
"hidden": "8/10",
"failed_tests": [
"RAISED_BED_MEMBER",
"ROUNDS_HALF_UP"
]
},
{
"object": "{{P}}GARDEN_RENT",
"mutant": "line 74: OR -> AND (logic)",
"status": "invalid",
"hidden": "0/0",
"failed_tests": []
}
],
"valid": 4,
"killed": 4,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,94 @@
CLASS {{p}}garden_rent DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_plot_type TYPE c LENGTH 4.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
TYPES:
BEGIN OF ty_result,
reason TYPE ty_reason,
rent TYPE ty_amount,
END OF ty_result.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
plot TYPE ty_reason VALUE 'PLOT',
area TYPE ty_reason VALUE 'AREA',
END OF c_reason.
METHODS calculate
IMPORTING iv_plot_type TYPE ty_plot_type
iv_area TYPE i
iv_water TYPE abap_bool
iv_member TYPE abap_bool
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_min_area TYPE i VALUE 10,
c_max_area TYPE i VALUE 500,
c_water_units TYPE i VALUE 120000,
c_member_percent TYPE i VALUE 85,
c_scale TYPE i VALUE 100,
c_half_cent TYPE i VALUE 50,
c_min_rent_cents TYPE i VALUE 1000,
c_cent_factor TYPE ty_amount VALUE '0.01'.
METHODS is_valid_plot_type
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS rate_units
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_units) TYPE i.
METHODS to_amount
IMPORTING iv_cents TYPE i
RETURNING VALUE(rv_rent) TYPE ty_amount.
ENDCLASS.
CLASS {{p}}garden_rent IMPLEMENTATION.
METHOD calculate.
IF is_valid_plot_type( iv_plot_type ) = abap_false.
rs_result-reason = c_reason-plot.
RETURN.
ENDIF.
IF iv_area < c_min_area OR iv_area > c_max_area.
rs_result-reason = c_reason-area.
RETURN.
ENDIF.
DATA(lv_units) = iv_area * rate_units( iv_plot_type ).
IF iv_water = abap_true.
lv_units = lv_units + c_water_units.
ENDIF.
IF iv_member = abap_true.
lv_units = ( lv_units * c_member_percent ) DIV c_scale.
ENDIF.
DATA(lv_cents) = ( lv_units + c_half_cent ) DIV c_scale.
IF lv_cents < c_min_rent_cents.
lv_cents = c_min_rent_cents.
ENDIF.
rs_result-rent = to_amount( lv_cents ).
rs_result-reason = c_reason-ok.
ENDMETHOD.
METHOD is_valid_plot_type.
CASE to_upper( iv_plot_type ).
WHEN 'STD' OR 'PREM' OR 'BED'.
rv_valid = abap_true.
ENDCASE.
ENDMETHOD.
METHOD rate_units.
CASE to_upper( iv_plot_type ).
WHEN 'STD'.
rv_units = 3500.
WHEN 'PREM'.
rv_units = 6000.
WHEN 'BED'.
rv_units = 9000.
ENDCASE.
ENDMETHOD.
METHOD to_amount.
DATA(lv_cents) = CONV ty_amount( iv_cents ).
rv_rent = lv_cents * c_cent_factor.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,71 @@
CLASS ltc_garden_rent DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
DATA mo_cut TYPE REF TO {{p}}garden_rent.
METHODS setup.
METHODS standard_plot_rent FOR TESTING.
METHODS member_discount FOR TESTING.
METHODS water_connection_fee FOR TESTING.
METHODS minimum_rent FOR TESTING.
METHODS rounds_half_up FOR TESTING.
METHODS unknown_plot_type FOR TESTING.
METHODS area_out_of_range FOR TESTING.
ENDCLASS.
CLASS ltc_garden_rent IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}garden_rent( ).
ENDMETHOD.
METHOD standard_plot_rent.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 100
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '35.00' ) act = ls_result-rent ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-ok
act = ls_result-reason ).
ENDMETHOD.
METHOD member_discount.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 100
iv_water = abap_false iv_member = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '29.75' ) act = ls_result-rent ).
ENDMETHOD.
METHOD water_connection_fee.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'PREM' iv_area = 100
iv_water = abap_true iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '72.00' ) act = ls_result-rent ).
ENDMETHOD.
METHOD minimum_rent.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 10
iv_water = abap_false iv_member = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '10.00' ) act = ls_result-rent ).
ENDMETHOD.
METHOD rounds_half_up.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 42
iv_water = abap_true iv_member = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '22.70' ) act = ls_result-rent ).
ENDMETHOD.
METHOD unknown_plot_type.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'X' iv_area = 100
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-plot
act = ls_result-reason ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '0.00' ) act = ls_result-rent ).
ENDMETHOD.
METHOD area_out_of_range.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 9
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-area
act = ls_result-reason ).
ls_result = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 501
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-area
act = ls_result-reason ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,61 @@
# 1. Goal
A community garden association rents garden plots to its tenants and charges an
annual rent for each plot. The billing program of the association calls one
calculation for each plot. The program needs the rent and one reason code for
each plot.
# 2. Open questions
None.
# 3. Context
- The class {{P}}GARDEN_RENT does not exist. Create it in package $TMP.
- The billing program calls the class for each plot. It passes the plot type, the
area of the plot in square metres, a flag that tells if the plot has a water
connection, and a flag that tells if the tenant is a member of the association.
# 4. Contract
- Create the class {{P}}GARDEN_RENT in package $TMP.
- The class is public and final. It has a public constructor without parameters.
- Do not add other public methods.
- Define these public types:
- TY_PLOT_TYPE: type c, length 4.
- TY_REASON: type c, length 10.
- TY_AMOUNT: type p, length 8, 2 decimals.
- TY_RESULT: structure with the components REASON (type TY_REASON) and RENT
(type TY_AMOUNT).
- Define the public constant structure C_REASON with the components OK, PLOT and
AREA. The values are 'OK', 'PLOT' and 'AREA'.
- The class has the public method CALCULATE with these parameters:
- importing IV_PLOT_TYPE, type TY_PLOT_TYPE.
- importing IV_AREA, type i.
- importing IV_WATER, type abap_bool.
- importing IV_MEMBER, type abap_bool.
- returning RS_RESULT, type TY_RESULT.
# 5. Business rules
Apply the rules in this sequence. The first rule that fails decides the result.
1. Convert the plot type to upper case.
2. The plot type must be STD, PREM or BED. If not, return the reason PLOT and the
rent 0.00.
3. The area must be between 10 and 500 square metres. Both limits are included.
If not, return the reason AREA and the rent 0.00.
4. The rent per square metre depends on the plot type: STD = 0.35, PREM = 0.60,
BED = 0.90.
5. The rent is the area multiplied by the rent per square metre.
6. If the plot has a water connection, add 12.00.
7. If the tenant is a member of the association, subtract 15 percent of that
amount.
8. Round the rent to two decimals. Round half up: 22.695 becomes 22.70.
9. The rent must be at least 10.00. If it is less, use 10.00.
10. Return the reason OK and the rent.
# 6. Constraints
- Release target: 8.16.
- Coding standards: Clean ABAP. Method length below 40 statements. No global
variables. No comment that restates the code.
- Out of scope: do not create other objects and do not use a database table.
# 7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.

View File

@@ -0,0 +1,41 @@
{
"id": "G1055",
"category": "A",
"object_type": "CLAS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [],
"contract": [
{
"type": "CLAS",
"name": "{{P}}GARDEN_RENT"
}
],
"out_of_scope": [],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T02_GARDEN_HIDDEN",
"file": "hidden/t02_garden_hidden.clas.abap",
"description": "T02 hidden tests for the annual rent of a community garden plot"
}
],
"reference": [
{
"type": "CLAS",
"name": "{{P}}GARDEN_RENT",
"file": "reference/garden_rent.clas.abap",
"description": "Annual rent of a community garden plot",
"testclasses_file": "reference/garden_rent.testclasses.abap"
}
],
"craft_checks": [
"method_length",
"cyclomatic_complexity"
]
}