Skip to content

Commit

Permalink
Merge pull request #13 from saidone75/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
saidone75 authored May 15, 2024
2 parents 40d2a0d + 8d4683e commit 229bf67
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 8 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ Weller is like Alfresco out-of-process extensions but 100% Clojure.
- 100% test coverage

## Usage

COMING SOON
### Create and compose filters
Filters can be composed of a single predicate:
```clojure
(filters/event? events/node-updated)
```
or a composition of predicates with `every-pred` (logical AND) or `some-fn` (logical OR):
```clojure
(every-pred (filters/event? events/node-updated) (filters/is-file?))
(some-fn (filters/node-aspect? cm/asp-titled) (filters/node-aspect? cm/asp-dublincore))
(some-fn (filters/node-aspect? cm/asp-titled) (filters/node-aspect? cm/asp-dublincore))
(every-pred (filters/event? events/node-updated) (some-fn (filters/node-aspect? cm/asp-titled) (filters/node-aspect? cm/asp-dublincore)))
```

## License
Copyright (c) 2024 Saidone
Expand Down
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.0"]
[org.saidone/cral "0.3.1"]
[com.taoensso/telemere "1.0.0-beta9"]
[russellwhitaker/immuconf "0.3.0"]
[org.clojure/core.async "1.6.681"]]
Expand Down
3 changes: 2 additions & 1 deletion test/weller/filters_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
[cral.model.alfresco.cm :as cm]
[weller.components.component :as component]
[weller.event-handler :as handler]
[weller.events :as events]
[weller.filters :as filters]
[weller.fixtures :as fixtures]
[weller.test-utils :as tu])
Expand All @@ -28,7 +29,7 @@

(deftest aspect-added-test
(let [resource (promise)
handler (handler/make-handler (filters/aspect-added? cm/asp-versionable) #(deliver resource %))]
handler (handler/make-handler (every-pred (filters/event? events/node-updated) (filters/aspect-added? cm/asp-versionable)) #(deliver resource %))]
(tu/add-aspect cm/asp-versionable)
(is (.contains ^PersistentVector (:aspect-names @resource) (name cm/asp-versionable)))
(component/stop handler)))
52 changes: 52 additions & 0 deletions test/weller/handler_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
; Weller is like Alfresco out-of-process extensions but 100% 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.handler-test
(:require [clojure.test :refer :all]
[cral.api.core.nodes :as nodes]
[taoensso.telemere :as t]
[weller.components.component :as component]
[weller.config :as c]
[weller.event-handler :as handler]
[weller.events :as events]
[weller.filters :as filters]
[weller.fixtures :as fixtures]
[weller.test-utils :as tu]))

(use-fixtures :once fixtures/ticket)

(def node-name "test node name")

(defn- get-node-name
[resource]
(get-in (nodes/get-node (:ticket @c/config) (:id resource)) [:body :entry :name]))

(deftest make-handler-test
(let [result (promise)
handler (handler/make-handler)
handler (handler/add-filtered-tap handler (filters/event? events/node-created) #(deliver result (get-node-name %)))]
(component/start handler)
(tu/create-then-update-then-delete-node node-name)
(t/log! @result)
(component/stop handler)))

(deftest simple-make-handler-test
(let [result (promise)
;; note that handler is started automatically with this constructor
handler (handler/make-handler (filters/event? events/node-created) #(deliver result (get-node-name %)))]
(tu/create-then-update-then-delete-node node-name)
(t/log! @result)
(component/stop handler)))
10 changes: 6 additions & 4 deletions test/weller/test_utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@
(nodes/delete-node (:ticket @c/config) node-id {:permanent true}))

(defn create-then-update-then-delete-node
[name]
(->> (create-node name)
(update-node)
(delete-node)))
([]
(create-then-update-then-delete-node (.toString (UUID/randomUUID))))
([name]
(->> (create-node name)
(update-node)
(delete-node))))

(defn create-then-delete-child-assoc
[]
Expand Down

0 comments on commit 229bf67

Please sign in to comment.