Skip to content

Commit

Permalink
property-added-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Marini committed May 16, 2024
1 parent 88ae5e8 commit 0fbb492
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
[com.stuartsierra/component "1.1.0"]
[org.apache.activemq/activemq-broker "6.1.1"]
[org.clojure/data.json "2.5.0"]
[org.saidone/cral "0.3.1"]
[org.saidone/cral "0.3.2-SNAPSHOT"]
[com.taoensso/telemere "1.0.0-beta9"]
[russellwhitaker/immuconf "0.3.0"]
[org.clojure/core.async "1.6.681"]]
Expand Down
12 changes: 9 additions & 3 deletions src/weller/filters.clj
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,16 @@
(partial #(= (get-in % [:data :resource :node-type]) (name type))))

(defn property-added?
;; TODO
"Checks if an event corresponds to the addition of a node property in the repository."
[]
)
[prop]
(partial #(let [properties (get-in % [:data :resource :properties])
properties-before (get-in % [:data :resource-before :properties])]
(if-not (or (nil? properties) (nil? properties-before))
(and
(or (not (contains? properties-before prop))
(nil? (get prop properties-before)))
(contains? properties prop))
false))))

(defn property-changed?
;; TODO
Expand Down
10 changes: 9 additions & 1 deletion test/weller/filters_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
; along with this program. If not, see <http://www.gnu.org/licenses/>.

(ns weller.filters-test
(:require [clojure.test :refer :all]
(:require [clojure.string :as str]
[clojure.test :refer :all]
[cral.model.alfresco.cm :as cm]
[weller.components.component :as component]
[weller.event-handler :as handler]
Expand Down Expand Up @@ -110,4 +111,11 @@
handler (handler/make-handler (filters/node-type? cm/type-savedquery) #(deliver result %))]
(tu/change-type cm/type-savedquery)
(is (= (:node-type @result) (name cm/type-savedquery)))
(component/stop handler)))

(deftest property-added-test
(let [result (promise)
handler (handler/make-handler (filters/property-added? cm/prop-publisher) #(deliver result %))]
(tu/add-property (name cm/prop-publisher) "saidone")
(is (contains? (:properties @result) cm/prop-publisher))
(component/stop handler)))
7 changes: 7 additions & 0 deletions test/weller/test_utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@
(nodes/update-node (:ticket @c/config) created-node-id))
(delete-node created-node-id)))

(defn add-property
[prop value]
(let [created-node-id (create-node)]
(->> (model/map->UpdateNodeBody {:properties {prop value}})
(nodes/update-node (:ticket @c/config) created-node-id))
(delete-node created-node-id)))

(defn create-then-delete-child-assoc
[]
(let [parent-node-id (create-folder)
Expand Down

0 comments on commit 0fbb492

Please sign in to comment.