diff --git a/src/nl/surf/eduhub_rio_mapper/cli_commands.clj b/src/nl/surf/eduhub_rio_mapper/cli_commands.clj index e6a7c361..82a4465d 100644 --- a/src/nl/surf/eduhub_rio_mapper/cli_commands.clj +++ b/src/nl/surf/eduhub_rio_mapper/cli_commands.clj @@ -76,7 +76,9 @@ "test-rio" (let [[client-info _args] (parse-client-info-args args clients) - uuid (UUID/randomUUID) + uuid (UUID/randomUUID) + new-uuid (UUID/randomUUID) + eduspec (-> "../test/fixtures/ooapi/education-specification-template.json" io/resource slurp @@ -84,16 +86,31 @@ (assoc :educationSpecificationId uuid))] (try - (insert! {:institution-oin (:institution-oin client-info) - :institution-schac-home (:institution-schac-home client-info) - ::ooapi/type "education-specification" - ::ooapi/id uuid - ::ooapi/entity eduspec}) + (let [insert-req {:institution-oin (:institution-oin client-info) + :institution-schac-home (:institution-schac-home client-info) + ::ooapi/type "education-specification" + ::ooapi/id uuid + ::ooapi/entity eduspec} + rio-code (-> insert-req insert! :aanleveren_opleidingseenheid_response :opleidingseenheidcode) + link-req (merge insert-req {::ooapi/id new-uuid ::rio/opleidingscode rio-code})] + (link! link-req) + (let [rio-obj (rio.loader/find-rio-object rio-code getter (:institution-oin client-info) "opleidingseenheid") + nieuwe-sleutel (->> rio-obj + :content + (filter #(= :kenmerken (:tag %))) + (map :content) + (map #(reduce (fn [m el] (assoc m (:tag el) (-> el :content first))) {} %)) + (filter #(= "eigenOpleidingseenheidSleutel" (:kenmerknaam %))) + first + :kenmerkwaardeTekst)] + (when (not= nieuwe-sleutel (str uuid)) + (throw (ex-info "Failed to set eigenOpleidingseenheidSleutel" {:rio-queue-status :down}))))) + (println "The RIO Queue is UP") (catch Exception ex (when-let [ex-data (ex-data ex)] (when (= :down (:rio-queue-status ex-data)) - (println "The RIO Queue is DOWN") + (println "The RIO Queue is DOWN;" (.getMessage ex)) (System/exit 255))) (println "An unexpected exception has occurred: " ex) (System/exit 254)))) diff --git a/test/nl/surf/eduhub_rio_mapper/utils/authentication_test.clj b/test/nl/surf/eduhub_rio_mapper/utils/authentication_test.clj index baa33889..683c62ea 100644 --- a/test/nl/surf/eduhub_rio_mapper/utils/authentication_test.clj +++ b/test/nl/surf/eduhub_rio_mapper/utils/authentication_test.clj @@ -83,7 +83,7 @@ "Authorized without client when no token provided") (is (= http-status/forbidden - (:status (handler {:headers {"authorization" (str "Bearer invalid-token")}}))) + (:status (handler {:headers {"authorization" "Bearer invalid-token"}}))) "Forbidden with invalid token") (is (= 2 @count-calls)