diff --git a/re/resources/re/config.dev.edn b/re/resources/re/config.dev.edn index 7b9d3a3..d6ff959 100644 --- a/re/resources/re/config.dev.edn +++ b/re/resources/re/config.dev.edn @@ -7,7 +7,8 @@ :count 1 :handler #ig/ref :re.handler/decoder} :re.handler/decoder {:classes ["events.SdkEvent$SDKEvent" - "events.SystemEventOuterClass$TimerExpired"] + "events.SystemEventOuterClass$TimerExpired" + "events.SystemEventOuterClass$Timer"] :next #ig/ref :re/crm} :re/crm {:oam #ig/ref :re/oam :entities #ig/ref :re.boundary/entities @@ -29,7 +30,9 @@ :topic "dev"} :re/kafka-producer {:configs {"bootstrap.servers" ["kafka:9092"]}} - :re/encoder {:classes ["events.SdkEvent$SDKEvent"]} + :re/encoder {:classes ["events.SdkEvent$SDKEvent" + "events.SystemEventOuterClass$TimerExpired" + "events.SystemEventOuterClass$Timer"]} :re/db {:contact-points ["scylladb"] :keyspace "re_dev"} diff --git a/re/test/re/handler/decoder_test.clj b/re/test/re/handler/decoder_test.clj index d08a6d6..c13be37 100644 --- a/re/test/re/handler/decoder_test.clj +++ b/re/test/re/handler/decoder_test.clj @@ -3,7 +3,9 @@ [integrant.core :as ig] [re.test-utils :refer [with-system]] [proto-edn.core :as proto]) - (:import events.SdkEvent$SDKEvent)) + (:import events.SdkEvent$SDKEvent + events.SystemEventOuterClass$TimerExpired + events.SystemEventOuterClass$Timer)) (defmethod ig/init-key ::db [_ _] (promise)) @@ -13,7 +15,9 @@ (deliver db message))) (def config - {:re.handler/decoder {:classes ["events.SdkEvent$SDKEvent"] + {:re.handler/decoder {:classes ["events.SdkEvent$SDKEvent" + "events.SystemEventOuterClass$TimerExpired" + "events.SystemEventOuterClass$Timer"] :next (ig/ref ::next)} ::next {:db (ig/ref ::db)} ::db {}}) @@ -27,3 +31,27 @@ (.toByteArray))] ((:re.handler/decoder system) {:value bytes}) (is (= @(::db system) {:value event}))))) + +(deftest timer-expired + (with-system [system config] + (let [event {"header" {"type" "events.TimerExpired" "createdAt" 0 "source" "test"} + "correlationId" "0" + "universe" "0"} + bytes (-> event + (proto/merge-and-build (SystemEventOuterClass$TimerExpired/newBuilder)) + (.toByteArray))] + ((:re.handler/decoder system) {:value bytes}) + (is (= @(::db system) {:value event}))))) + +(deftest timer + (with-system [system config] + (let [event {"header" {"type" "events.Timer" "createdAt" 0 "source" "test"} + "correlationId" "0" + "expireAt" 0} + bytes (-> event + (proto/merge-and-build (SystemEventOuterClass$Timer/newBuilder)) + (.toByteArray))] + ((:re.handler/decoder system) {:value bytes}) + (is (= @(::db system) {:value event}))))) + +