diff --git a/modules/claims_api/lib/bgs_service/veteran_representative_service.rb b/modules/claims_api/lib/bgs_service/veteran_representative_service.rb index 3d37d0de7da..073e4742a48 100644 --- a/modules/claims_api/lib/bgs_service/veteran_representative_service.rb +++ b/modules/claims_api/lib/bgs_service/veteran_representative_service.rb @@ -1,23 +1,58 @@ # frozen_string_literal: true -require_relative 'veteran_representative_service/create_veteran_representative_request' -require_relative 'veteran_representative_service/read_all_veteran_representatives' - module ClaimsApi class VeteranRepresentativeService < ClaimsApi::LocalBGS def bean_name 'VDC/VeteranRepresentativeService' end - private + def create_veteran_representative(options) + injected = convert_nil_values(options) - def make_request(namespace:, **args) - super( - endpoint: 'VDC/VeteranRepresentativeService', - namespaces: { namespace => '/data' }, - transform_response: false, - **args + body = Nokogiri::XML::DocumentFragment.parse <<~EOXML + + #{injected} + + EOXML + + make_request( + endpoint: bean_name, + namespaces: { 'data' => '/data' }, + action: 'createVeteranRepresentative', + body: body.to_s, + key: 'VeteranRepresentativeReturn', + transform_response: false ) end + + # type_code: form type (I.E. 21-22 vs 21-22A) + # ptcpnt_id: participant ID + def read_all_veteran_representatives(type_code:, ptcpnt_id:) + validate! type_code, ptcpnt_id + + body = Nokogiri::XML::DocumentFragment.parse <<~EOXML + + #{ptcpnt_id} + #{type_code} + + EOXML + + ret = make_request(endpoint: bean_name, namespaces: { 'data' => '/data' }, + action: 'readAllVeteranRepresentatives', body:, + key: 'VeteranRepresentativeReturnList', + transform_response: false) || [] + + [ret].flatten + end + + private + + def validate!(type_code, ptcpnt_id) + errors = [] + errors << 'type_code is required' if type_code.nil? + errors << 'ptcpnt_id must be 1-15 digits and > 0' if ptcpnt_id.length > 15 || ptcpnt_id.to_i < 1 + + raise ArgumentError, "Errors: #{errors.join(', ')}" if errors.any? + end end end diff --git a/modules/claims_api/lib/bgs_service/veteran_representative_service/create_veteran_representative_request.rb b/modules/claims_api/lib/bgs_service/veteran_representative_service/create_veteran_representative_request.rb deleted file mode 100644 index 69823f7f0c7..00000000000 --- a/modules/claims_api/lib/bgs_service/veteran_representative_service/create_veteran_representative_request.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -module ClaimsApi - class VeteranRepresentativeService < ClaimsApi::LocalBGS - def create_veteran_representative(options) - injected = convert_nil_values(options) - body = Nokogiri::XML::DocumentFragment.parse <<~EOXML - - #{injected} - - EOXML - - make_request( - namespace: 'data', - action: 'createVeteranRepresentative', - body: body.to_s, - key: 'VeteranRepresentativeReturn' - ) - end - end -end diff --git a/modules/claims_api/lib/bgs_service/veteran_representative_service/read_all_veteran_representatives.rb b/modules/claims_api/lib/bgs_service/veteran_representative_service/read_all_veteran_representatives.rb deleted file mode 100644 index 9dfeb0e3c69..00000000000 --- a/modules/claims_api/lib/bgs_service/veteran_representative_service/read_all_veteran_representatives.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -module ClaimsApi - class VeteranRepresentativeService < ClaimsApi::LocalBGS - # type_code: form type (I.E. 21-22 vs 21-22A) - # ptcpnt_id: participant ID - def read_all_veteran_representatives(type_code:, ptcpnt_id:) - validate! type_code, ptcpnt_id - - body = Nokogiri::XML::DocumentFragment.parse <<~EOXML - - #{ptcpnt_id} - #{type_code} - - EOXML - ret = make_request(namespace: 'ns0', action: 'readAllVeteranRepresentatives', body:) - &.dig('VeteranRepresentativeReturnList') || [] - [ret].flatten - end - - def validate_read_all_veteran_representatives(type_code:, ptcpnt_id:) - validate! type_code, ptcpnt_id - rescue - false - end - - private - - def validate!(type_code, ptcpnt_id) - errors = [] - errors << 'type_code is required' if type_code.nil? - errors << 'ptcpnt_id must be 1-15 digits and > 0' if ptcpnt_id.length > 15 || ptcpnt_id.to_i < 1 - - raise ArgumentError, "Errors: #{errors.join(', ')}" if errors.any? - end - end -end diff --git a/modules/claims_api/spec/clients/bgs_client/veteran_representative_vs_poa_request_comparison_spec.rb b/modules/claims_api/spec/clients/bgs_client/veteran_representative_vs_poa_request_comparison_spec.rb deleted file mode 100644 index 58e9c18d849..00000000000 --- a/modules/claims_api/spec/clients/bgs_client/veteran_representative_vs_poa_request_comparison_spec.rb +++ /dev/null @@ -1,463 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' -require Rails.root / 'modules/claims_api/spec/rails_helper' -require 'claims_api/bgs_client' - -RSpec.describe 'VeteranRepresentative versus POARequest comparison', :bgs do # rubocop:disable RSpec/DescribeClass - it 'concerns the same underlying data' do - use_soap_cassette('results', use_spec_name_prefix: true) do - participant_ids = Set[] - comparisons = - Hash.new do |h_a, k_a| - h_a[k_a] = Hash.new do |h_b, k_b| - h_b[k_b] = {} - end - end - - page_number = 1 - page_size = 100 - - # Suspicious weird results where POARequest exists but VeteranRepresentative does not. - # exceptional_poa_codes = Set['862', 'BQX', '6B6', '9U7', '1EY'] - exceptional_poa_codes = Set[] - exceptional_participant_ids = Set['13397031', '111'] - - search_action = - ClaimsApi::BGSClient::Definitions:: - ManageRepresentativeService:: - ReadPoaRequest::DEFINITION.name - - loop do - poa_requests = search_poa_requests(page_number, page_size) - poa_requests.each do |poa_request| - participant_id = poa_request['vetPtcpntID'] - next if participant_id.blank? - next if participant_id.in?(exceptional_participant_ids) - - participant_ids << participant_id - - next if poa_request['poaCode'].in?(exceptional_poa_codes) - - proc_id = poa_request['procID'] - comparisons[participant_id][proc_id][search_action] = poa_request - end - - break if poa_requests.size < page_size - - page_number += 1 - end - - veteran_representative_action = - ClaimsApi::BGSClient::Definitions:: - VeteranRepresentativeService:: - ReadAllVeteranRepresentatives::DEFINITION.name - - poa_request_action = - ClaimsApi::BGSClient::Definitions:: - ManageRepresentativeService:: - ReadPoaRequestByParticipantId::DEFINITION.name - - counter = participant_ids.size - participant_ids.each do |participant_id| - # puts counter # uncomment for some progress tracking - counter -= 1 - - veteran_representatives = get_veteran_representatives(participant_id) - poa_requests = get_poa_requests(participant_id) - - veteran_representatives.each do |veteran_representative| - next if veteran_representative['poaCode'].in?(exceptional_poa_codes) - - # These two are about visibility logic for POARequest due to statuses. - next if veteran_representative['secondaryStatus'].to_s.strip.downcase == 'obsolete' - next unless veteran_representative['vdcStatus'].to_s.strip.downcase == 'submitted' - - comparison = - comparisons.dig( - participant_id, - veteran_representative['procId'] - ) - - comparison[veteran_representative_action] = - veteran_representative - end - - poa_requests.each do |poa_request| - next if poa_request['poaCode'].in?(exceptional_poa_codes) - - comparison = - comparisons.dig( - participant_id, - poa_request['procID'] - ) - - comparison[poa_request_action] = - poa_request - end - end - - records = comparisons.values.flat_map(&:values) - categories = records.group_by(&:keys) - tally = categories.transform_values(&:size) - - expect(tally).to eq( - %w[readPOARequest readAllVeteranRepresentatives readPOARequestByPtcpntId] => 52, - # These are because `readPOARequestByPtcpntId` only returns the latest. - %w[readPOARequest readAllVeteranRepresentatives] => 31, - # This anomaly I don't understand. They seem like they may not be - # produced in a production setting. The `exceptional_poa_codes` - # condition targets these when uncommented. - %w[readPOARequest readPOARequestByPtcpntId] => 5 - ) - - summary = - comparisons.values.filter_map do |participant| - memo = { - 'readPOARequest' => [], - 'readAllVeteranRepresentatives' => [], - 'readPOARequestByPtcpntId' => [] - } - - participant.each_value do |comparison| - comparison.each do |key, value| - memo[key] << - case key - when 'readAllVeteranRepresentatives' - value['submittedDate'] - else - value['dateRequestReceived'] - end - end - end - - next if memo['readPOARequest'].size == 1 - - memo - end - - expect(summary).to eq( - [ - { - 'readPOARequest' => [ - '2013-02-11T09:06:50-06:00', - '2014-07-16T09:54:31-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2013-02-11T09:06:50-06:00', - '2014-07-16T09:54:31-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2014-07-16T09:54:31-05:00' - ] - }, - { # This is the only representative of the missing `readAllVeteranRepresentatives` anomalies above. - 'readPOARequest' => [ - '2013-08-29T14:09:33-05:00', - '2015-10-19T09:04:34-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2013-08-29T14:09:33-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2015-10-19T09:04:34-05:00' - ] - }, - { - 'readPOARequest' => [ - '2015-03-25T17:12:26-05:00', - '2015-04-03T17:00:53-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2015-03-25T17:12:26-05:00', - '2015-04-03T17:00:53-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2015-04-03T17:00:53-05:00' - ] - }, - { - 'readPOARequest' => [ - '2015-08-18T21:44:30-05:00', - '2017-05-16T11:16:37-05:00', - '2017-07-10T09:59:12-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2015-08-18T21:44:30-05:00', - '2017-05-16T11:16:37-05:00', - '2017-07-10T09:59:12-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2017-07-10T09:59:12-05:00' - ] - }, - { - 'readPOARequest' => [ - '2016-12-06T13:12:43-06:00', - '2017-04-26T16:26:36-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2016-12-06T13:12:43-06:00', - '2017-04-26T16:26:36-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2017-04-26T16:26:36-05:00' - ] - }, - { - 'readPOARequest' => [ - '2017-07-10T15:14:30-05:00', - '2017-10-18T13:59:29-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2017-07-10T15:14:30-05:00', - '2017-10-18T13:59:29-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2017-10-18T13:59:29-05:00' - ] - }, - { - 'readPOARequest' => [ - '2017-10-18T13:35:46-05:00', - '2024-04-05T12:08:02-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2017-10-18T13:35:46-05:00', - '2024-04-05T12:08:02-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2024-04-05T12:08:02-05:00' - ] - }, - { - 'readPOARequest' => [ - '2018-02-09T07:46:42-06:00', - '2018-05-09T15:10:47-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2018-02-09T07:46:42-06:00', - '2018-05-09T15:10:47-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2018-05-09T15:10:47-05:00' - ] - }, - { - 'readPOARequest' => [ - '2018-10-04T10:36:26-05:00', - '2018-10-04T12:55:44-05:00', - '2018-11-08T10:18:10-06:00', - '2018-11-16T10:11:22-06:00' - ], - 'readAllVeteranRepresentatives' => [ - '2018-10-04T10:36:26-05:00', - '2018-10-04T12:55:44-05:00', - '2018-11-08T10:18:10-06:00', - '2018-11-16T10:11:22-06:00' - ], - 'readPOARequestByPtcpntId' => [ - '2018-11-16T10:11:22-06:00' - ] - }, - { - 'readPOARequest' => [ - '2019-02-05T10:34:33-06:00', - '2020-04-24T13:51:15-05:00', - '2022-04-12T16:05:26-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2019-02-05T10:34:33-06:00', - '2020-04-24T13:51:15-05:00', - '2022-04-12T16:05:26-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2022-04-12T16:05:26-05:00' - ] - }, - { - 'readPOARequest' => [ - '2020-02-25T13:56:42-06:00', - '2020-04-30T07:56:44-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2020-02-25T13:56:42-06:00', - '2020-04-30T07:56:44-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2020-04-30T07:56:44-05:00' - ] - }, - { - 'readPOARequest' => [ - '2021-10-15T08:36:33-05:00', - '2023-05-16T11:06:07-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2021-10-15T08:36:33-05:00', - '2023-05-16T11:06:07-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2023-05-16T11:06:07-05:00' - ] - }, - { - 'readPOARequest' => [ - '2023-03-30T08:41:51-05:00', - '2023-05-24T10:04:31-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2023-03-30T08:41:51-05:00', - '2023-05-24T10:04:31-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2023-05-24T10:04:31-05:00' - ] - }, - { - 'readPOARequest' => [ - '2023-08-23T12:16:37-05:00', - '2024-05-10T09:30:23-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2023-08-23T12:16:37-05:00', - '2024-05-10T09:30:23-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2024-05-10T09:30:23-05:00' - ] - }, - { - 'readPOARequest' => [ - '2023-09-07T13:46:48-05:00', - '2024-05-30T14:36:09-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2023-09-07T13:46:48-05:00', - '2024-05-30T14:36:09-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2024-05-30T14:36:09-05:00' - ] - }, - { - 'readPOARequest' => [ - '2024-03-01T09:13:08-06:00', - '2024-03-08T07:56:37-06:00' - ], - 'readAllVeteranRepresentatives' => [ - '2024-03-01T09:13:08-06:00', - '2024-03-08T07:56:37-06:00' - ], - 'readPOARequestByPtcpntId' => [ - '2024-03-08T07:56:37-06:00' - ] - }, - { - 'readPOARequest' => [ - '2024-04-04T13:08:05-05:00', - '2024-04-16T15:21:38-05:00', - '2024-04-18T13:01:27-05:00', - '2024-04-18T13:57:50-05:00', - '2024-04-19T14:20:45-05:00', - '2024-04-22T10:31:30-05:00', - '2024-04-23T12:55:08-05:00', - '2024-05-22T14:25:07-05:00', - '2024-05-23T07:42:50-05:00', - '2024-05-23T08:40:27-05:00', - '2024-05-29T15:20:45-05:00', - '2024-05-30T08:51:01-05:00' - ], - 'readAllVeteranRepresentatives' => [ - '2024-04-04T13:08:05-05:00', - '2024-04-16T15:21:38-05:00', - '2024-04-18T13:01:27-05:00', - '2024-04-18T13:57:50-05:00', - '2024-04-19T14:20:45-05:00', - '2024-04-22T10:31:30-05:00', - '2024-04-23T12:55:08-05:00', - '2024-05-22T14:25:07-05:00', - '2024-05-23T07:42:50-05:00', - '2024-05-23T08:40:27-05:00', - '2024-05-29T15:20:45-05:00', - '2024-05-30T08:51:01-05:00' - ], - 'readPOARequestByPtcpntId' => [ - '2024-05-30T08:51:01-05:00' - ] - } - ] - ) - end - end - - def search_poa_requests(page_number, page_size) # rubocop:disable Metrics/MethodLength - poa_codes = %w[ - 002 003 004 005 006 007 008 009 00V 010 012 014 015 016 017 018 019 020 - 021 022 023 025 027 028 030 031 032 033 034 035 036 037 038 039 040 041 - 043 044 045 046 047 048 049 050 051 052 054 055 056 059 060 064 065 070 - 071 073 074 075 077 078 079 080 081 082 083 084 085 086 087 088 090 091 - 093 094 097 095 097 1EY 4R0 4R2 4R3 6B6 862 869 8FE 9U7 BQX E5L FYT HTC - HW0 IP4 J3C JCV - ] - - action = - ClaimsApi::BGSClient::Definitions:: - ManageRepresentativeService:: - ReadPoaRequest::DEFINITION - - result = - ClaimsApi::BGSClient.perform_request(action) do |xml, data_aliaz| - xml[data_aliaz].POACodeList do - poa_codes.each do |poa_code| - xml.POACode(poa_code) - end - end - - xml[data_aliaz].SecondaryStatusList do - xml.SecondaryStatus('New') - xml.SecondaryStatus('Pending') - xml.SecondaryStatus('Accepted') - xml.SecondaryStatus('Declined') - end - - xml[data_aliaz].POARequestParameter do - xml.pageIndex(page_number) - xml.pageSize(page_size) - end - end - - Array.wrap(result['poaRequestRespondReturnVOList']) - end - - def get_poa_requests(participant_id) - action = - ClaimsApi::BGSClient::Definitions:: - ManageRepresentativeService:: - ReadPoaRequestByParticipantId::DEFINITION - - result = - ClaimsApi::BGSClient.perform_request(action) do |xml| - xml.PtcpntId(participant_id) - end - - Array.wrap(result['poaRequestRespondReturnVOList']) - end - - def get_veteran_representatives(participant_id) - action = - ClaimsApi::BGSClient::Definitions:: - VeteranRepresentativeService:: - ReadAllVeteranRepresentatives::DEFINITION - - result = - ClaimsApi::BGSClient.perform_request(action) do |xml, data_aliaz| - xml[data_aliaz].CorpPtcpntIdFormTypeCode do - xml.formTypeCode('21-22') - xml.veteranCorpPtcpntId(participant_id) - end - end - - Array.wrap(result) - end -end diff --git a/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/create_veteran_representative_request_spec.rb b/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/create_veteran_representative_request_spec.rb index 6b4a039e1cf..f0c9979722e 100644 --- a/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/create_veteran_representative_request_spec.rb +++ b/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/create_veteran_representative_request_spec.rb @@ -4,27 +4,13 @@ require 'bgs_service/veteran_representative_service' require Rails.root.join('modules', 'claims_api', 'spec', 'support', 'bgs_client_spec_helpers.rb') -metadata = { - bgs: { - service: 'veteran_representative_service', - action: 'create_veteran_representative' - } -} - -describe ClaimsApi::VeteranRepresentativeService, metadata do +describe ClaimsApi::VeteranRepresentativeService do describe '#create_veteran_representative' do subject do - service = described_class.new(**header_params) + service = described_class.new(external_uid: 'xUid', external_key: 'xKey') service.create_veteran_representative(**params) end - let(:header_params) do - { - external_uid: 'keyHere', - external_key: 'keyHere' - } - end - describe 'with valid request params' do let(:params) do { @@ -61,7 +47,7 @@ 'city' => 'Bridgeport', 'claimantPtcpntId' => '182358', 'claimantRelationship' => nil, - 'formTypeCode' => '21-22', + 'formTypeCode' => '21-22 ', 'insuranceNumbers' => nil, 'limitationAlcohol' => 'false', 'limitationDrugAbuse' => 'false', @@ -90,7 +76,7 @@ 'claimantMiddleName' => nil, 'declinedBy' => nil, 'declinedReason' => nil, - 'secondaryStatus' => nil, + 'secondaryStatus' => 'Obsolete', 'veteranFirstName' => 'VERNON', 'veteranLastName' => 'WAGNER', 'veteranMiddleName' => nil, @@ -100,7 +86,7 @@ end it 'returns a response with expected body' do - use_bgs_cassette('valid_params') do + VCR.use_cassette('claims_api/bgs/veteran_representative_service/create_veteran_representative/valid_params') do expect(subject).to eq(expected_response) end end @@ -135,7 +121,7 @@ end it 'raises Common::Exceptions::ServiceError' do - use_bgs_cassette('mpi_ptcpnt_id_instead_of_vnp_ptcpnt_id') do + VCR.use_cassette('mpi_ptcpnt_id_instead_of_vnp_ptcpnt_id') do expect { subject }.to raise_error( Common::Exceptions::ServiceError ) diff --git a/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/read_all_veteran_representatives_spec.rb b/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/read_all_veteran_representatives_spec.rb index 4bdcde0fdbf..21e03ff9985 100644 --- a/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/read_all_veteran_representatives_spec.rb +++ b/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/read_all_veteran_representatives_spec.rb @@ -4,125 +4,82 @@ require 'bgs_service/veteran_representative_service' require Rails.root.join('modules', 'claims_api', 'spec', 'support', 'bgs_client_spec_helpers.rb') -metadata = { - bgs: { - service: 'veteran_representative_service', - action: 'read_all_veteran_representatives' - }, - run_at: '2024-04-17T23:10:31+00:00' -} - -describe ClaimsApi::VeteranRepresentativeService, metadata do +describe ClaimsApi::VeteranRepresentativeService do describe '#read_all_veteran_representatives' do subject do - service = described_class.new(**header_params) + service = described_class.new external_uid: 'xUid', external_key: 'xKey' service.read_all_veteran_representatives(**params) end - describe 'with valid external uid and key' do - let(:header_params) do - { - external_uid: 'xUid', - external_key: 'xKey' - } - end - - describe 'with no params' do - let(:params) { {} } - - it 'raises ArgumentError' do - use_bgs_cassette('no_params') do - expect { subject }.to raise_error(ArgumentError) - end - end - end - - describe 'with no type_code param' do - let(:params) { { ptcpnt_id: '123456' } } + describe 'with no params' do + let(:params) { {} } - it 'raises ArgumentError' do + it 'raises ArgumentError' do + VCR.use_cassette('no_params') do expect { subject }.to raise_error(ArgumentError) end end + end - describe 'with invalid ptcpnt_id param' do - let(:params) do - { - type_code: '21-22', - ptcpnt_id: '0' - } - end + describe 'with no type_code param' do + let(:params) { { ptcpnt_id: '123456' } } - it 'raises ArgumentError' do - expect { subject }.to raise_error(ArgumentError) - end + it 'raises ArgumentError' do + expect { subject }.to raise_error(ArgumentError) end + end - describe 'with no ptcpnt_id param' do - let(:params) { { type_code: '21-22' } } - - it 'raises ArgumentError' do - expect { subject }.to raise_error(ArgumentError) - end + describe 'with invalid ptcpnt_id param' do + let(:params) do + { + type_code: '21-22', + ptcpnt_id: '0' + } end - describe 'with valid individual params' do - let(:params) do - { - type_code: '21-22A', - ptcpnt_id: '600043201' - } - end - - it 'returns poa requests' do - use_bgs_cassette('valid_individual') do - expect(subject.size).to eq(4) - end - end + it 'raises ArgumentError' do + expect { subject }.to raise_error(ArgumentError) end + end - describe 'with valid org params' do - let(:params) do - { - type_code: '21-22', - ptcpnt_id: '600043201' - } - end + describe 'with no ptcpnt_id param' do + let(:params) { { type_code: '21-22' } } - it 'returns poa requests' do - use_bgs_cassette('valid_org') do - expect(subject.size).to eq(6) - end - end + it 'raises ArgumentError' do + expect { subject }.to raise_error(ArgumentError) end + end - describe 'with a single response' do - let(:params) do - { - type_code: '21-22', - ptcpnt_id: '600043201' - } - end + describe 'with valid individual params' do + let(:params) do + { + type_code: '21-22A', + ptcpnt_id: '600043201' + } + end - it 'handles object vs array' do - use_bgs_cassette('valid_org_single') do - expect(subject.size).to eq(1) - end + it 'returns poa requests' do + VCR.use_cassette( + 'claims_api/bgs/veteran_representative_service/read_all_veteran_representatives/valid_individual' + ) do + expect(subject.size).to eq(4) end end + end - describe 'with an empty response' do - let(:params) do - { - type_code: '21-22', - ptcpnt_id: '1' - } - end + describe 'with valid org params' do + let(:params) do + { + type_code: '21-22', + ptcpnt_id: '600043201' + } + end - it 'returns an empty array' do - use_bgs_cassette('empty_response') do - expect(subject.size).to eq(0) - end + it 'returns poa requests' do + VCR.use_cassette( + 'claims_api/bgs/veteran_representative_service/read_all_veteran_representatives/valid_org' + ) do + expect(subject.size).to eq(6) end end end diff --git a/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/veteran_representative_service_spec.rb b/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/veteran_representative_service_spec.rb index 5a35a2cacad..eddeb8cd351 100644 --- a/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/veteran_representative_service_spec.rb +++ b/modules/claims_api/spec/lib/claims_api/bgs/veteran_representative_service/veteran_representative_service_spec.rb @@ -15,7 +15,9 @@ it 'does not raise ArgumentError' do service = described_class.new(**header_params) expect do - service.send(:make_request, namespace: 'testspace', action: 'testAction', body: 'this is the body', + service.send(:make_request, endpoint: 'endpoint', namespaces: { 'testspace' => '/test' }, + action: 'testAction', + body: 'this is the body', key: 'ThisIsTheKey') end.not_to raise_error(ArgumentError) end diff --git a/spec/support/vcr_cassettes/claims_api/bgs/veteran_representative_service/create_veteran_representative/valid_params.yml b/spec/support/vcr_cassettes/claims_api/bgs/veteran_representative_service/create_veteran_representative/valid_params.yml index eafca230145..4f49e7cc3ec 100644 --- a/spec/support/vcr_cassettes/claims_api/bgs/veteran_representative_service/create_veteran_representative/valid_params.yml +++ b/spec/support/vcr_cassettes/claims_api/bgs/veteran_representative_service/create_veteran_representative/valid_params.yml @@ -1,149 +1,5 @@ --- http_interactions: -- request: - method: get - uri: "/VDC/VeteranRepresentativeService?WSDL" - body: - encoding: US-ASCII - string: '' - headers: - User-Agent: - - - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - response: - status: - code: 200 - message: OK - headers: - Date: - - Tue, 23 Apr 2024 19:07:13 GMT - Server: - - Apache - X-Frame-Options: - - SAMEORIGIN - Transfer-Encoding: - - chunked - Content-Type: - - text/xml;charset=utf-8 - Strict-Transport-Security: - - max-age=16000000; includeSubDomains; preload; - body: - encoding: UTF-8 - string: |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - recorded_at: Mon, 22 Apr 2024 19:27:37 GMT - request: method: post uri: "/VDC/VeteranRepresentativeService" @@ -152,50 +8,31 @@ http_interactions: string: | - - - - VAgovAPI - - - 127.0.0.1 - 281 - VAgovAPI - keyHere - keyHere - - - + + + + VAgovAPI + + + 127.0.0.1 + 281 + VAgovAPI + xUid + xKey + + + - - - - 21-22 - 3854909 - 182359 - 074 - false - false - false - false - false - false - true - Submitted - Recognized Veterans Service Organization - 182358 - 76 Crowther Ave - Bridgeport - 06605 - CT - 2024-04-22T19:27:37Z - - - + + + 21-223854909182359074falsefalsefalsefalsefalsefalsetrueSubmittedRecognized Veterans Service Organization18235876 Crowther AveBridgeport06605CT2024-04-22T19:27:37Z + + + headers: User-Agent: - - + - "" Content-Type: - text/xml;charset=UTF-8 Host: @@ -212,7 +49,7 @@ http_interactions: message: OK headers: Date: - - Tue, 23 Apr 2024 19:07:14 GMT + - Fri, 20 Dec 2024 18:22:42 GMT Server: - Apache X-Frame-Options: @@ -228,53 +65,9 @@ http_interactions: string: - - 76 Crowther Ave - - - true - Bridgeport - 182358 - - 21-22 - - false - false - false - false - - - - 074 - 06605 - 3854909 - - - - - Recognized Veterans Service Organization - false - - - CT - Submitted - 182359 - - VERNON - WAGNER - - - - - VERNON - WAGNER - - - - - - - - recorded_at: Mon, 22 Apr 2024 19:27:37 GMT -recorded_with: VCR 6.2.0 + xmlns:ns2="http://gov.va.vba.benefits.vdc/data">76 + Crowther AvetrueBridgeport18235821-22 + falsefalsefalsefalse074066053854909Recognized + Veterans Service OrganizationfalseCTSubmitted182359VERNONWAGNERObsoleteVERNONWAGNER + recorded_at: Fri, 20 Dec 2024 18:22:42 GMT +recorded_with: VCR 6.3.1