pvdgm_services 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +29 -0
- data/Rakefile +40 -0
- data/app/contexts/services/accept_hl7_message_context.rb +32 -0
- data/app/contexts/services/application_mds_context.rb +21 -0
- data/app/contexts/services/complete_sltc_registration_process_context.rb +23 -0
- data/app/contexts/services/create_account_mapping_context.rb +23 -0
- data/app/contexts/services/create_configured_account_context.rb +26 -0
- data/app/contexts/services/create_configured_facility_context.rb +26 -0
- data/app/contexts/services/create_credential_context.rb +23 -0
- data/app/contexts/services/create_facility_mapping_context.rb +23 -0
- data/app/contexts/services/create_public_key_context.rb +22 -0
- data/app/contexts/services/create_service_context.rb +22 -0
- data/app/contexts/services/create_service_definition_context.rb +26 -0
- data/app/contexts/services/create_sltc_registration_context.rb +24 -0
- data/app/contexts/services/create_third_party_context.rb +22 -0
- data/app/contexts/services/hl7_message_trimming_context.rb +19 -0
- data/app/contexts/services/invoke_service_context.rb +21 -0
- data/app/contexts/services/list_sltc_providers_context.rb +22 -0
- data/app/contexts/services/mds_file_processing_context.rb +27 -0
- data/app/contexts/services/mds_file_upload_context.rb +25 -0
- data/app/contexts/services/mds_pull_context.rb +21 -0
- data/app/contexts/services/monthly_service_table_cleanup_context.rb +19 -0
- data/app/contexts/services/notify_new_registration_context.rb +22 -0
- data/app/contexts/services/notify_sltc_provider_change_context.rb +19 -0
- data/app/contexts/services/request_sltc_baseline_context.rb +23 -0
- data/app/contexts/services/update_account_mapping_context.rb +23 -0
- data/app/contexts/services/update_configured_account_context.rb +26 -0
- data/app/contexts/services/update_configured_facility_context.rb +26 -0
- data/app/contexts/services/update_credential_context.rb +23 -0
- data/app/contexts/services/update_facility_mapping_context.rb +23 -0
- data/app/contexts/services/update_public_key_context.rb +23 -0
- data/app/contexts/services/update_service_context.rb +23 -0
- data/app/contexts/services/update_service_definition_context.rb +26 -0
- data/app/contexts/services/update_third_party_context.rb +23 -0
- data/app/controllers/services/account_mappings_controller.rb +54 -0
- data/app/controllers/services/adts_controller.rb +35 -0
- data/app/controllers/services/application_controller.rb +17 -0
- data/app/controllers/services/assessment_requests_controller.rb +48 -0
- data/app/controllers/services/available_files_controller.rb +19 -0
- data/app/controllers/services/configured_account_base_controller.rb +17 -0
- data/app/controllers/services/configured_accounts_controller.rb +59 -0
- data/app/controllers/services/configured_facilities_controller.rb +65 -0
- data/app/controllers/services/facility_mappings_controller.rb +58 -0
- data/app/controllers/services/mds_files_controller.rb +75 -0
- data/app/controllers/services/mds_pull_accounts_controller.rb +57 -0
- data/app/controllers/services/public_keys_controller.rb +50 -0
- data/app/controllers/services/service_base_controller.rb +18 -0
- data/app/controllers/services/service_definition_base_controller.rb +31 -0
- data/app/controllers/services/service_definitions_controller.rb +59 -0
- data/app/controllers/services/services_controller.rb +56 -0
- data/app/controllers/services/sltc_providers_controller.rb +15 -0
- data/app/controllers/services/sltc_registrations_controller.rb +74 -0
- data/app/controllers/services/status_masking.rb +17 -0
- data/app/controllers/services/third_parties_controller.rb +47 -0
- data/app/controllers/services/third_party_base_controller.rb +17 -0
- data/app/controllers/services/validation_controller.rb +17 -0
- data/app/helpers/services/application_helper.rb +8 -0
- data/app/helpers/services/assessment_request_helper.rb +19 -0
- data/app/helpers/services/available_files_helper.rb +27 -0
- data/app/helpers/services/mds_pull_accounts_helper.rb +27 -0
- data/app/helpers/services/sltc_registrations_helper.rb +15 -0
- data/app/mailers/services_mailer.rb +57 -0
- data/app/models/services/abaqis_mds_push.rb +51 -0
- data/app/models/services/account_mapping.rb +10 -0
- data/app/models/services/application_api.rb +19 -0
- data/app/models/services/assessment_request.rb +18 -0
- data/app/models/services/available_file.rb +73 -0
- data/app/models/services/configured_account.rb +26 -0
- data/app/models/services/configured_facility.rb +16 -0
- data/app/models/services/credential.rb +9 -0
- data/app/models/services/facility_mapping.rb +12 -0
- data/app/models/services/ftp_server.rb +69 -0
- data/app/models/services/hl7_inbound_service.rb +47 -0
- data/app/models/services/hl7_message.rb +27 -0
- data/app/models/services/isc_code.rb +15 -0
- data/app/models/services/isc_code_lookup.rb +75 -0
- data/app/models/services/mds_assessment.rb +371 -0
- data/app/models/services/mds_content.rb +55 -0
- data/app/models/services/mds_pull.rb +41 -0
- data/app/models/services/mds_pull_account.rb +192 -0
- data/app/models/services/mds_push.rb +24 -0
- data/app/models/services/mds_upload.rb +64 -0
- data/app/models/services/mds_upload_content.rb +148 -0
- data/app/models/services/mds_ws_response.rb +21 -0
- data/app/models/services/mds_ws_response_handler.rb +31 -0
- data/app/models/services/pcc_mds_pull.rb +77 -0
- data/app/models/services/provider_change.rb +26 -0
- data/app/models/services/public_key.rb +11 -0
- data/app/models/services/service.rb +20 -0
- data/app/models/services/service_definition.rb +37 -0
- data/app/models/services/service_implementation.rb +29 -0
- data/app/models/services/sltc_api.rb +179 -0
- data/app/models/services/sltc_api_exception.rb +54 -0
- data/app/models/services/sltc_mds_pull.rb +230 -0
- data/app/models/services/sltc_registration.rb +23 -0
- data/app/models/services/third_party.rb +18 -0
- data/app/roles/services/account_mapping_creator.rb +13 -0
- data/app/roles/services/account_mapping_updator.rb +12 -0
- data/app/roles/services/configured_account_creator.rb +13 -0
- data/app/roles/services/configured_account_updater.rb +12 -0
- data/app/roles/services/configured_facility_creator.rb +13 -0
- data/app/roles/services/configured_facility_updater.rb +12 -0
- data/app/roles/services/credential_creator.rb +11 -0
- data/app/roles/services/credential_updater.rb +20 -0
- data/app/roles/services/facility_mapping_creator.rb +13 -0
- data/app/roles/services/facility_mapping_updater.rb +11 -0
- data/app/roles/services/hl7_adt_message_saver.rb +15 -0
- data/app/roles/services/hl7_message_trimmer.rb +14 -0
- data/app/roles/services/mds_assessment_categorizer.rb +71 -0
- data/app/roles/services/mds_file_processor.rb +86 -0
- data/app/roles/services/mds_notifications.rb +44 -0
- data/app/roles/services/monthly_service_table_cleaner.rb +19 -0
- data/app/roles/services/new_registration_notifier.rb +11 -0
- data/app/roles/services/public_key_creator.rb +14 -0
- data/app/roles/services/public_key_updater.rb +12 -0
- data/app/roles/services/service_creator.rb +13 -0
- data/app/roles/services/service_definition_creator.rb +13 -0
- data/app/roles/services/service_definition_updater.rb +12 -0
- data/app/roles/services/service_invoker.rb +25 -0
- data/app/roles/services/service_updater.rb +11 -0
- data/app/roles/services/sltc_baseline_requestor.rb +19 -0
- data/app/roles/services/sltc_provider_change_notifier.rb +25 -0
- data/app/roles/services/sltc_provider_lister.rb +13 -0
- data/app/roles/services/sltc_registration_completer.rb +81 -0
- data/app/roles/services/sltc_registration_saver.rb +13 -0
- data/app/roles/services/submit_mds_file_for_processing.rb +28 -0
- data/app/roles/services/third_party_creator.rb +13 -0
- data/app/roles/services/third_party_updater.rb +12 -0
- data/app/utils/services/file_upload_handler.rb +33 -0
- data/app/utils/services/mds_upload_filters.rb +26 -0
- data/app/utils/services/mds_xml_file_parser.rb +104 -0
- data/app/utils/services/upload_file.rb +13 -0
- data/app/validators/isc_code_validator.rb +42 -0
- data/app/validators/mds_birthdate_validator.rb +37 -0
- data/app/validators/mds_date_validator.rb +8 -0
- data/app/validators/mds_integer_validator.rb +15 -0
- data/app/validators/mds_version_validator.rb +16 -0
- data/app/validators/state_code_validator.rb +9 -0
- data/app/views/layouts/services/application.html.erb +14 -0
- data/app/views/services/account_mappings/index.json.jbuilder +9 -0
- data/app/views/services/account_mappings/show.json.jbuilder +7 -0
- data/app/views/services/assessment_requests/index.json.jbuilder +11 -0
- data/app/views/services/available_files/index.json.jbuilder +13 -0
- data/app/views/services/configured_accounts/index.json.jbuilder +13 -0
- data/app/views/services/configured_accounts/show.json.jbuilder +11 -0
- data/app/views/services/configured_facilities/index.json.jbuilder +13 -0
- data/app/views/services/configured_facilities/show.json.jbuilder +11 -0
- data/app/views/services/facility_mappings/index.json.jbuilder +10 -0
- data/app/views/services/facility_mappings/show.json.jbuilder +8 -0
- data/app/views/services/mds_files/create.builder +10 -0
- data/app/views/services/mds_pull_accounts/index.json.jbuilder +11 -0
- data/app/views/services/public_keys/index.json.jbuilder +8 -0
- data/app/views/services/public_keys/show.json.jbuilder +6 -0
- data/app/views/services/service_definitions/index.json.jbuilder +17 -0
- data/app/views/services/service_definitions/show.json.jbuilder +16 -0
- data/app/views/services/services/index.json.jbuilder +6 -0
- data/app/views/services/services/show.json.jbuilder +4 -0
- data/app/views/services/sltc_providers/index.json.jbuilder +10 -0
- data/app/views/services/sltc_registrations/index.json.jbuilder +10 -0
- data/app/views/services/third_parties/index.json.jbuilder +7 -0
- data/app/views/services/third_parties/show.json.jbuilder +5 -0
- data/app/views/services_mailer/burying_job.html.erb +20 -0
- data/app/views/services_mailer/delaying_job.html.erb +20 -0
- data/app/views/services_mailer/notify_sltc_client_registration.html.erb +39 -0
- data/app/views/services_mailer/notify_sltc_client_registration_invalid_request_type.html.erb +8 -0
- data/app/views/services_mailer/notify_sltc_client_registration_request_invalid.html.erb +10 -0
- data/app/views/services_mailer/notify_sltc_client_registration_validation_errors.html.erb +13 -0
- data/app/views/services_mailer/notify_sltc_provider_changes.html.erb +26 -0
- data/app/views/services_mailer/notify_support_about_no_mds_pull.html.erb +6 -0
- data/config/routes.rb +48 -0
- data/db/migrate/20140102000000_create_services_engine_tables.rb +131 -0
- data/db/migrate/20140517184450_new_services_columns.rb +24 -0
- data/db/migrate/20140525142842_new_configured_provider_table.rb +18 -0
- data/db/migrate/20140714172442_add_error_column_to_hl7_messages.rb +5 -0
- data/db/migrate/20140730164152_mds_upload_tables.rb +78 -0
- data/db/sql_data/service_data_setup.sql +24 -0
- data/lib/services/engine.rb +40 -0
- data/lib/services/version.rb +3 -0
- data/lib/services.rb +4 -0
- data/lib/tasks/services_tasks.rake +40 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +60 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +29 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +35 -0
- data/spec/dummy/config/environments/production.rb +68 -0
- data/spec/dummy/config/environments/test.rb +32 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/email.rb +1 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/schema.rb +237 -0
- data/spec/dummy/db/sql_data/services_isc_codes.sql +878 -0
- data/spec/dummy/log/test.log +3498 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/models/abaqis_mds_push_spec.rb +120 -0
- data/spec/models/available_file_spec.rb +234 -0
- data/spec/models/configured_account_spec.rb +39 -0
- data/spec/models/ftp_server_spec.rb +221 -0
- data/spec/models/isc_code_lookup_spec.rb +125 -0
- data/spec/models/isc_code_spec.rb +5 -0
- data/spec/models/mds_assessment_spec.rb +1070 -0
- data/spec/models/mds_pull_account_spec.rb +468 -0
- data/spec/models/mds_pull_spec.rb +48 -0
- data/spec/models/mds_push_spec.rb +43 -0
- data/spec/models/mds_ws_response_spec.rb +54 -0
- data/spec/models/pcc_mds_pull_spec.rb +273 -0
- data/spec/models/service_implementation_spec.rb +88 -0
- data/spec/models/sltc_api_exception_spec.rb +136 -0
- data/spec/models/sltc_api_spec.rb +192 -0
- data/spec/models/sltc_mds_pull_spec.rb +776 -0
- data/spec/roles/account_mapping_creator_spec.rb +40 -0
- data/spec/roles/account_mapping_updator_spec.rb +16 -0
- data/spec/roles/configured_account_creator_spec.rb +40 -0
- data/spec/roles/configured_account_updater_spec.rb +16 -0
- data/spec/roles/configured_facility_creator_spec.rb +40 -0
- data/spec/roles/configured_facility_updater_spec.rb +16 -0
- data/spec/roles/credential_creator_spec.rb +23 -0
- data/spec/roles/credential_updater_spec.rb +38 -0
- data/spec/roles/facility_mapping_creator_spec.rb +40 -0
- data/spec/roles/facility_mapping_updater_spec.rb +16 -0
- data/spec/roles/hl7_adt_message_saver_spec.rb +35 -0
- data/spec/roles/hl7_message_trimmer_spec.rb +31 -0
- data/spec/roles/monthly_service_table_cleaner_spec.rb +27 -0
- data/spec/roles/new_registration_notifier_spec.rb +18 -0
- data/spec/roles/service_ceator_spec.rb +34 -0
- data/spec/roles/service_definition_creator_spec.rb +40 -0
- data/spec/roles/service_definition_updater_spec.rb +16 -0
- data/spec/roles/service_invoker_spec.rb +22 -0
- data/spec/roles/service_updater_spec.rb +17 -0
- data/spec/roles/sltc_baseline_requestor_spec.rb +30 -0
- data/spec/roles/sltc_provider_lister_spec.rb +27 -0
- data/spec/roles/sltc_registration_completer_spec.rb +187 -0
- data/spec/roles/sltc_registration_saver_spec.rb +34 -0
- data/spec/roles/third_party_creator_spec.rb +34 -0
- data/spec/roles/third_party_updater_spec.rb +17 -0
- data/spec/spec_helper.rb +72 -0
- metadata +581 -0
@@ -0,0 +1,468 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::MdsPullAccount do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@mds_pull_account = Services::MdsPullAccount.new
|
7
|
+
@mds_pull_account.stub(:to_rrepr).and_return("")
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'Public Methods' do
|
11
|
+
|
12
|
+
context '#process' do
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
mock_ca = mock_model(Services::ConfiguredAccount)
|
16
|
+
mock_ca.stub(:to_rrepr).and_return("")
|
17
|
+
|
18
|
+
@mds_pull_account.configured_account = mock_ca
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should attempt to walk through all possible statuses in order to process the account" do
|
22
|
+
@mds_pull_account.should_receive(:update_attribute).with(:attempt, 1)
|
23
|
+
|
24
|
+
@mds_pull_account.should_receive(:perform_task).with(Services::MdsPullAccount::STATUS_NEW)
|
25
|
+
@mds_pull_account.should_receive(:perform_task).with(Services::MdsPullAccount::STATUS_PROVIDERS_IDENTIFIED)
|
26
|
+
@mds_pull_account.should_receive(:perform_task).with(Services::MdsPullAccount::STATUS_ASSESSMENTS_REQUESTED)
|
27
|
+
@mds_pull_account.should_receive(:perform_task).with(Services::MdsPullAccount::STATUS_FILES_IDENTIFIED)
|
28
|
+
@mds_pull_account.should_receive(:perform_task).with(Services::MdsPullAccount::STATUS_FILES_DOWNLOADED)
|
29
|
+
@mds_pull_account.should_receive(:perform_task).with(Services::MdsPullAccount::STATUS_SUBMITTED_TO_ABAQIS)
|
30
|
+
@mds_pull_account.should_receive(:perform_task).with(Services::MdsPullAccount::STATUS_FILE_SYSTEM_CLEAN)
|
31
|
+
@mds_pull_account.should_receive(:perform_task).with(Services::MdsPullAccount::STATUS_REMOTE_CLEAN)
|
32
|
+
|
33
|
+
@mds_pull_account.process
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should delay the job if the attempt number is not evenly divisible by 3" do
|
37
|
+
@mds_pull_account.should_receive(:perform_task).with(Services::MdsPullAccount::STATUS_NEW).and_raise("Failed to list files")
|
38
|
+
@mds_pull_account.should_receive(:update_attribute)
|
39
|
+
@mds_pull_account.stub(:attempt).and_return(0, 1)
|
40
|
+
|
41
|
+
ServicesMailer.should_receive(:delaying_job).with(@mds_pull_account).and_return do
|
42
|
+
double("MailMessage").tap do | mail_message |
|
43
|
+
mail_message.should_receive(:deliver)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
expect { @mds_pull_account.process }.to raise_error(Ayl::Beanstalk::RequiresJobDecay)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should bury the job if the attempt number if evenly divisible by 3" do
|
51
|
+
@mds_pull_account.should_receive(:perform_task).exactly(3).times.with(Services::MdsPullAccount::STATUS_NEW).and_raise("Failed to list files")
|
52
|
+
|
53
|
+
@mds_pull_account.should_receive(:update_attribute).exactly(3).times
|
54
|
+
@mds_pull_account.stub(:attempt).and_return(0, 1, 1, 2, 2, 3, 3)
|
55
|
+
|
56
|
+
ServicesMailer.should_receive(:delaying_job).with(@mds_pull_account).exactly(2).times.and_return do
|
57
|
+
double("MailMessage").tap do | mail_message |
|
58
|
+
mail_message.should_receive(:deliver)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
ServicesMailer.should_receive(:burying_job).with(@mds_pull_account).and_return do
|
63
|
+
double("MailMessage").tap do | mail_message |
|
64
|
+
mail_message.should_receive(:deliver)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Attempt #1
|
69
|
+
expect { @mds_pull_account.process }.to raise_error(Ayl::Beanstalk::RequiresJobDecay)
|
70
|
+
# Attempt #2
|
71
|
+
expect { @mds_pull_account.process }.to raise_error(Ayl::Beanstalk::RequiresJobDecay)
|
72
|
+
# Attempt #3
|
73
|
+
expect { @mds_pull_account.process }.to raise_error(Ayl::Beanstalk::RequiresJobBury)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'Private Methods' do
|
81
|
+
|
82
|
+
context '#service_impl' do
|
83
|
+
|
84
|
+
it "should return the instantiate service implementation class" do
|
85
|
+
mock_service_implementation = double("ServiceImplementation")
|
86
|
+
|
87
|
+
mock_service_definition = double("ServiceDefinition")
|
88
|
+
mock_service_definition.should_receive(:service_implementation).and_return(mock_service_implementation)
|
89
|
+
|
90
|
+
@mds_pull_account.should_receive(:service_definition).and_return(mock_service_definition)
|
91
|
+
|
92
|
+
expect(@mds_pull_account.send(:service_impl)).to be(mock_service_implementation)
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should cache and return the instantiate service implementation class" do
|
96
|
+
mock_service_implementation = double("ServiceImplementation")
|
97
|
+
|
98
|
+
mock_service_definition = double("ServiceDefinition")
|
99
|
+
mock_service_definition.should_receive(:service_implementation).and_return(mock_service_implementation)
|
100
|
+
|
101
|
+
@mds_pull_account.should_receive(:service_definition).and_return(mock_service_definition)
|
102
|
+
|
103
|
+
expect(@mds_pull_account.send(:service_impl)).to be(mock_service_implementation)
|
104
|
+
|
105
|
+
# The second time shouldn't fire the mocks above.
|
106
|
+
expect(@mds_pull_account.send(:service_impl)).to be(mock_service_implementation)
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
context '#perform_task' do
|
112
|
+
|
113
|
+
it "should do nothing if the specified status doesn't match the status of the model" do
|
114
|
+
|
115
|
+
@mds_pull_account.status = Services::MdsPullAccount::STATUS_NEW
|
116
|
+
@mds_pull_account.should_not_receive(:send).with(Services::MdsPullAccount::STATE_MACHINE[Services::MdsPullAccount::STATUS_FILES_IDENTIFIED])
|
117
|
+
@mds_pull_account.should_not_receive(:update_attribute)
|
118
|
+
|
119
|
+
@mds_pull_account.send(:perform_task, Services::MdsPullAccount::STATUS_FILES_IDENTIFIED)
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should invoke ':identify_providers' if the status is STATUS_NEW and - if successful, update status to STATUS_PROVIDERS_IDENTIFIED" do
|
124
|
+
@mds_pull_account.status = Services::MdsPullAccount::STATUS_NEW
|
125
|
+
@mds_pull_account.should_receive(:identify_providers)
|
126
|
+
@mds_pull_account.should_receive(:update_attribute).with(:status, Services::MdsPullAccount::STATUS_PROVIDERS_IDENTIFIED)
|
127
|
+
|
128
|
+
@mds_pull_account.send(:perform_task, Services::MdsPullAccount::STATUS_NEW)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should invoke ':request_assessments_to_process' if the status is STATUS_PROVIDERS_IDENTIFIED and - if successful, update status to STATUS_ASSESSMENTS_REQUESTED" do
|
132
|
+
@mds_pull_account.status = Services::MdsPullAccount::STATUS_PROVIDERS_IDENTIFIED
|
133
|
+
@mds_pull_account.should_receive(:request_assessments_to_process)
|
134
|
+
@mds_pull_account.should_receive(:update_attribute).with(:status, Services::MdsPullAccount::STATUS_ASSESSMENTS_REQUESTED)
|
135
|
+
|
136
|
+
@mds_pull_account.send(:perform_task, Services::MdsPullAccount::STATUS_PROVIDERS_IDENTIFIED)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should invoke ':identify_files_to_pull' if the status is STATUS_ASSESSMENTS_REQUESTED and - if successful update status to STATUS_FILES_IDENTIFIED" do
|
140
|
+
@mds_pull_account.status = Services::MdsPullAccount::STATUS_ASSESSMENTS_REQUESTED
|
141
|
+
@mds_pull_account.should_receive(:identify_files_to_pull)
|
142
|
+
@mds_pull_account.should_receive(:update_attribute).with(:status, Services::MdsPullAccount::STATUS_FILES_IDENTIFIED)
|
143
|
+
|
144
|
+
@mds_pull_account.send(:perform_task, Services::MdsPullAccount::STATUS_ASSESSMENTS_REQUESTED)
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should invoke ':download_files' if the status is STATUS_FILES_IDENTIFIED and - if successful update status to STATUS_FILES_DOWNLOADED" do
|
148
|
+
@mds_pull_account.status = Services::MdsPullAccount::STATUS_FILES_IDENTIFIED
|
149
|
+
@mds_pull_account.should_receive(:download_files)
|
150
|
+
@mds_pull_account.should_receive(:update_attribute).with(:status, Services::MdsPullAccount::STATUS_FILES_DOWNLOADED)
|
151
|
+
|
152
|
+
@mds_pull_account.send(:perform_task, Services::MdsPullAccount::STATUS_FILES_IDENTIFIED)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should invoke ':submit_files_to_abaqis' if the status is STATUS_FILES_DOWNLOADED and - if successful update status to STATUS_SUBMITTED_TO_ABAQIS" do
|
156
|
+
@mds_pull_account.status = Services::MdsPullAccount::STATUS_FILES_DOWNLOADED
|
157
|
+
@mds_pull_account.should_receive(:submit_files_to_abaqis)
|
158
|
+
@mds_pull_account.should_receive(:update_attribute).with(:status, Services::MdsPullAccount::STATUS_SUBMITTED_TO_ABAQIS)
|
159
|
+
|
160
|
+
@mds_pull_account.send(:perform_task, Services::MdsPullAccount::STATUS_FILES_DOWNLOADED)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should invoke ':clean_up_file_system' if the status is STATUS_SUBMITTED_TO_ABAQIS and - if successful update status to STATUS_FILE_SYSTEM_CLEAN" do
|
164
|
+
@mds_pull_account.status = Services::MdsPullAccount::STATUS_SUBMITTED_TO_ABAQIS
|
165
|
+
@mds_pull_account.should_receive(:clean_up_file_system)
|
166
|
+
@mds_pull_account.should_receive(:update_attribute).with(:status, Services::MdsPullAccount::STATUS_FILE_SYSTEM_CLEAN)
|
167
|
+
|
168
|
+
@mds_pull_account.send(:perform_task, Services::MdsPullAccount::STATUS_SUBMITTED_TO_ABAQIS)
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should invoke ':clean_up_remote_server' if the status is STATUS_FILE_SYSTEM_CLEAN and - if successful update status to STATUS_REMOTE_CLEAN" do
|
172
|
+
@mds_pull_account.status = Services::MdsPullAccount::STATUS_FILE_SYSTEM_CLEAN
|
173
|
+
@mds_pull_account.should_receive(:clean_up_remote_server)
|
174
|
+
@mds_pull_account.should_receive(:update_attribute).with(:status, Services::MdsPullAccount::STATUS_REMOTE_CLEAN)
|
175
|
+
|
176
|
+
@mds_pull_account.send(:perform_task, Services::MdsPullAccount::STATUS_FILE_SYSTEM_CLEAN)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should do nothing if the specified status is STATUS_REMOTE_CLEAN and the current status is STATUS_REMOTE_CLEAN" do
|
180
|
+
@mds_pull_account.status = Services::MdsPullAccount::STATUS_REMOTE_CLEAN
|
181
|
+
@mds_pull_account.should_not_receive(:update_attribute)
|
182
|
+
|
183
|
+
@mds_pull_account.send(:perform_task, Services::MdsPullAccount::STATUS_REMOTE_CLEAN)
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should not update the status if the method raises an exception" do
|
187
|
+
ex = Exception.new
|
188
|
+
@mds_pull_account.status = Services::MdsPullAccount::STATUS_NEW
|
189
|
+
@mds_pull_account.should_receive(:identify_providers).and_raise(ex)
|
190
|
+
@mds_pull_account.should_not_receive(:update_attribute)
|
191
|
+
|
192
|
+
expect { @mds_pull_account.send(:perform_task, Services::MdsPullAccount::STATUS_NEW) }.to raise_error(ex)
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
context '#perform_cleanup_on_remote_server' do
|
199
|
+
|
200
|
+
it "should invoke the cleanup on the service implementation class" do
|
201
|
+
mock_ca = mock_model(Services::ConfiguredAccount)
|
202
|
+
@mds_pull_account.configured_account = mock_ca
|
203
|
+
|
204
|
+
mock_service_impl = double("ServiceImplementation")
|
205
|
+
mock_service_impl.should_receive(:perform_cleanup_on_remote_server).with(mock_ca).and_return([ 1, 2, 3 ])
|
206
|
+
|
207
|
+
@mds_pull_account.should_receive(:service_impl).and_return(mock_service_impl)
|
208
|
+
|
209
|
+
expect(@mds_pull_account.send(:perform_cleanup_on_remote_server)).to eq([ 1, 2, 3 ])
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
213
|
+
|
214
|
+
context '#clean_up_remote_server' do
|
215
|
+
|
216
|
+
before(:each) do
|
217
|
+
mock_ca = mock_model(Services::ConfiguredAccount)
|
218
|
+
mock_ca.stub(:to_rrepr).and_return("")
|
219
|
+
@mds_pull_account.configured_account = mock_ca
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should not update any AvailableFile statuses if no files have been cleared" do
|
223
|
+
@mds_pull_account.should_receive(:perform_cleanup_on_remote_server).and_return([])
|
224
|
+
|
225
|
+
Services::AvailableFile.should_not_receive(:update_all)
|
226
|
+
|
227
|
+
@mds_pull_account.send(:clean_up_remote_server)
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should update all the AvailableFile records that match the id's returned from the implementation" do
|
231
|
+
@mds_pull_account.should_receive(:perform_cleanup_on_remote_server).and_return([1,2,3])
|
232
|
+
|
233
|
+
Services::AvailableFile.should_receive(:where).with("id IN (1,2,3)").and_return do
|
234
|
+
double("WhereAvailableFiles").tap do | waf |
|
235
|
+
waf.should_receive(:update_all).with("status = '#{Services::AvailableFile::STATUS_CLEARED}'")
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
@mds_pull_account.send(:clean_up_remote_server)
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
|
244
|
+
context '#clean_up_file_system' do
|
245
|
+
|
246
|
+
before(:each) do
|
247
|
+
@mock_sd = mock_model(Services::ServiceDefinition)
|
248
|
+
|
249
|
+
@mock_ca = mock_model(Services::ConfiguredAccount)
|
250
|
+
@mock_ca.stub(:to_rrepr).and_return("")
|
251
|
+
@mds_pull_account.configured_account = @mock_ca
|
252
|
+
@mds_pull_account.stub(:service_definition).and_return(@mock_sd)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "shouldn't do much of anything if there are no files to be cleaned up" do
|
256
|
+
@mock_ca.should_receive(:available_files).and_return do
|
257
|
+
double("AvailableFiles").tap do | available_files |
|
258
|
+
available_files.should_receive(:uploaded).and_return([])
|
259
|
+
end
|
260
|
+
end
|
261
|
+
@mds_pull_account.should_not_receive(:rm_rf)
|
262
|
+
@mds_pull_account.send(:clean_up_file_system)
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should remove the file and update the status of the file as appropriate" do
|
266
|
+
mock_af = mock_model(Services::AvailableFile)
|
267
|
+
mock_af.should_receive(:download_path).and_return("/tmp/afile")
|
268
|
+
mock_af.should_receive(:update_attribute).with(:status, Services::AvailableFile::STATUS_DELETED)
|
269
|
+
|
270
|
+
@mock_ca.should_receive(:available_files).and_return do
|
271
|
+
double("AvailableFiles").tap do | available_files |
|
272
|
+
available_files.should_receive(:uploaded).and_return([ mock_af ])
|
273
|
+
end
|
274
|
+
end
|
275
|
+
@mds_pull_account.should_receive(:rm_rf).with("/tmp/afile")
|
276
|
+
@mds_pull_account.send(:clean_up_file_system)
|
277
|
+
end
|
278
|
+
|
279
|
+
end
|
280
|
+
|
281
|
+
context '#submit_files_to_abaqis' do
|
282
|
+
|
283
|
+
before(:each) do
|
284
|
+
@mock_sd = mock_model(Services::ServiceDefinition)
|
285
|
+
|
286
|
+
@mock_ca = mock_model(Services::ConfiguredAccount)
|
287
|
+
@mock_ca.stub(:to_rrepr).and_return("")
|
288
|
+
@mds_pull_account.configured_account = @mock_ca
|
289
|
+
@mds_pull_account.stub(:service_definition).and_return(@mock_sd)
|
290
|
+
end
|
291
|
+
|
292
|
+
it "should not attempt to push any MDS files to abaqis if none are available" do
|
293
|
+
mock_mds_push = double("MdsPush")
|
294
|
+
mock_mds_push.should_not_receive(:push_mds_file)
|
295
|
+
Services::AbaqisMdsPush.should_receive(:service_impl).and_return(mock_mds_push)
|
296
|
+
|
297
|
+
@mock_ca.should_receive(:available_files).and_return do
|
298
|
+
double("AvailableFiles").tap do | available_files |
|
299
|
+
available_files.should_receive(:downloaded).and_return([])
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
@mds_pull_account.send(:submit_files_to_abaqis)
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should attempt to push the MDS file to abaqis" do
|
307
|
+
mock_af = mock_model(Services::AvailableFile)
|
308
|
+
|
309
|
+
mock_mds_push = double("MdsPush")
|
310
|
+
mock_mds_push.should_receive(:push_mds_file).with(mock_af)
|
311
|
+
Services::AbaqisMdsPush.should_receive(:service_impl).and_return(mock_mds_push)
|
312
|
+
|
313
|
+
@mock_ca.should_receive(:available_files).and_return do
|
314
|
+
double("AvailableFiles").tap do | available_files |
|
315
|
+
available_files.should_receive(:downloaded).and_return([ mock_af ])
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
@mds_pull_account.send(:submit_files_to_abaqis)
|
320
|
+
end
|
321
|
+
|
322
|
+
it "should capture a failure to submit to abaqis" do
|
323
|
+
ex = Exception.new("Failed to submit")
|
324
|
+
|
325
|
+
mock_af = mock_model(Services::AvailableFile)
|
326
|
+
mock_af.should_receive(:update_attribute).with(:error, "Error pushing file to abaqis: #{ex.message}")
|
327
|
+
mock_af.stub(:to_rrepr).and_return("")
|
328
|
+
|
329
|
+
mock_mds_push = double("MdsPush")
|
330
|
+
mock_mds_push.should_receive(:push_mds_file).with(mock_af).and_raise(ex)
|
331
|
+
Services::AbaqisMdsPush.should_receive(:service_impl).and_return(mock_mds_push)
|
332
|
+
|
333
|
+
@mock_ca.should_receive(:available_files).and_return do
|
334
|
+
double("AvailableFiles").tap do | available_files |
|
335
|
+
available_files.should_receive(:downloaded).and_return([ mock_af ])
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
@mds_pull_account.send(:submit_files_to_abaqis)
|
340
|
+
end
|
341
|
+
|
342
|
+
end
|
343
|
+
|
344
|
+
context '#perform_file_downloads' do
|
345
|
+
|
346
|
+
it "should invoke the implementation's :perform_file_downloads method" do
|
347
|
+
mock_af = mock_model(Services::AvailableFile)
|
348
|
+
|
349
|
+
mock_ca = mock_model(Services::ConfiguredAccount)
|
350
|
+
@mds_pull_account.configured_account = mock_ca
|
351
|
+
|
352
|
+
mock_si = double("ServiceImplementation")
|
353
|
+
mock_si.should_receive(:perform_file_downloads).with(mock_ca, [ mock_af ]).and_return([ 1 ])
|
354
|
+
@mds_pull_account.should_receive(:service_impl).and_return(mock_si)
|
355
|
+
|
356
|
+
expect(@mds_pull_account.send(:perform_file_downloads, [ mock_af ])).to eq([ 1 ])
|
357
|
+
end
|
358
|
+
|
359
|
+
end
|
360
|
+
|
361
|
+
context '#download_files' do
|
362
|
+
|
363
|
+
before(:each) do
|
364
|
+
@mock_sd = mock_model(Services::ServiceDefinition)
|
365
|
+
|
366
|
+
@mock_ca = mock_model(Services::ConfiguredAccount)
|
367
|
+
@mock_ca.stub(:to_rrepr).and_return("")
|
368
|
+
@mds_pull_account.configured_account = @mock_ca
|
369
|
+
@mds_pull_account.stub(:service_definition).and_return(@mock_sd)
|
370
|
+
end
|
371
|
+
|
372
|
+
it "should do nothing if there are no files downloaded" do
|
373
|
+
@mock_ca.should_receive(:available_files).and_return do
|
374
|
+
double("AvailableFiles").tap do | available_files |
|
375
|
+
available_files.should_receive(:available).and_return([])
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
@mds_pull_account.should_receive(:perform_file_downloads).with([]).and_return([])
|
380
|
+
|
381
|
+
Services::AvailableFile.should_not_receive(:update_all)
|
382
|
+
|
383
|
+
@mds_pull_account.send(:download_files)
|
384
|
+
end
|
385
|
+
|
386
|
+
it "should update the status of the files that were downloaded" do
|
387
|
+
mock_af = mock_model(Services::AvailableFile)
|
388
|
+
|
389
|
+
@mock_ca.should_receive(:available_files).and_return do
|
390
|
+
double("AvailableFiles").tap do | available_files |
|
391
|
+
available_files.should_receive(:available).and_return([ mock_af ])
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
@mds_pull_account.should_receive(:perform_file_downloads).with([ mock_af ]).and_return([ mock_af.id ])
|
396
|
+
|
397
|
+
Services::AvailableFile.should_receive(:where).with("id IN (#{mock_af.id})").and_return do
|
398
|
+
double("AvailableFilesWhere").tap do | afw |
|
399
|
+
afw.should_receive(:update_all).with("status = '#{Services::AvailableFile::STATUS_DOWNLOADED}', downloaded_at = '#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}'")
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
@mds_pull_account.send(:download_files)
|
404
|
+
end
|
405
|
+
|
406
|
+
end
|
407
|
+
|
408
|
+
context '#list_available_files' do
|
409
|
+
|
410
|
+
it "should invoke the implementation's :list_available_files method" do
|
411
|
+
mock_ca = mock_model(Services::ConfiguredAccount)
|
412
|
+
@mds_pull_account.configured_account = mock_ca
|
413
|
+
|
414
|
+
mock_si = double("ServiceImplementation")
|
415
|
+
mock_si.should_receive(:list_available_files).with(mock_ca).and_return([ [ '123', 'the_file.zip' ] ])
|
416
|
+
@mds_pull_account.should_receive(:service_impl).and_return(mock_si)
|
417
|
+
|
418
|
+
expect(@mds_pull_account.send(:list_available_files)).to eq([ [ '123', 'the_file.zip' ] ])
|
419
|
+
end
|
420
|
+
|
421
|
+
end
|
422
|
+
|
423
|
+
context '#identify_files_to_pull' do
|
424
|
+
|
425
|
+
before(:each) do
|
426
|
+
@mock_sd = mock_model(Services::ServiceDefinition)
|
427
|
+
|
428
|
+
@mock_ca = mock_model(Services::ConfiguredAccount)
|
429
|
+
@mock_ca.stub(:to_rrepr).and_return("")
|
430
|
+
@mds_pull_account.configured_account = @mock_ca
|
431
|
+
@mds_pull_account.stub(:service_definition).and_return(@mock_sd)
|
432
|
+
end
|
433
|
+
|
434
|
+
it "should do nothing if there are no files to pull" do
|
435
|
+
@mds_pull_account.should_receive(:list_available_files).and_return([])
|
436
|
+
|
437
|
+
@mock_sd.should_not_receive(:available_files)
|
438
|
+
|
439
|
+
@mds_pull_account.send(:identify_files_to_pull)
|
440
|
+
end
|
441
|
+
|
442
|
+
it "should create an available file record for each file identified by the server" do
|
443
|
+
@mds_pull_account.should_receive(:list_available_files).and_return([ [ '1234', 'thefile' ], [ '2345', 'anotherfile', true ] ])
|
444
|
+
|
445
|
+
@mock_ca.should_receive(:available_files).and_return do
|
446
|
+
double("AvailableFiles").tap do | available_files |
|
447
|
+
available_files.should_receive(:create).with(request_id: '1234',
|
448
|
+
filename: 'thefile',
|
449
|
+
status: Services::AvailableFile::STATUS_AVAILABLE)
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
@mock_ca.should_receive(:available_files).and_return do
|
454
|
+
double("AvailableFiles").tap do | available_files |
|
455
|
+
available_files.should_receive(:create).with(request_id: '2345',
|
456
|
+
filename: 'anotherfile',
|
457
|
+
status: Services::AvailableFile::STATUS_AVAILABLE)
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
@mds_pull_account.send(:identify_files_to_pull)
|
462
|
+
end
|
463
|
+
|
464
|
+
end
|
465
|
+
|
466
|
+
end
|
467
|
+
|
468
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::MdsPull do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@mock_service_definition = double("ServiceDefinition")
|
7
|
+
|
8
|
+
@mds_pull = Services::MdsPull.new(@mock_service_definition)
|
9
|
+
|
10
|
+
Time.stub(:yesterday_at_midnight_mountain).and_return(Time.now)
|
11
|
+
Time.stub(:today_at_midnight_mountain).and_return(Time.now)
|
12
|
+
end
|
13
|
+
|
14
|
+
context '#invoke' do
|
15
|
+
|
16
|
+
it "should do nothing if there are no enabled accounts configured for this service" do
|
17
|
+
@mock_service_definition.should_receive(:configured_accounts).and_return do
|
18
|
+
double("ConfiguredAccounts").tap do | configured_accounts |
|
19
|
+
configured_accounts.should_receive(:enabled).and_return([])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Services::MdsPullAccount.should_not_receive(:create!)
|
24
|
+
|
25
|
+
@mds_pull.invoke
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should create an MdsPullAccount record for each enabled account configured for the service and submitt the account to async for processing" do
|
29
|
+
mock_configured_account = double("ConfiguredAccount")
|
30
|
+
|
31
|
+
@mock_service_definition.should_receive(:configured_accounts).and_return do
|
32
|
+
double("ConfiguredAccounts").tap do | configured_accounts |
|
33
|
+
configured_accounts.should_receive(:enabled).and_return([ mock_configured_account ])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
mock_pull_account = double("MdsPullAccount")
|
38
|
+
mock_pull_account.should_receive(:ayl_send_opts).with(:process, { :priority => 100, :time_to_run => 3600 })
|
39
|
+
|
40
|
+
Services::MdsPullAccount.should_receive(:create!).and_return(mock_pull_account)
|
41
|
+
|
42
|
+
@mds_pull.invoke
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::MdsPush do
|
4
|
+
|
5
|
+
context 'Instance Methods' do
|
6
|
+
before(:each) do
|
7
|
+
@service_definition = double("ServiceDefinition")
|
8
|
+
@mds_push = Services::MdsPush.new(@service_definition)
|
9
|
+
end
|
10
|
+
|
11
|
+
context '#invoke' do
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
context '#push_mds_file' do
|
16
|
+
|
17
|
+
it "should raise an exception if the downloaded file doesn't exist" do
|
18
|
+
mock_af = double("AvailableFile")
|
19
|
+
mock_af.should_receive(:downloaded_file_exists?).and_return(false)
|
20
|
+
mock_af.should_receive(:downloaded_file_path).and_return('/tmp')
|
21
|
+
|
22
|
+
expect { @mds_push.push_mds_file(mock_af) }.to raise_error
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise an exception if the downloaded file is not valid" do
|
26
|
+
mock_af = double("AvailableFile")
|
27
|
+
mock_af.should_receive(:downloaded_file_exists?).and_return(true)
|
28
|
+
mock_af.should_receive(:valid_mds_file?).and_return(false)
|
29
|
+
mock_af.should_receive(:downloaded_file_path).and_return('/tmp')
|
30
|
+
|
31
|
+
expect { @mds_push.push_mds_file(mock_af) }.to raise_error
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'Class Methods' do
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::MdsWsResponse do
|
4
|
+
|
5
|
+
context '.parse_xml_response' do
|
6
|
+
|
7
|
+
success_response = <<-EOF
|
8
|
+
<composite_file_response>
|
9
|
+
<status>SUCCESS</status>
|
10
|
+
<filename>CMP_6MB.zip</filename>
|
11
|
+
<acknowledgement_id>MDS30cu0000000000002</acknowledgement_id>
|
12
|
+
<submission_datetime>2/22/2012 13:12:36</submission_datetime>
|
13
|
+
</composite_file_response>
|
14
|
+
EOF
|
15
|
+
|
16
|
+
error_response = <<-EOF
|
17
|
+
<composite_file_response>
|
18
|
+
<status>ERROR</status>
|
19
|
+
<error_message>Authentication failed for 2.</error_message>
|
20
|
+
<submission_datetime>2/22/2012 12:55:15</submission_datetime>
|
21
|
+
</composite_file_response>
|
22
|
+
EOF
|
23
|
+
|
24
|
+
invalid_response = <<-EOF
|
25
|
+
A day in the life
|
26
|
+
EOF
|
27
|
+
|
28
|
+
it "should successfully parse a success response xml" do
|
29
|
+
response = Services::MdsWsResponse.parse_xml_response(success_response)
|
30
|
+
|
31
|
+
response.status.should == 'SUCCESS'
|
32
|
+
response.error_message.should be_nil
|
33
|
+
response.filename.should == 'CMP_6MB.zip'
|
34
|
+
response.acknowledgement_id.should == 'MDS30cu0000000000002'
|
35
|
+
response.submission_datetime.should == '2/22/2012 13:12:36'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should successfully parse an error response xml" do
|
39
|
+
response = Services::MdsWsResponse.parse_xml_response(error_response)
|
40
|
+
|
41
|
+
response.status.should == 'ERROR'
|
42
|
+
response.error_message.should == 'Authentication failed for 2.'
|
43
|
+
response.filename.should be_nil
|
44
|
+
response.acknowledgement_id.should be_nil
|
45
|
+
response.submission_datetime.should == '2/22/2012 12:55:15'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should raise an exception if non-valid XML is provided to parse" do
|
49
|
+
lambda { Services::MdsWsResponse.parse_xml_response(invalid_response) }.should raise_error
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|