From b8544b7cea0a65a1171742cdd698178beb72d24e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D0=B5=D0=BC?= Date: Mon, 25 Jul 2022 14:11:34 +0300 Subject: [PATCH] TD-266: Fix - empty invoice id field (#17) * fixed empty invoice id bug * fixed * fixed --- apps/capi/src/capi_handler_search.erl | 2 +- apps/capi/test/capi_bouncer_data.hrl | 6 +++++ apps/capi/test/capi_ct_helper_bouncer.erl | 17 +++++++++++++ .../test/capi_magista_stat_tests_SUITE.erl | 24 +++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/apps/capi/src/capi_handler_search.erl b/apps/capi/src/capi_handler_search.erl index 987d5cd..56c55fe 100644 --- a/apps/capi/src/capi_handler_search.erl +++ b/apps/capi/src/capi_handler_search.erl @@ -61,7 +61,7 @@ make_query(payments, Context, Req) -> #magista_PaymentSearchQuery{ common_search_query_params = CommonSearchQueryParams, payment_params = PaymentParams, - invoice_ids = [genlib_map:get('invoiceID', Req)] + invoice_ids = genlib_list:wrap(genlib_map:get('invoiceID', Req)) }. process_search_request(QueryType, Query, _Req, Context, Opts = #{thrift_fun := ThriftFun}) -> diff --git a/apps/capi/test/capi_bouncer_data.hrl b/apps/capi/test/capi_bouncer_data.hrl index f1fccd2..f66b07d 100644 --- a/apps/capi/test/capi_bouncer_data.hrl +++ b/apps/capi/test/capi_bouncer_data.hrl @@ -100,6 +100,12 @@ payment = ?CTX_ENTITY(PaymentID) }). +-define(CTX_SEARCH_PAYMENT_OP(ID, PartyID, ShopID), #ctx_v1_CommonAPIOperation{ + id = ID, + party = ?CTX_ENTITY(PartyID), + shop = ?CTX_ENTITY(ShopID) +}). + -define(CTX_SEARCH_PAYOUT_OP(ID, PartyID, ShopID, PayoutID), #ctx_v1_CommonAPIOperation{ id = ID, party = ?CTX_ENTITY(PartyID), diff --git a/apps/capi/test/capi_ct_helper_bouncer.erl b/apps/capi/test/capi_ct_helper_bouncer.erl index b3d753c..b080bd7 100644 --- a/apps/capi/test/capi_ct_helper_bouncer.erl +++ b/apps/capi/test/capi_ct_helper_bouncer.erl @@ -21,6 +21,7 @@ -export([mock_assert_webhook_op_ctx/4]). -export([mock_assert_payout_op_ctx/6]). -export([mock_assert_search_invoice_op_ctx/7]). +-export([mock_assert_search_payment_op_ctx/4]). -export([mock_assert_search_payment_op_ctx/6]). -export([mock_assert_search_payout_op_ctx/5]). -export([mock_assert_search_refund_op_ctx/7]). @@ -199,6 +200,22 @@ mock_assert_payout_op_ctx(Op, PayoutID, PartyID, ContractID, ShopID, Config) -> Config ). +-spec mock_assert_search_payment_op_ctx(_, _, _, _) -> _. +mock_assert_search_payment_op_ctx(Op, PartyID, ShopID, Config) -> + SearchCtx = ?CTX_SEARCH_PAYMENT_OP( + Op, + PartyID, + ShopID + ), + mock_arbiter( + ?assertContextMatches( + #ctx_v1_ContextFragment{ + capi = ?CTX_CAPI(SearchCtx) + } + ), + Config + ). + -spec mock_assert_search_payment_op_ctx(_, _, _, _, _, _) -> _. mock_assert_search_payment_op_ctx(Op, PartyID, ShopID, InvoiceID, PaymentID, Config) -> SearchCtx = ?CTX_SEARCH_PAYMENT_OP( diff --git a/apps/capi/test/capi_magista_stat_tests_SUITE.erl b/apps/capi/test/capi_magista_stat_tests_SUITE.erl index 5a7b425..889aaa6 100644 --- a/apps/capi/test/capi_magista_stat_tests_SUITE.erl +++ b/apps/capi/test/capi_magista_stat_tests_SUITE.erl @@ -21,6 +21,7 @@ -export([init/1]). -export([ + search_payments_without_all_optional_fields_ok_test/1, search_payments_ok_test/1, search_payments_invalid_request_test/1, search_payments_invalid_token_test/1, @@ -54,6 +55,7 @@ groups() -> {group, operations_by_any_token} ]}, {operations_by_any_token, [], [ + search_payments_without_all_optional_fields_ok_test, search_payments_ok_test, search_payments_invalid_request_test, search_payments_invalid_token_test, @@ -107,6 +109,28 @@ end_per_testcase(_Name, C) -> %%% Tests +-spec search_payments_without_all_optional_fields_ok_test(config()) -> _. +search_payments_without_all_optional_fields_ok_test(Config) -> + _ = capi_ct_helper:mock_services( + [ + capi_test_hack:get_invoice_mock(), + {magista, fun('SearchPayments', _) -> {ok, ?STAT_RESPONSE_PAYMENTS} end} + ], + Config + ), + _ = capi_ct_helper_bouncer:mock_assert_search_payment_op_ctx( + <<"SearchPayments">>, + ?STRING, + ?STRING, + Config + ), + Query = [ + {limit, 2}, + {from_time, {{2015, 08, 11}, {19, 42, 35}}}, + {to_time, {{2020, 08, 11}, {19, 42, 35}}} + ], + {ok, _, _} = capi_client_searches:search_payments(?config(context, Config), ?STRING, Query). + -spec search_payments_ok_test(config()) -> _. search_payments_ok_test(Config) -> _ = capi_ct_helper:mock_services(