diff --git a/project.clj b/project.clj index d5f937f..f823d36 100644 --- a/project.clj +++ b/project.clj @@ -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"]] diff --git a/src/weller/filters.clj b/src/weller/filters.clj index 4cd177f..b5e4f4b 100644 --- a/src/weller/filters.clj +++ b/src/weller/filters.clj @@ -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 diff --git a/test/weller/filters_test.clj b/test/weller/filters_test.clj index 8689e66..8bd619f 100644 --- a/test/weller/filters_test.clj +++ b/test/weller/filters_test.clj @@ -15,7 +15,8 @@ ; along with this program. If not, see . (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] @@ -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))) \ No newline at end of file diff --git a/test/weller/test_utils.clj b/test/weller/test_utils.clj index fa635e6..777ebdd 100644 --- a/test/weller/test_utils.clj +++ b/test/weller/test_utils.clj @@ -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)