Skip to content

Commit

Permalink
Merge pull request #5 from saidone75/dev
Browse files Browse the repository at this point in the history
node-created-test
  • Loading branch information
saidone75 authored May 13, 2024
2 parents b8d6893 + 9fe7e3d commit 8864c78
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/weller/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@

(ns weller.core-test
(:require [clojure.test :refer :all]
[cral.model.alfresco.cm :as cm]
[taoensso.telemere :as t]
[weller.components.component :as component]
[weller.core :refer :all]
[weller.event-handler :as handler]
[weller.events :as events]
[weller.filters :as filters]
[weller.events :as events]))
[weller.test-utils :as tu])
(:import (java.util UUID)))

(deftest node-created-test
(def res (promise))
(def handler (handler/make-handler (filters/event? events/node-created) #(deliver res %)))
(println @res)
(def resource (promise))
(def handler (handler/make-handler (filters/event? events/node-created) #(deliver resource %)))
(let [name (.toString (UUID/randomUUID))]
(tu/create-then-delete-node name)
(is (= (:name @resource)) name))
(component/stop handler))
37 changes: 37 additions & 0 deletions test/weller/test_utils.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
; weller - Alfresco out-of-process extensions in Clojure
; Copyright (C) 2024 Saidone
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.

(ns weller.test-utils
(:require [clojure.test :refer :all]
[cral.api.auth :as auth]
[cral.api.core.nodes :as nodes]
[cral.model.alfresco.cm :as cm]
[cral.model.core :as model]
[weller.config :as config]))

(defn get-guest-home
[ticket]
(get-in (nodes/get-node ticket "-root-" (model/map->GetNodeQueryParams {:relative-path "/Guest Home"})) [:body :entry :id]))

(defn create-then-delete-node
[name]
(let [ticket (get-in (auth/create-ticket (get-in @config/config [:alfresco :user]) (get-in @config/config [:alfresco :password])) [:body :entry])
;; create a node
create-node-response (->> (model/map->CreateNodeBody {:name name :node-type cm/type-content})
(nodes/create-node ticket (get-guest-home ticket)))]
(is (= (:status create-node-response) 201))
;; delete node
(is (= (:status (nodes/delete-node ticket (get-in create-node-response [:body :entry :id]) {:permanent true})) 204))))

0 comments on commit 8864c78

Please sign in to comment.