summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorC.T. Paterson <ctpaterson+onap@gmail.com>2018-09-04 14:05:24 -0400
committerC.T. Paterson <ctpaterson+onap@gmail.com>2018-09-04 14:49:55 -0400
commitd0dceef6a3504a376cc689afc119ef15a56b5f7a (patch)
tree6403bf7e70a014860e426589bdeec9fc11401607 /test
parent1586036fd345c240982237b76469a1f5d04d122d (diff)
Adding version.properties for build job, tests
Issue-ID: AAI-1547 Change-Id: I70ecf0f427eb30da8df1ec3e2a0cec383e0063fb Signed-off-by: C.T. Paterson <ctpaterson+onap@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/chameleon/testing.clj125
1 files changed, 106 insertions, 19 deletions
diff --git a/test/chameleon/testing.clj b/test/chameleon/testing.clj
index 13acb1a..35f897d 100644
--- a/test/chameleon/testing.clj
+++ b/test/chameleon/testing.clj
@@ -6,37 +6,124 @@
[chameleon.logging :as log]
[chameleon.specs :as cs]
[chameleon.route :as cr]
- [chameleon.aai-processor :as cai]))
+ [chameleon.aai-processor :as cai]
+ [chameleon.config :as cc]
+ [integrant.core :as ic]
+ [integrant.core :as ig])
+ (:import [chameleon.kafka CljKafkaConsumer]))
+;; STUBS
(s/fdef chameleon.route/assert-gallifrey!
- :args (s/cat :host :chameleon.specs/host
- :provenance :chameleon.specs/provenance
- :type :chameleon.specs/type
- :payload :chameleon.specs/payload
- :loggers :chameleon.specs/loggers)
- :ret nil?)
+ :args (s/cat :host :chameleon.specs/host
+ :provenance :chameleon.specs/provenance
+ :type :chameleon.specs/type
+ :payload :chameleon.specs/payload
+ :loggers :chameleon.specs/loggers)
+ :ret nil?)
+
+(s/fdef org.httpkit.client/request
+ :args (s/cat :host :chameleon.specs/host
+ :provenance :chameleon.specs/provenance
+ :type :chameleon.specs/type
+ :payload :chameleon.specs/payload
+ :loggers :chameleon.specs/loggers)
+ :ret (s/or :get :chameleon.specs/string
+ :create (s/spec clojure.string/blank? :gen #(gen/return ""))
+ :update :chameleon.specs/string))
+
+(s/fdef ig/ref
+ :args (binding [s/*recursion-limit* 30]
+ (s/cat :keyword (s/spec keyword? :gen-max 4)))
+ :ret any?)
+
+(s/fdef ig/load-namespaces
+ :args (binding [s/*recursion-limit* 30]
+ (s/cat :config (s/spec map? :gen-max 4)))
+ :ret map?)
+
+
+(s/fdef org.httpkit.client/request
+ :args (s/cat :request map?)
+ :ret :route/response)
+
+
+;; TESTS
+;; This requires a fix. I should return a random generated hashmap and not an empty one.
+;; If i leave it at `(s/spec map?)` it takes about 7 minutes
+;; to run the tests, so returning an empty hash-map for now.
+(s/fdef chameleon.config/config
+ :args (s/cat :config (s/spec map? :gen #(gen/return {})))
+ :ret map?)
(s/fdef chameleon.aai-processor/from-spike
- :args (s/cat :gallifrey-host :chameleon.specs/host
- :payload :spike/payload
- :loggers :chameleon.specs/loggers)
- :ret nil?)
+ :args (s/cat :gallifrey-host :chameleon.specs/host
+ :payload :spike/payload
+ :loggers :chameleon.specs/loggers)
+ :ret nil?)
(s/fdef chameleon.aai-processor/from-gallifrey
- :args (s/cat :body :gallifrey/payload)
- :ret map?)
+ :args (s/cat :body :gallifrey/payload)
+ :ret map?)
(s/fdef chameleon.aai-processor/gen-trim-relationship
- :args (s/cat :relationship :chameleon.specs/relationship)
- :ret map?)
+ :args (s/cat :relationship :chameleon.specs/relationship)
+ :ret map?)
+
+(s/fdef chameleon.kafka/clj-kafka-consumer
+ :args (s/cat :config :kafka/config :group-id :chameleon.specs/string
+ :topic :chameleon.specs/string :logger :chameleon.specs/logger)
+ :ret #(instance? CljKafkaConsumer %))
+(s/fdef chameleon.kafka/consumer-record->clojure
+ :args (s/cat :consumer-record :kafka/consumer-record)
+ :ret :kafka/clojure-consumer-record)
+
+(s/fdef chameleon.route/query
+ :args (s/cat :host :chameleon.specs/host :key :kafka/key :type :chameleon.specs/type
+ :gallifrey-params :gallifrey/payload)
+ :ret string?)
+
+(s/fdef chameleon.route/assert-create!
+ :args (s/cat :host :chameleon.specs/host :actor :chameleon.specs/string
+ :type :chameleon.specs/type :key :kafka/key
+ :payload :gallifrey/payload)
+ :ret string?)
+
+(s/fdef chameleon.route/assert-update!
+ :args (s/cat :host :chameleon.specs/host :actor :chameleon.specs/string
+ :type :chameleon.specs/type :key :kafka/key
+ :payload :gallifrey/payload)
+ :ret string?)
+
+(s/fdef chameleon.route/assert-delete!
+ :args (s/cat :host :chameleon.specs/host :actor :chameleon.specs/string
+ :type :chameleon.specs/type :key :kafka/key
+ :payload :gallifrey/payload)
+ :ret string?)
+
+
+;; INSTRUMENTS - MOCKS
(st/instrument 'chameleon.route/assert-gallifrey! {:stub '(chameleon.route/assert-gallifrey!)})
+(st/instrument 'org.httpkit.client/request {:stub '(org.httpkit.client/request)})
+(st/instrument 'ig/ref {:stub '(ig/ref)})
+(st/instrument 'ig/load-namespaces {:stub '(ig/load-namespaces)})
+
+;; TESTING INSTRUMENTATIONS
+#_(chameleon.route/assert-gallifrey! "host" "aai" "type" {}
+ (log/error-logger "chameleon.testing") (log/audit-logger "chameleon.testing"))
+#_(org.httpkit.client/request {"host" "aai"})
+#_(integrant.core/load-namespaces {:foo "bar"})
+#_(integrant.core/ref :foo)
-;; Testing instrumentation
-(chameleon.route/assert-gallifrey! "host" "aai" "type" {} (log/error-logger "chameleon.testing") (log/audit-logger "chameleon.testing"))
-(->> '(chameleon.aai-processor/from-spike
+(->> '(chameleon.config/config
+ chameleon.aai-processor/from-spike
chameleon.aai-processor/from-gallifrey
- chameleon.aai-processor/gen-trim-relationship)
+ chameleon.aai-processor/gen-trim-relationship
+ chameleon.kafka/clj-kafka-consumer
+ chameleon.kafka/consumer-record->clojure
+ chameleon.route/query
+ chameleon.route/assert-create!
+ chameleon.route/assert-update!)
st/check
st/summarize-results)