CLASS zcl_integrationtest_bupa DEFINITION PUBLIC FINAL CREATE PUBLIC FOR TESTING.
PUBLIC SECTION.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_integrationtest_bupa IMPLEMENTATION.
ENDCLASS.
"!@testing SRVB:ZUI_BUSINESSPARTNER_V2
CLASS ltc_create_bupa_notes_ba DEFINITION FINAL FOR TESTING DURATION MEDIUM RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_entity_key,
BusinessPartnerUUID TYPE bu_partner_guid,
isactiveentity TYPE abap_boolean,
END OF ty_entity_key.
CLASS-DATA:
go_client_proxy TYPE REF TO /iwbep/if_cp_client_proxy,
go_cds_test_environment TYPE REF TO if_cds_test_environment,
go_sql_test_environment TYPE REF TO if_osql_test_environment.
METHODS:
"! Integration test for creating the the businesspartner notes with deep create
deep_create FOR TESTING RAISING cx_static_check,
"! Integration test create by association scenario for the business partner notes
cba_bupa_notes FOR TESTING RAISING cx_static_check,
"! Teardown performs rollback of the entities.
teardown RAISING cx_static_check,
"! This method is called before executing each test method in the test class.
"! It allows you to set up the necessary test data and initialize the test environment.
setup.
CLASS-METHODS:
"! Setup routine for the integration test for reading the businesspartner
"! It sets up the mocks for the CDS views and SQL tables and starts the local proxy.
class_setup RAISING cx_static_check,
"! Class teardown for the integration test for reading the BusinessPartner.
"! Here the mocks for the CDS-views and the databases are destroyed.
class_teardown RAISING cx_static_check.
ENDCLASS.
CLASS ltc_create_bupa_notes_ba IMPLEMENTATION.
METHOD class_setup.
zcl_bp_l_bupa_test=>class_setup_helper(
IMPORTING
ei_cds_test_environment = go_cds_test_environment
ei_sql_test_environment = go_sql_test_environment ).
" Create Proxy
go_client_proxy = /iwbep/cl_cp_client_proxy_fact=>create_v2_local_proxy( VALUE #( service_id = 'ZUI_BUSINESSPARTNER_V2'
service_version = '0001' ) ).
ENDMETHOD.
METHOD setup.
zcl_bp_l_bupa_test=>prepare_testdataset_for_partner(
ii_cds_test_environment = go_cds_test_environment
ii_sql_test_environment = go_sql_test_environment ).
ENDMETHOD.
METHOD cba_bupa_notes.
DATA:
ls_business_data_response TYPE zc_bupa_notes,
ls_entity_key TYPE ty_entity_key.
FIELD-SYMBOLS: <lv_business_data_response> TYPE data.
" Navigate to the resource
ls_entity_key-BusinessPartnerUUID = zcl_bp_l_bupa_test=>cv_partner_uuid_draft.
ls_entity_key-isactiveentity = abap_false.
"create a request for the create operation
DATA(lo_resource) = go_client_proxy->create_resource_for_entity_set( 'BusinessPartner' ).
DATA(lo_resrouce_bupa_notes) = lo_resource->navigate_with_key( ls_entity_key )->navigate_to_many( 'TO_BUPA_NOTES' ).
"set the business data for the created entity
DATA(ls_data_notes_create) = VALUE zc_bupa_notes( TextId ='Z001' TextContent ='Business Partner Note'
RelObjectGuid = zcl_bp_l_bupa_test=>cv_partner_uuid_draft ).
DATA(lo_request_create) = lo_resrouce_bupa_notes->create_request_for_create( ).
lo_request_create->set_business_data( ls_data_notes_create ).
" execute the request
DATA(lo_response_create) = lo_request_create->execute( ).
ASSIGN ls_business_data_response TO <lv_business_data_response>.
lo_response_create->get_business_data( IMPORTING es_business_data = <lv_business_data_response> ).
cl_abap_unit_assert=>assert_equals( msg = 'values do not match'
exp = ls_business_data_create-TextContent
act = ls_business_data_response-TextContent ).
SELECT * FROM zbupa_text_d INTO TABLE @DATA(lt_bupanotes_draft). "#EC CI_NOWHERE
cl_abap_unit_assert=>assert_equals( msg = 'no entry in the draft table'
exp = lines( lt_bupanotes_draft )
act = '1' ).
ENDMETHOD.
METHOD teardown.
go_cds_test_environment->clear_doubles( ).
go_sql_test_environment->clear_doubles( ).
ROLLBACK ENTITIES.
ENDMETHOD.
METHOD class_teardown.
go_cds_test_environment->destroy( ).
go_sql_test_environment->destroy( ).
ENDMETHOD.
ENDCLASS.
CLASS ltc_create_bupa_notes_ba IMPLEMENTATION.
METHOD class_setup.
zcl_bp_l_bupa_test=>class_setup_helper(
IMPORTING
ei_cds_test_environment = go_cds_test_environment
ei_sql_test_environment = go_sql_test_environment ).
" Create Proxy
go_client_proxy = /iwbep/cl_cp_client_proxy_fact=>create_v2_local_proxy( VALUE #( service_id = 'ZUI_BUSINESSPARTNER_V2'
service_version = '0001' ) ).
ENDMETHOD.
METHOD setup.
zcl_bp_l_bupa_test=>prepare_testdataset_for_partner(
ii_cds_test_environment = go_cds_test_environment
ii_sql_test_environment = go_sql_test_environment ).
ENDMETHOD.
METHOD deep_create.
TYPES: BEGIN OF ty_deep_entity,
BusinessPartnerUUID TYPE bu_partner_guid,
to_bupa_notes TYPE TABLE OF zc_bupa_notes WITH DEFAULT KEY, "#EC CI_DEFAULT_KEY
END OF ty_deep_entity.
DATA:
ls_data_notes_create TYPE zc_bupa_notes,
ls_business_data_create TYPE ty_deep_entity,
ls_business_data_response TYPE ty_deep_entity.
FIELD-SYMBOLS: <lv_business_data_response> TYPE data.
"create a request for the create operation
DATA(lo_resource) = go_client_proxy->create_resource_for_entity_set( 'BusinessPartner' ).
"set the business data for the created entity
ls_data_notes_create = VALUE #( TextId ='Z001' TextContent ='Business Partner Note'
RelObjectGuid = zcl_bp_l_bupa_test=>cv_partner_uuid_draft ).
ls_business_data_create = VALUE #(
BusinessPartnerUUID = zcl_bp_l_bupa_test=>cv_partner_uuid_draft
to_bupa_notes = VALUE #( ( ls_data_notes_create ) ) ).
DATA(lo_request_create) = lo_resource->create_request_for_create( ).
DATA(lo_cp_data_descr_node) = lo_request_create->create_data_descripton_node( ).
lo_cp_data_descr_node->add_child( iv_property_path = 'TO_BUPA_NOTES' ).
lo_request_create->set_deep_business_data(
is_business_data = ls_business_data_create
io_data_description = lo_cp_data_descr_node ).
" execute the request
DATA(lo_response_create) = lo_request_create->execute( ).
ASSIGN ls_business_data_response TO <lv_business_data_response>.
lo_response_create->get_business_data( IMPORTING es_business_data = <lv_business_data_response> ).
cl_abap_unit_assert=>assert_equals( msg = 'values do not match'
exp = ls_business_data_create-to_bupa_notes[ 1 ]-TextContent
act = ls_business_data_response-to_bupa_notes[ 1 ]-TextContent ).
SELECT * FROM zbupa_text_d INTO TABLE @DATA(lt_bupanotes_draft). "#EC CI_NOWHERE
cl_abap_unit_assert=>assert_equals( msg = 'no entry in the draft table'
exp = lines( lt_bupanotes_draft )
act = '1' ).
ENDMETHOD.
METHOD teardown.
go_cds_test_environment->clear_doubles( ).
go_sql_test_environment->clear_doubles( ).
ROLLBACK ENTITIES.
ENDMETHOD.
METHOD class_teardown.
go_cds_test_environment->destroy( ).
go_sql_test_environment->destroy( ).
ENDMETHOD.
ENDCLASS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 |