/
catalog.clj
50 lines (43 loc) · 1.82 KB
/
catalog.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(ns onyx-java.test.single-javafn.catalog
(:import [org.onyxplatform.api.java Catalog Task]
[org.onyxplatform.api.java.utils AsyncCatalog MapFns]
[org.onyxplatform.api.java.instance BindUtils])
(:require [clojure.test :refer [deftest is]]))
(defn build-catalog []
(let [cat (Catalog.)
fqns "onyxplatform.test.PassFn"
ctr-args {}]
(-> cat
(BindUtils/addFn "pass" 5 50 fqns ctr-args)
(AsyncCatalog/addInput "in" 5 50)
(AsyncCatalog/addOutput "out" 5 50))))
(def expected [{:onyx/name :pass,
:onyx/fn :onyx-java.instance.bind/method,
:onyx/type :function,
:onyx/batch-size 5
:onyx/batch-timeout 50,
:java-instance/class "onyxplatform.test.PassFn",
:java-instance/ctr-args {},
; NOTE: java-instance/id is stripped before comparison as its generated
:onyx/params [:java-instance/id :java-instance/class :java-instance/ctr-args] }
{:onyx/name :in,
:onyx/plugin :onyx.plugin.core-async/input,
:onyx/medium :core.async,
:onyx/type :input,
:onyx/max-peers 1,
:onyx/batch-size 5
:onyx/batch-timeout 50 }
{:onyx/name :out,
:onyx/plugin :onyx.plugin.core-async/output,
:onyx/medium :core.async,
:onyx/type :output,
:onyx/max-peers 1,
:onyx/batch-size 5
:onyx/batch-timeout 50 }])
(deftest valid-catalog?
(let [cat (build-catalog)
; Strip generated IDs before comparing
tasks (map
#(dissoc % :java-instance/id)
(.tasks cat)) ]
(is (= expected tasks))))