Skip to content

Commit

Permalink
Kev ma/appeals 58827 v2 (#1703)
Browse files Browse the repository at this point in the history
* Change type_description to mapping

* Updated rspecs to handle edge case
  • Loading branch information
Kevma50287 authored Sep 30, 2024
1 parent 5039af4 commit 6f77e66
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/services/json_api_response_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Translates JSON API responses into a format that's compatible with the legacy SOAP responses expected
# by most of caseflow-efolder
class JsonApiResponseAdapter
include Caseflow::DocumentTypes

def adapt_v2_fetch_documents_for(json_response)
json_response = normalize_json_response(json_response)

Expand Down Expand Up @@ -45,7 +47,9 @@ def v2_fetch_documents_file_response(file_json)
document_id: "{#{file_json['currentVersionUuid'].upcase}}",
series_id: "{#{file_json['uuid'].upcase}}",
version: "1",
type_description: provider_data["subject"],
# CE Api doesn't provide document category type desciption.
# Use Caseflow document type mapping instead, and if not found then "Unknown"
type_description: TYPES[provider_data["documentTypeId"]] || TYPES[10],
type_id: provider_data["documentTypeId"],
doc_type: provider_data["documentTypeId"],
subject: provider_data["subject"],
Expand Down
12 changes: 12 additions & 0 deletions spec/services/json_api_response_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,24 @@
expect(parsed.length).to eq 2

expect(parsed[0].document_id).to eq "{03223945-468B-4E8A-B79B-82FA73C2D2D9}"
expect(parsed[0].type_description).to eq "Rating Decision - Codesheet"
expect(parsed[0].received_at).to eq "2018/03/08"
expect(parsed[0].mime_type).to eq "application/pdf"

expect(parsed[1].document_id).to eq "{7D6AFD8C-3BF7-4224-93AE-E1F07AC43C71}"
expect(parsed[1].type_description).to eq "Rating Decision - Narrative"
expect(parsed[1].received_at).to eq "2018/12/08"
expect(parsed[1].mime_type).to eq "application/pdf"
end

it "returns type description 'Unknown' if mapping is not found in Caseflow" do
file = File.open(Rails.root.join("spec/support/api_responses/ce_api_folders_files_search_unknown.json"))
data_hash = JSON.parse(File.read(file))
file.close

parsed = described.adapt_v2_fetch_documents_for(data_hash)

expect(parsed[0].type_description).to eq "UNKNOWN"
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"page": {
"totalPages": 1,
"requestedResultsPerPage": 20,
"currentPage": 1,
"totalResults": 1
},
"files": [
{
"owner": {
"type": "VETERAN",
"id": "123456789"
},
"uuid": "23e7ae3b-5489-4fa9-b6e3-b1f953287138",
"currentVersionUuid": "03223945-468b-4e8a-b79b-82fa73c2d2d9",
"currentVersion": {
"systemData": {
"uploadedDateTime": "2018-03-08T14:21:40",
"contentName": "20180308091849 - codesheet.pdf",
"mimeType": "application/pdf",
"uploadSource": "RATING"
},
"providerData": {
"subject": "Rating Decision - Codesheet",
"documentTypeId": 999111,
"ocrStatus": "Failure to Process",
"newMail": false,
"bookmarks": {
"VBA": {
"isDefaultRealm": true
}
},
"systemSource": "RATING",
"isAnnotated": false,
"modifiedDateTime": "2018-03-08T14:21:40",
"numberOfContentions": 0,
"readByCurrentUser": false,
"dateVaReceivedDocument": "2018-03-08",
"hasContentionAnnotations": false,
"contentSource": "VBMS-R",
"actionable": false,
"lastOpenedDocument": false
}
}
}
]
}

0 comments on commit 6f77e66

Please sign in to comment.