From 91b91b96fabf63183445f8a504199b9cc3face25 Mon Sep 17 00:00:00 2001 From: Janne Suominen Date: Tue, 29 Oct 2024 12:19:22 +0200 Subject: [PATCH 1/2] UHF-10877: Add rest queries for testing race condition things. Suggestion for fixing race conditions. --- .../src/ApplicationUploaderService.php | 19 ++++++- tools/http/ATV.http | 4 +- tools/http/Integraatio.http | 50 +++++++++++++++++++ tools/http/http-client.env.json | 8 +++ 4 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 tools/http/Integraatio.http create mode 100644 tools/http/http-client.env.json diff --git a/public/modules/custom/grants_handler/src/ApplicationUploaderService.php b/public/modules/custom/grants_handler/src/ApplicationUploaderService.php index 38d88ae06..53c8c9fbc 100644 --- a/public/modules/custom/grants_handler/src/ApplicationUploaderService.php +++ b/public/modules/custom/grants_handler/src/ApplicationUploaderService.php @@ -191,8 +191,19 @@ public function handleApplicationUploadViaIntegration( * the most recent version available even if integration fails * for some reason. */ - $updatedDocumentFromAtv = $this->handleApplicationUploadToAtv($applicationData, $applicationNumber, $submittedFormData); - $myJSON = Json::encode($updatedDocumentFromAtv->getContent()); + $updatedDocumentFromAtv = $this->handleApplicationUploadToAtv($applicationData, $applicationNumber, $submittedFormData); + $myJSON = Json::encode($updatedDocumentFromAtv->getContent()); + + /* + * This is how we could send the data to the integration w/o saving it to ATV first. + */ +// $webform_submission = $this->applicationGetterService->submissionObjectFromApplicationNumber($applicationNumber); +// $appDocumentContent = +// $this->helfiAtvAtvSchema->typedDataToDocumentContent( +// $applicationData, +// $webform_submission, +// $submittedFormData); +// $myJSON = Json::encode($appDocumentContent); // No matter what the debug value is, we do NOT log json in PROD. if ($this->isDebug() && Helpers::getAppEnv() !== 'PROD') { @@ -213,6 +224,10 @@ public function handleApplicationUploadViaIntegration( try { $headers = []; + // Use service to get desired status if no ATV saving was done. + // $headers['X-Case-Status'] = $this->grantsHandlerApplicationStatusService->getNewStatusHeader(); + + // Get status from updated document. $headers['X-Case-Status'] = $updatedDocumentFromAtv->getStatus(); // We set the data source for integration to be used in controlling diff --git a/tools/http/ATV.http b/tools/http/ATV.http index be6ec438c..c3a407258 100644 --- a/tools/http/ATV.http +++ b/tools/http/ATV.http @@ -1,6 +1,6 @@ # Get single document by transaction_id GET {{atvUrl}}/v1/documents/? - transaction_id={{transaction_id}} + transaction_id={{transactionId}} Accept-Encoding: utf8 X-Api-Key: {{atvApiKey}} @@ -19,7 +19,7 @@ GET {{atvUrl}}/v1/documents/? user_id={{user_id}}& type={{type}}& service_name=AvustushakemusIntegraatio& - transaction_id={{transaction_id}} + transaction_id={{transactionId}} Accept-Encoding: utf8 X-Api-Key: {{atvApiKey}} diff --git a/tools/http/Integraatio.http b/tools/http/Integraatio.http new file mode 100644 index 000000000..fe97c5a54 --- /dev/null +++ b/tools/http/Integraatio.http @@ -0,0 +1,50 @@ +### Create Event via integration API +POST {{integraatioUrl}}/createEvent +Authorization: Basic {{integraatioBasicToken}} +Content-Type: application/json + +{ + "caseId": "{{transactionId}}", + "eventType": "EVENT_INFO", + "eventCode": 0, + "eventSource": "Avustusten kasittelyjarjestelma", + "eventDescription": "Puhakka Tero;09 310 36070;tero.puhakka@hel.fi", + "eventDescription_SV": null, + "eventDescription_EN": null, + "timeUpdated": null, + "timeCreated": "{{$isoTimestamp}}", + "eventTarget": null, + "eventID": "{{$random.uuid}}" +} + +### Create Status Update via integration API +POST {{integraatioUrl}}/updateCitizenCaseStatus +Authorization: Basic {{integraatioBasicToken}} +Content-Type: application/json + +{ + "caseId": "{{transactionId}}", + "citizenCaseStatus" : "PROCESSING", + "eventType" : "STATUS_UPDATE", + "eventCode" : 0, + "eventSource" : "Avustusten kasittelyjarjestelma", + "timeUpdated" : null, + "timeCreated": "{{$isoTimestamp}}" +} + +### Create Message via integration API +POST {{integraatioUrl}}/createConversationMessage +Authorization: Basic {{integraatioBasicToken}} +Content-Type: application/json + +{ +"caseId": "{{transactionId}}", +"messageId" : "{{$random.uuid}}", +"body" : "Lorem ipsum dolor sit amet, consectetur adipiscing elit", +"sentBy" : "Avustusten kasittelyjarjestelma", +"sendDateTime" :"{{$isoTimestamp}}" +} + +### + + diff --git a/tools/http/http-client.env.json b/tools/http/http-client.env.json new file mode 100644 index 000000000..719f9b855 --- /dev/null +++ b/tools/http/http-client.env.json @@ -0,0 +1,8 @@ +{ + "dev": { + "atvUrl": "https://atv-api-hki-kanslia-atv-test.agw.arodevtest.hel.fi", + "transactionId": "LOCALYRTTI12-068-0000647", + "document_id": "28753685-24b8-4542-b1c1-cc70ff9f9fbc", + "integraatioUrl": "https://avustus-integration-test.agw.arodevtest.hel.fi" + } +} From 85b2d01313aeeec8818625690271fe9f64bb9800 Mon Sep 17 00:00:00 2001 From: Janne Suominen Date: Tue, 29 Oct 2024 12:44:40 +0200 Subject: [PATCH 2/2] UHF-10877: PHPCS --- .../src/ApplicationUploaderService.php | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/public/modules/custom/grants_handler/src/ApplicationUploaderService.php b/public/modules/custom/grants_handler/src/ApplicationUploaderService.php index 53c8c9fbc..66966a96e 100644 --- a/public/modules/custom/grants_handler/src/ApplicationUploaderService.php +++ b/public/modules/custom/grants_handler/src/ApplicationUploaderService.php @@ -191,19 +191,8 @@ public function handleApplicationUploadViaIntegration( * the most recent version available even if integration fails * for some reason. */ - $updatedDocumentFromAtv = $this->handleApplicationUploadToAtv($applicationData, $applicationNumber, $submittedFormData); - $myJSON = Json::encode($updatedDocumentFromAtv->getContent()); - - /* - * This is how we could send the data to the integration w/o saving it to ATV first. - */ -// $webform_submission = $this->applicationGetterService->submissionObjectFromApplicationNumber($applicationNumber); -// $appDocumentContent = -// $this->helfiAtvAtvSchema->typedDataToDocumentContent( -// $applicationData, -// $webform_submission, -// $submittedFormData); -// $myJSON = Json::encode($appDocumentContent); + $updatedDocumentFromAtv = $this->handleApplicationUploadToAtv($applicationData, $applicationNumber, $submittedFormData); + $myJSON = Json::encode($updatedDocumentFromAtv->getContent()); // No matter what the debug value is, we do NOT log json in PROD. if ($this->isDebug() && Helpers::getAppEnv() !== 'PROD') { @@ -224,9 +213,6 @@ public function handleApplicationUploadViaIntegration( try { $headers = []; - // Use service to get desired status if no ATV saving was done. - // $headers['X-Case-Status'] = $this->grantsHandlerApplicationStatusService->getNewStatusHeader(); - // Get status from updated document. $headers['X-Case-Status'] = $updatedDocumentFromAtv->getStatus();