Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
AE-2014: Clarify parameter naming and docstring in move-processing-ac…
Browse files Browse the repository at this point in the history
…tion!

- Add tests to new transitions
- Remove Valitusajan umpeutuminen as it's not used
  • Loading branch information
Juholei committed Dec 5, 2023
1 parent 8e7cf6b commit 20c5927
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 17 deletions.
31 changes: 14 additions & 17 deletions etp-backend/src/main/clj/solita/etp/service/asha.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
["Vireillepano"
"Käsittely"
"Päätöksenteko"
"Tiedoksianto ja toimeenpano"
"Valitusajan umpeutuminen"])
"Tiedoksianto ja toimeenpano"])

(defn- must-exist! [n]
(when (< n 0)
Expand Down Expand Up @@ -182,36 +181,35 @@
last))

(defn move-processing-action!
"Move the case to the next step, if it the new action (processing-action parameter) is in Käsittely or Päätöksenteko
and the desired state is not already reached (not in processing-action-states)."
[sender-id request-id case-number processing-action-states processing-action]
"Move the case to the next step, if the new action (wanted-processing-action parameter) is in Käsittely or Päätöksenteko
and the desired state is not already reached (not in processing-action-states).
`processing-action-states` parameter is a map containing the processing actions that are already made and their states.
Note that this is used for both käytönvalvonta and oikeellisuuden valvonta."
[sender-id request-id case-number processing-action-states wanted-processing-action]
(when-let [action (cond
(and (= processing-action "Käsittely")
(and (= wanted-processing-action "Käsittely")
(every? #(not= ["Tiedoksianto ja toimeenpano" "UNFINISHED"] %) processing-action-states))
{:processing-action "Vireillepano"
:decision "Siirry käsittelyyn"}

(= processing-action "Päätöksenteko")
(= wanted-processing-action "Päätöksenteko")
{:processing-action "Käsittely"
:decision "Siirry päätöksentekoon"}

(= processing-action "Valitusajan umpeutuminen")
{:processing-action "Tiedoksianto ja toimeenpano"
:decision "Valmis"}

(= processing-action "Tiedoksianto ja toimeenpano")
(= wanted-processing-action "Tiedoksianto ja toimeenpano")
{:processing-action "Päätöksenteko"
:decision "Siirry tiedoksiantoon"}


(and (= processing-action "Käsittely")
(and (= wanted-processing-action "Käsittely")
(some #(= ["Tiedoksianto ja toimeenpano" "UNFINISHED"] %) processing-action-states))
{:processing-action "Tiedoksianto ja toimeenpano"
:decision "Uudelleenkäsittele asia"}

:else nil)]

(when (not (get processing-action-states processing-action))
(when (not (get processing-action-states wanted-processing-action))
(proceed-operation! sender-id request-id case-number (:processing-action action) (:decision action)))))

(defn mark-processing-action-as-ready! [sender-id request-id case-number processing-action]
Expand Down Expand Up @@ -249,8 +247,7 @@
require-vireillepano (= {"Vireillepano" "NEW"} processing-action-states)
processing-action (-> processing-action
;; Possibly redirect the processing action to Vireillepano
(with-vireillepano require-vireillepano))
_ (println "toteutettava processing-action" processing-action)]
(with-vireillepano require-vireillepano))]
(move-processing-action!
sender-id
request-id
Expand Down
26 changes: 26 additions & 0 deletions etp-backend/src/test/clj/solita/etp/service/asha_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,30 @@
:response-status 200
:request-received move-called}})]
(asha-service/move-processing-action! sender-id request-id case-number {} "Päätöksenteko")
(t/is (= 1 @move-called)))))

(t/testing "Move from Päätöksenteko to Tiedoksianto ja toimeenpano"
(let [move-called (atom 0)]
(binding [asha-service/post! (handle-requests {(render-resource "asha/moveaction/move-template.xml" {:sender-id sender-id
:request-id request-id
:case-number case-number
:processing-action "Päätöksenteko"
:proceed-decision "Siirry tiedoksiantoon"})
{:response-body "Irrelevant"
:response-status 200
:request-received move-called}})]
(asha-service/move-processing-action! sender-id request-id case-number {} "Tiedoksianto ja toimeenpano")
(t/is (= 1 @move-called)))))

(t/testing "Move from Tiedoksianto ja toimeenpano to Käsittely using 'uudelleenkäsittele asia' decision"
(let [move-called (atom 0)]
(binding [asha-service/post! (handle-requests {(render-resource "asha/moveaction/move-template.xml" {:sender-id sender-id
:request-id request-id
:case-number case-number
:processing-action "Tiedoksianto ja toimeenpano"
:proceed-decision "Uudelleenkäsittele asia"})
{:response-body "Irrelevant"
:response-status 200
:request-received move-called}})]
(asha-service/move-processing-action! sender-id request-id case-number {"Tiedoksianto ja toimeenpano" "UNFINISHED"} "Käsittely")
(t/is (= 1 @move-called))))))))

0 comments on commit 20c5927

Please sign in to comment.