I have resolved the issue as below:-
Put the steps till post request in another feature file as below:-
@ignore
Feature: Reusable
Background: Maintenance Soap Request
* def DbUtils = Java.type('util.DbUtils')
* def db = new DbUtils(eposEnvironment.database[defaultEntity])
* url eposEnvironment.baseUrl
@Limit-GTC-Straddle @parallel=false
Scenario: Limit-GTC-Straddle
* def derivativeOrderTemp =
"""
function() {
var count = 1
while (count <= 10) {
var selectRandomLetter = db.readRows("select chr(trunc(dbms_random.value(65,74))) firstLetter, chr(trunc(dbms_random.value(80,90))) lastLetter, trunc(dbms_random.value(1, 4)) positionToBuy, to_char(current_date + 364, 'YYYY-MM-DD') expDate from dual")
var symbol1FromDB = db.readRows("select * from (select be_symbool, RTRIM(be_muntsoort) as be_muntsoort, be_code, be_optietype, be_expiratiedatum as be_expiratiedatum2, to_char(to_date(be_expiratiedatum, 'YYYYMMDD'), 'YYYY-MM-DD') as be_expiratiedatum, be_exerciseprijs, brs_naam, be_bv_beurs, round(max (quot_laat) keep (dense_rank last order by quot_datum)+ 1, 0) as limit, (round(max (quot_laat) keep (dense_rank last order by quot_datum)+ 1, 0)*100*-1*" + selectRandomLetter[0].POSITIONTOBUY + ") effAmount, be_volgnummer from beleggingsinstrument join fn_quotes_table on quot_symbool = be_symbool and quot_optietype = be_optietype and quot_expiratiedatum = be_expiratiedatum and quot_exerciseprijs = be_exerciseprijs join beurzen on brs_nummer = be_bv_beurs where be_Symbool in (select be_symbool from beleggingsinstrument where be_bi_nummer = 100 and length(trim(be_symbool)) < 4 and substr(trim(be_symbool),1,1) between '" + selectRandomLetter[0].FIRSTLETTER + "' and '" + selectRandomLetter[0].LASTLETTER + "' and be_geblokkeerd = 0 and be_handelen_toegestaan = 1 and be_referentiesymbool = ' ') and be_optietype = 'CALL' and be_handelen_toegestaan = 1 and be_expiratiedatum > to_char(sysdate, 'yyyymmdd') group by be_symbool, be_muntsoort, be_code, be_optietype, be_expiratiedatum, be_exerciseprijs, be_bv_beurs, quot_laat, brs_naam, quot_laat, quot_datum, be_volgnummer ) where rownum = 1")
karate.log('Symbol1FromDB-->', symbol1FromDB)
if (symbol1FromDB.length >= 1) {
karate.log('condition satisfied, exiting from first conditionalGoto1 loop counter');
var indirectCosts1FromDB = db.readRows("select icf_cfcu_id, cfcu_description, decode(icf_amount, null, 0, icf_amount) icf_amount, decode(icf_currency, null, 'NULL', icf_currency) icf_currency, decode(icf_percentage, null, 0, icf_percentage) icf_percentage from EPP_OWNER.INDIRECT_COSTS_PER_FUND join epp_owner.calculationrules on cfcu_id = icf_cfcu_id where icf_be_id = " + symbol1FromDB[0].BE_VOLGNUMMER + " and (icf_import_date_till > to_char(sysdate, 'yy-mm-dd') or icf_search_date_till is null) and icf_ex_ante_ex_post_ind = 'A' and icf_cfcu_id in (67)")
karate.log('indirectCosts1FromDB-->', indirectCosts1FromDB)
var symbol2FromDB = db.readRows("select * from (select be_symbool, RTRIM(be_muntsoort) as be_muntsoort, be_code, be_optietype, to_char(to_date(be_expiratiedatum, 'YYYYMMDD'), 'YYYY-MM-DD') as be_expiratiedatum, be_exerciseprijs, brs_naam, be_bv_beurs, round(max (quot_laat) keep (dense_rank last order by quot_datum)+ 1, 0) as limit, (round(max (quot_laat) keep (dense_rank last order by quot_datum)+ 1, 0)*100*-1*" + selectRandomLetter[0].POSITIONTOBUY + ") effAmount, be_volgnummer from beleggingsinstrument join fn_quotes_table on quot_symbool = be_symbool and quot_optietype = be_optietype and quot_expiratiedatum = be_expiratiedatum and quot_exerciseprijs = be_exerciseprijs join beurzen on brs_nummer = be_bv_beurs where be_Symbool = '" + symbol1FromDB[0].BE_SYMBOOL + "' and be_optietype = 'PUT' and be_handelen_toegestaan = 1 and be_expiratiedatum = '" + symbol1FromDB[0].BE_EXPIRATIEDATUM2 + "' group by be_symbool, be_muntsoort, be_code, be_optietype, be_expiratiedatum, be_exerciseprijs, be_bv_beurs, quot_laat, brs_naam, quot_laat, quot_datum, be_volgnummer ) where rownum = 1")
karate.log('Symbol2FromDB-->', symbol2FromDB)
var indirectCosts2FromDB = db.readRows("select icf_cfcu_id, cfcu_description, decode(icf_amount, null, 0, icf_amount) icf_amount, decode(icf_currency, null, 'NULL', icf_currency) icf_currency, decode(icf_percentage, null, 0, icf_percentage) icf_percentage from EPP_OWNER.INDIRECT_COSTS_PER_FUND join epp_owner.calculationrules on cfcu_id = icf_cfcu_id where icf_be_id = " + symbol2FromDB[0].BE_VOLGNUMMER + " and (icf_import_date_till > to_char(sysdate, 'yy-mm-dd') or icf_search_date_till is null) and icf_ex_ante_ex_post_ind = 'A' and icf_cfcu_id in (67)")
karate.log('indirectCosts2FromDB-->', indirectCosts2FromDB)
var selectRandomNumber = db.readRows("select trunc(dbms_random.value(10020000, 10050000)) min, trunc(dbms_random.value(11000000, 11500000)) max from dual")
karate.log('selectRandomNumber-->', selectRandomNumber)
var holderFromDB = db.readRows("SELECT * from (select ap_relatienr, ap_rekeningnr, hpp_holdernummer, ppr_id from aktuele_posities ap join epp_owner.rekeningen_per_product on rpp_relatienummer = ap.ap_relatienr and rpp_rekening_nummer = ap.ap_rekeningnr and rpp_rekeningsoort = ap.ap_rekening_soort join epp_owner.holders_per_product on hpp_relatienummer = rpp_relatienummer and hpp_product = rpp_productnummer and hpp_product_volgnr = rpp_volgnr_per_product and hpp_type_holder = 1 join rekeningen on re_rekening = rpp_rekening_nummer and re_nummer = rpp_relatienummer and re_rekening_status = 2 join epp_owner.wwwusers on wus_holder = hpp_holdernummer and wus_userblocked = 0 join producten_per_relatie on ppr_relatienummer = rpp_relatienummer and ppr_productnummer = rpp_productnummer and ppr_volgnr_per_product = rpp_volgnr_per_product JOIN on_line_dossier onld ON onld.onld_relatienummer = hpp_relatienummer and onld_productnummer = rpp_productnummer join kennis_per_client a on rpp_relatienummer = ke_clientnr where rpp_productnummer = 100 and rpp_volgnr_per_product = 1 and ap.ap_rekening_soort = 1000 and ap_saldo_positie > 7000 AND ap.ap_relatienr between " + selectRandomNumber[0].MIN + " and " + selectRandomNumber[0].MAX + " and onld.onld_klasse = 16 and onld.onld_ontvangstdatum <> '00000000' and onld.onld_vervaldatum = '00000000' and ((ke_kennis_niv = 'V' or ke_ervaring = 'V') and ke_mifcat_id = 25) and not exists (select 1 from kennis_per_client b where (ke_kennis_niv = 'O' or ke_ervaring = 'O') and a.ke_clientnr = b.ke_clientnr) and rpp_relatienummer in (select cl_nummer from clienten where cl_nummer between " + selectRandomNumber[0].MIN + " and " + selectRandomNumber[0].MAX + " and cl_geb_datum < to_char(add_months(sysdate, -216), 'YYYYMMDD')) and not exists (select 1 from profiel_toevoeging_verwijderen where ptv_relatie = ap.ap_relatienr) and not exists (select 1 from rekeninghouders_details where UPPER(eor_compliancecode) like 'INSIDER%' and eor_partij_id = hpp_holdernummer) ) where rownum = 1")
karate.log('holderFromDB-->', holderFromDB)
while (count <= 10) {
if (holderFromDB.length >= 1) {
karate.log('condition satisfied, exiting from conditionalGoto2');
productId = holderFromDB[0].get('PPR_ID')
userId = holderFromDB[0].get('HPP_HOLDERNUMMER')
return {
productId,
userId
};
}
count++;
if (count >= 9) {
karate.fail('Count exceeded more than 10 times and conditionalgoto2 loop counter failed')
}
}
count++;
if (count >= 9) {
karate.fail('Count exceeded more than 10 times and conditionalgoto1 loop counter failed')
}
}
}
}
"""
* def derivativeTemp = call derivativeOrderTemp
* def productId = derivativeTemp.productId
* print 'Product Id is-->',productId
* def userId = derivativeTemp.userId
* print 'User Id is-->',userId
################GetSpendingLimit###########################
* def javaclass = Java.type('epos.positionmanagement.service.test.GetSpendingLimitRequestTest')
* def map = {deviceTypeId: 2, entityId: '#(defaultEntity)', ppr_id: '#(productId)', userId: '#(userId)' }
* def createGetSpendingLimitRequest = javaclass.getPayload(map)
Then print 'Request body--->', createGetSpendingLimitRequest
Given request createGetSpendingLimitRequest
When soap action 'Request'
Then print '\n', response
And then call this feature file from other test case feature file as below :-
@Ordering
Feature: CreateCombinationDerivativeOrderTemp
Background: Ordering Soap Request
* url eposEnvironment.baseUrl
@parallel=true
Scenario: Limit-GTC-Straddle
* call read('reusable.feature@Limit-GTC-Straddle')
* def revisionId = get response //GetSpendingLimitResponse/spendingLimit/totalAmount*1
# * eval for(var i=0; i<=10; i++) (revisionId<3000 && i<10 ? karate.call('request1.feature') : karate.fail('Condition did not fulfill in 10 occurrence hence failing the test case'))
* def condionalgoto3 =
"""
function() {
for (var i = 0; i <= 10; i++) {
if (revisionId < 3000) {
karate.call('request1.feature')
if (i >= 9) {
karate.fail('Count exceeded more than 10 times and conditionalgoto3 loop counter failed')
}
}
}
}
"""
* call condionalgoto3
Note :- These java classes I am using to create a payload xml which was requirement of the project and these java classes are nothing but the actual services which I have added as pom dependency in my project which directly gives me the payload xml request and I just create a map and fill the value in the request body so these java classes are mandatory to use.And also these db queries are being used to fetch the actual customer details from a database to prepare the request body so there is nothing which I can ignore or improve in this test case but yes in some queries they are using some random values to fetch some customer data that I can definitely use some Java/Js/Karate.range() but apart from that I really dont think I can improve anything here.