-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
AE-2012: Add title fields for pääkäyttäjät, used in document templates
- Loading branch information
Showing
20 changed files
with
229 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
etp-core/etp-backend/src/test/clj/solita/etp/api/kayttaja_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
(ns solita.etp.api.kayttaja-test | ||
(:require [clojure.test :as t] | ||
[jsonista.core :as j] | ||
[ring.mock.request :as mock] | ||
[solita.etp.test-data.kayttaja :as test-kayttaja] | ||
[solita.etp.test-data.laatija :as laatija-test-data] | ||
[solita.etp.test-system :as ts])) | ||
|
||
(t/use-fixtures :each ts/fixture) | ||
|
||
(t/deftest kayttaja-title-test | ||
(let [user-id (test-kayttaja/insert-virtu-paakayttaja! | ||
{:etunimi "Asian" | ||
:sukunimi "Tuntija" | ||
:email "[email protected]" | ||
:puhelin "0504363675457"})] | ||
(t/testing "User can be fetched from the api after being created" | ||
(let [response (ts/handler (-> (mock/request :get (format "/api/private/kayttajat/%s" user-id)) | ||
(test-kayttaja/with-virtu-user) | ||
(mock/header "Accept" "application/json")))] | ||
(t/is (= (:status response) | ||
200)) | ||
|
||
(t/is (= (-> response :body (j/read-value j/keyword-keys-object-mapper)) | ||
{:titteli-fi nil | ||
:titteli-sv nil | ||
:etunimi "Asian" | ||
:sukunimi "Tuntija" | ||
:email "[email protected]" | ||
:puhelin "0504363675457" | ||
:cognitoid nil | ||
:henkilotunnus nil | ||
:id 1 | ||
:login nil | ||
:organisaatio "" | ||
:passivoitu false | ||
:rooli 2 | ||
:valvoja false | ||
:verifytime nil | ||
:virtu {:localid "vvirkamies" | ||
:organisaatio "testivirasto.fi"}})))) | ||
|
||
(t/testing "Setting the title fields in user update request succeeds" | ||
(let [user-update {:titteli-fi "Energia-asiantuntija" | ||
:titteli-sv "Energiexpert" | ||
:valvoja false | ||
:email "[email protected]" | ||
:puhelin "0504363675457" | ||
:sukunimi "Tuntija" | ||
:virtu {:localid "vvirkamies" | ||
:organisaatio "testivirasto.fi"} | ||
:rooli 2 | ||
:henkilotunnus nil | ||
:passivoitu false | ||
:etunimi "Asian" | ||
:organisaatio "" | ||
:api-key nil} | ||
response (ts/handler (-> (mock/request :put (format "/api/private/kayttajat/%s" user-id)) | ||
(mock/json-body user-update) | ||
(test-kayttaja/with-virtu-user) | ||
(mock/header "Accept" "application/json")))] | ||
(t/is (= (:status response) | ||
200)) | ||
|
||
(t/testing "and the title and pre-existing fields are present in the returned user" | ||
(let [user (-> (mock/request :get (format "/api/private/kayttajat/%s" user-id)) | ||
(test-kayttaja/with-virtu-user) | ||
(mock/header "Accept" "application/json") | ||
ts/handler | ||
:body | ||
(j/read-value j/keyword-keys-object-mapper))] | ||
(t/is (= user | ||
{:titteli-fi "Energia-asiantuntija" | ||
:titteli-sv "Energiexpert" | ||
:etunimi "Asian" | ||
:sukunimi "Tuntija" | ||
:email "[email protected]" | ||
:puhelin "0504363675457" | ||
:cognitoid nil | ||
:henkilotunnus nil | ||
:id 1 | ||
:login nil | ||
:organisaatio "" | ||
:passivoitu false | ||
:rooli 2 | ||
:valvoja false | ||
:verifytime nil | ||
:virtu {:localid "vvirkamies" | ||
:organisaatio "testivirasto.fi"}})))))))) | ||
|
||
(t/deftest retrieve-users-test | ||
(test-kayttaja/insert-virtu-paakayttaja! | ||
{:etunimi "Asian" | ||
:sukunimi "Tuntija" | ||
:email "[email protected]" | ||
:puhelin "0504363675457"}) | ||
(t/testing "Users can be retrieved through the api" | ||
;; Create users, together with the pääkäyttäjä there are 200 users | ||
(test-kayttaja/generate-and-insert! 199) | ||
(let [response (ts/handler (-> (mock/request :get "/api/private/kayttajat") | ||
(test-kayttaja/with-virtu-user) | ||
(mock/header "Accept" "application/json"))) | ||
users (-> response :body (j/read-value j/keyword-keys-object-mapper))] | ||
(t/is (= (:status response) 200)) | ||
(t/is (= (count users) | ||
200)) | ||
|
||
(t/testing "Users have title fields" | ||
(doseq [laatija users] | ||
(t/is (true? (contains? laatija :titteli-fi))) | ||
(t/is (true? (contains? laatija :titteli-sv))))))) | ||
|
||
(t/testing "Laatija users can be retrieved through the api" | ||
(laatija-test-data/generate-and-insert! 200) | ||
(let [response (ts/handler (-> (mock/request :get "/api/private/laatijat") | ||
(test-kayttaja/with-virtu-user) | ||
(mock/header "Accept" "application/json"))) | ||
laatijat (-> response :body (j/read-value j/keyword-keys-object-mapper))] | ||
(t/is (= (:status response) 200)) | ||
|
||
(t/is (= (count laatijat) | ||
200)) | ||
|
||
(t/testing "Laatija users don't have title fields" | ||
(doseq [laatija laatijat] | ||
(t/is (false? (contains? laatija :titteli-fi))) | ||
(t/is (false? (contains? laatija :titteli-sv)))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,9 @@ | |
{:etunimi "Asian" | ||
:sukunimi "Tuntija" | ||
:email "[email protected]" | ||
:puhelin "0504363675457"}) | ||
:puhelin "0504363675457" | ||
:titteli-fi "energia-asiantuntija" | ||
:titteli-sv "energiexpert"}) | ||
(t/testing "Käskypäätös / Kuulemiskirje toimenpide is created successfully for yksityishenkilö and document is generated with correct information" | ||
;; Add the valvonta and previous toimenpides | ||
;; so that käskypäätös / kuulemiskirje toimenpide can be created | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,9 @@ | |
{:etunimi "Asian" | ||
:sukunimi "Tuntija" | ||
:email "[email protected]" | ||
:puhelin "0504363675457"}) | ||
:puhelin "0504363675457" | ||
:titteli-fi "energia-asiantuntija" | ||
:titteli-sv "energiexpert"}) | ||
(t/testing "Käskypäätös / varsinainen päätös toimenpide is created successfully for yksityishenkilö and document is generated with correct information" | ||
;; Add the valvonta and previous toimenpides | ||
;; so that käskypäätös / kuulemiskirje toimenpide can be created | ||
|
@@ -568,7 +570,9 @@ | |
{:etunimi "Asian" | ||
:sukunimi "Tuntija" | ||
:email "[email protected]" | ||
:puhelin "0504363675457"}) | ||
:puhelin "0504363675457" | ||
:titteli-fi "energia-asiantuntija" | ||
:titteli-sv "energiexpert"}) | ||
(t/testing "Käskypäätös / varsinainen päätös toimenpide is created successfully for yksityishenkilö even though yritysosapuoli with same id exists" | ||
;; Add the valvonta and previous toimenpides | ||
;; so that käskypäätös / kuulemiskirje toimenpide can be created | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,9 @@ | |
{:etunimi "Asian" | ||
:sukunimi "Tuntija" | ||
:email "[email protected]" | ||
:puhelin "0504363675457"}) | ||
:puhelin "0504363675457" | ||
:titteli-fi "energia-asiantuntija" | ||
:titteli-sv "energiexpert"}) | ||
(t/testing "Preview api call for sakkopäätös / kuulemiskirje toimenpide succeeds" | ||
(let [valvonta-id (valvonta-service/add-valvonta! ts/*db* | ||
{:katuosoite "Testitie 5" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,9 @@ | |
{:etunimi "Asian" | ||
:sukunimi "Tuntija" | ||
:email "[email protected]" | ||
:puhelin "0504363675457"}) | ||
:puhelin "0504363675457" | ||
:titteli-fi "energia-asiantuntija" | ||
:titteli-sv "energiexpert"}) | ||
(t/testing "Sakkopäätös / varsinainen päätös toimenpide is created successfully for yksityishenkilö and document is generated with correct information" | ||
;; Add the valvonta and previous toimenpides | ||
;; so that käskypäätös / kuulemiskirje toimenpide can be created | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
etp-core/etp-db/src/main/sql/migration/v5-release-1.1/v5.45-add-titles-to-kayttaja-table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
alter table kayttaja add column titteli_fi text default null; | ||
alter table kayttaja add column titteli_sv text default null; |
4 changes: 4 additions & 0 deletions
4
.../etp-db/src/main/sql/migration/v5-release-1.1/v5.46-add-title-to-current-paakayttajat.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
update kayttaja | ||
set titteli_fi = 'energia-asiantuntija', | ||
titteli_sv = 'energiexpert' | ||
where rooli_id = 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.