Repository: FundingCircle/jackdaw
Pull request #14 (2018-12-12 01:17:26)

Clean up `jackdaw.serdes` API
This removes the `jackdaw.serdes` namespace and cleans up the underlying serdes. The constructor was not really doing much for us and belonged in the app. This also renames top level functions in the `jackdaw.serdes.avro` and `jackdaw.serdes.json` namespaces to match `jackdaw.serdes.edn` and deletes some lesser used serdes.

To create serdes, the usage is now:
```
(jackdaw.serdes.edn/serde)
(jackdaw.serdes.json/serde)
(jackdaw.serdes.avro/serde <ARGS>)
```


Patch:
diff --git a/.circleci/config.yml b/.circleci/config.yml
index b04f346..717eeff 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -29,54 +29,9 @@ jobs:
       - run:
           command: lein test
 
-  deploy-staging:
-    docker:
-      - image: circleci/clojure:latest
-    environment:
-      GIT_AUTHOR_NAME: CircleCI
-      GIT_AUTHOR_EMAIL: circleci@circleci.com
-
-    steps:
-      - checkout
-      - *restore-cache
-      - run:
-          command: git config --global user.name $GIT_AUTHOR_NAME
-      - run:
-          command: git config --global user.email $GIT_AUTHOR_EMAIL
-      - run:
-          command: lein deploy snapshots
-  deploy-release:
-    docker:
-      - image: circleci/clojure:latest
-    environment:
-      GIT_AUTHOR_NAME: CircleCI
-      GIT_AUTHOR_EMAIL: circleci@circleci.com
-
-    steps:
-      - checkout
-      - *restore-cache
-      - run:
-          command: git config --global user.name $GIT_AUTHOR_NAME
-      - run:
-          command: git config --global user.email $GIT_AUTHOR_EMAIL
-      - run:
-          command: lein deploy
-
 workflows:
   version: 2
   build_and_deploy:
     jobs:
       - build:
           context: org-global
-      - deploy-staging:
-          requires:
-            - build
-          filters:
-            branches:
-              ignore: master
-      - deploy-release:
-          requires:
-            - build
-          filters:
-            branches:
-              only: master
diff --git a/dev/user.clj b/dev/user.clj
deleted file mode 100644
index 6c00e5e..0000000
--- a/dev/user.clj
+++ /dev/null
@@ -1,26 +0,0 @@
-(ns user
-  (:require [jackdaw.client :as jc]
-            [jackdaw.serdes :as js]
-            [jackdaw.admin :as ja]
-            [jackdaw.serdes.avro :as js.a]))
-
-(def +local-schema-registry+
-  {:avro.schema-registry/url "http://localhost:8081"})
-
-(def +local-kafka+
-  "A Kafka consumer or streams config."
-  (let [id (str "dev-" (java.util.UUID/randomUUID))]
-    {"replication.factor" "1", "group.id" id, "application.id" id,
-     "bootstrap.servers"  "localhost:9092"
-     "zookeeper.connect"  "localhost:2181"
-     "request.timeout.ms" "1000"}))
-
-(def +local-zookeeper+
-  +local-kafka+)
-
-(def +avro-type-registry+
-  (merge js.a/+base-schema-type-registry+
-         js.a/+UUID-type-registry+))
-
-(def +admin-client+
-  (ja/->AdminClient +local-kafka+))
diff --git a/project.clj b/project.clj
index a39ab5b..887ae30 100644
--- a/project.clj
+++ b/project.clj
@@ -2,7 +2,6 @@
   :description "A Clojure library for the Apache Kafka distributed streaming platform."
 
   :dependencies [[clj-time "0.13.0"]
-                 [com.taoensso/nippy "2.12.2"]
                  [danlentz/clj-uuid "0.1.7"]
                  [environ "1.1.0"]
                  ;; Confluent does paired releases with Kafka, this should tie
diff --git a/src/jackdaw/admin.clj b/src/jackdaw/admin.clj
index ee6aa49..0d29377 100644
--- a/src/jackdaw/admin.clj
+++ b/src/jackdaw/admin.clj
@@ -102,7 +102,7 @@
   {:pre [(client? client)
           (sequential? topics)]}
   (-> client
-      (.describeConfigs (map #(-> % :topic-name jd/->topic-resource) topics))
+      (.describeConfigs (map #(-> % :topic-name jd/->topic-resource)))
       .all deref vals first jd/datafy))
 
 (defn topics-ready?
diff --git a/src/jackdaw/serdes.clj b/src/jackdaw/serdes.clj
deleted file mode 100644
index 3f17041..0000000
--- a/src/jackdaw/serdes.clj
+++ /dev/null
@@ -1,120 +0,0 @@
-(ns jackdaw.serdes
-  "Some useful serdes."
-  {:license "BSD 3-Clause License <https://github.com/FundingCircle/jackdaw/blob/master/LICENSE>"}
-  (:refer-clojure :exclude [resolve])
-  (:require [jackdaw.serdes.edn.nippy :as j.s.edn.nippy]
-            [jackdaw.serdes.json :as json]
-            [jackdaw.serdes.uuid :as uuid])
-  (:import org.apache.kafka.common.serialization.Serdes))
-
-(def
-  ^{:const true
-    :doc "A registry of keys to functions of a topic config to a SerDe instance.
-
-  This registry is deliberately somewhat incomplete, as users are intended to
-  call `#'resolve` or `#'serde` as appropriate with their own mappings.
-
-  This mapping is not intended to be exhaustive, merely introductory and useful."}
-  +default-serdes+
-
-  {::edn         (fn [_] (j.s.edn.nippy/serde))
-   ::json        (fn [_] (json/json-serde))
-   ::uuid        (fn [_] (uuid/uuid-serde))
-   ::byte-array  (fn [_] (Serdes/ByteArray))
-   ::byte-buffer (fn [_] (Serdes/ByteBuffer))
-   ::double      (fn [_] (Serdes/Double))
-   ::integer     (fn [_] (Serdes/Integer))
-   ::long        (fn [_] (Serdes/Long))
-   ::string      (fn [_] (Serdes/String))})
-
-(defn serde
-  "Accepts an optional serde ctor `mapping`, a topic configuration
-  specifying a serde or a keyword naming a serde, and an optional
-  `default-ctor` serde constructor.
-
-  Looks a serde constructor up out of the mapping and applies the
-  constructor to the given topic configuration (or keyword), returning
-  its result - presumably a serde.
-
-  If no mapping is provided, `#'+default-serdes+` is used.
-
-  If no serde constructor is found in the active mapping, the
-  `default-ctor` is invoked.
-
-  If no `default-ctor` is provided, a function which simply throws
-  `ex-info` indicating a failure to resolve a serde is used."
-
-  ([topic-or-kw]
-   (serde +default-serdes+
-          topic-or-kw))
-
-  ([mapping topic-or-kw]
-   (serde mapping
-          topic-or-kw
-          (fn [t]
-            (throw (ex-info "Unable to resolve serde for topic"
-                            {:topic topic-or-kw})))))
-
-  ([mapping topic-or-kw default-ctor]
-   (let [key (or (::type topic-or-kw)
-                 topic-or-kw)]
-     (when-not (keyword? key)
-       (throw (ex-info "Failed to find a legal mapping `key` for `topic-or-kw`"
-                       {:topic-or-kw topic-or-kw
-                        :key key})))
-     (-> (get mapping key default-ctor)
-         ;; Could also be (apply <> topic-or-kw nil)
-         (.invoke topic-or-kw)))))
-
-(defn resolve
-  "Loads the key and value serdes for a topic spec, returning an extended topic spec.
-
-  By default, serdes are resolved from `#'+default-serdes+`. The
-  registry is deliberately read-only. Users wanting to override the
-  default registry serdes, or to otherwise bring their own serdes
-  should simply use the 2-arity and provide a serde ctor registry
-  suiting their needs.
-
-  This is done so that no global coherence property is required on
-  serde instances, as it's impossible to enforce such a contract.
-
-  `topic-config` structs are expected to have
-  `:jackdaw.topic/key-serde` and `:jackdaw.topic/value-serde`, both of
-  which should be keywords present in the provided (or default) serde
-  registry mappings.
-
-  In order to support Avro serdes, which are parameterized on the
-  concrete schema to use, `:jackdaw.topic/value-schema` and
-  `:jackdaw.topics/key-schema` may be provided."
-
-  ([topic-config]
-   (resolve +default-serdes+ topic-config))
-  ([registry topic-config]
-   (let [{:keys [jackdaw.topic/key-serde
-                 jackdaw.topic/value-serde]} topic-config]
-
-     (if-not key-serde
-       (throw
-        (IllegalArgumentException.
-         ":jackdaw.topic/key-serde is required in the topic config.")))
-
-     (if-not value-serde
-       (throw
-        (IllegalArgumentException.
-         ":jackdaw.topic/value-serde is required in the topic config.")))
-
-     (assoc topic-config
-            ;; FIXME (reid.mckenzie 2018-09-24):
-            ;;
-            ;;   Passing the desired serde through with `::type` and implicitly
-            ;;   parameterizing the ctor on the thus altered topic config is
-            ;;   fairly janky. There's probably a better way to generally
-            ;;   parameterize serdes, but leaving this as is for now.
-            ::key-serde
-            (serde registry
-                   (assoc topic-config
-                          ::type key-serde))
-            ::value-serde
-            (serde registry
-                   (assoc topic-config
-                          ::type value-serde))))))
diff --git a/src/jackdaw/serdes/avro.clj b/src/jackdaw/serdes/avro.clj
index e49dae0..a6bcb24 100644
--- a/src/jackdaw/serdes/avro.clj
+++ b/src/jackdaw/serdes/avro.clj
@@ -484,7 +484,7 @@
 (defn- base-config [registry-url]
   {"schema.registry.url" registry-url})
 
-(defn- avro-serializer [schema->coercion serde-config]
+(defn- serializer [schema->coercion serde-config]
   (let [{:keys [registry-client registry-url avro-schema key?]} serde-config
         base-serializer (KafkaAvroSerializer. registry-client)
         ;; This is invariant across subject schema changes, shockingly.
@@ -505,7 +505,7 @@
     (.configure clj-serializer (base-config registry-url) key?)
     clj-serializer))
 
-(defn- avro-deserializer [schema->coercion serde-config]
+(defn- deserializer [schema->coercion serde-config]
   (let [{:keys [registry-client registry-url avro-schema key?]} serde-config
         base-deserializer (KafkaAvroDeserializer. registry-client)
         methods {:close       (fn [_]
@@ -580,7 +580,7 @@
    {:type "string" :logical-type "uuid"}
    (fn [_ _] (StringUUIDType.))})
 
-(defn avro-serde
+(defn serde
   "Given a type and logical type registry, a schema registry config with
   either a client or a URL and an Avro topic descriptor, build and
   return a Serde instance."
@@ -629,6 +629,6 @@
                              (get @coercion-cache %))
 
         ;; The final serdes based on the (cached) coercion stack.
-        serializer (avro-serializer schema->coercion config)
-        deserializer (avro-deserializer schema->coercion config)]
-    (Serdes/serdeFrom serializer deserializer)))
+        avro-serializer (serializer schema->coercion config)
+        avro-deserializer (deserializer schema->coercion config)]
+    (Serdes/serdeFrom avro-serializer avro-deserializer)))
diff --git a/src/jackdaw/serdes/edn.clj b/src/jackdaw/serdes/edn.clj
index 62c0d98..d62989a 100644
--- a/src/jackdaw/serdes/edn.clj
+++ b/src/jackdaw/serdes/edn.clj
@@ -1,15 +1,15 @@
 (ns jackdaw.serdes.edn
-  "FIXME"
+  "Implements an EDN SerDes (Serializer/Deserializer)."
   {:license "BSD 3-Clause License <https://github.com/FundingCircle/jackdaw/blob/master/LICENSE>"}
   (:require [clojure.edn]
-            [jackdaw.serdes.fn :as j.s.fn])
+            [jackdaw.serdes.fn :as jsfn])
   (:import java.nio.charset.StandardCharsets
            org.apache.kafka.common.serialization.Serdes))
 
 (set! *warn-on-reflection* true)
 
 (defn to-bytes
-  "Convert a string to byte array."
+  "Converts a string to a byte array."
   [data]
   (.getBytes ^String data StandardCharsets/UTF_8))
 
@@ -21,18 +21,18 @@
 (defn serializer
   "Returns an EDN serializer."
   []
-  (j.s.fn/new-serializer {:serialize (fn [_ _ data]
-                                       (when data
-                                         (to-bytes (prn-str data))))}))
+  (jsfn/new-serializer {:serialize (fn [_ _ data]
+                                     (when data
+                                       (to-bytes (prn-str data))))}))
 
 (defn deserializer
   "Returns an EDN deserializer."
   []
-  (j.s.fn/new-deserializer {:deserialize (fn [_ _ data]
-                                           (-> (from-bytes data)
-                                               clojure.edn/read-string))}))
+  (jsfn/new-deserializer {:deserialize (fn [_ _ data]
+                                         (-> (from-bytes data)
+                                             clojure.edn/read-string))}))
 
 (defn serde
-  "Returns EDN serde."
+  "Returns an EDN serde."
   []
   (Serdes/serdeFrom (serializer) (deserializer)))
diff --git a/src/jackdaw/serdes/edn/nippy.clj b/src/jackdaw/serdes/edn/nippy.clj
deleted file mode 100644
index c08a7fd..0000000
--- a/src/jackdaw/serdes/edn/nippy.clj
+++ /dev/null
@@ -1,25 +0,0 @@
-(ns jackdaw.serdes.edn.nippy
-  "FIXME"
-  {:license "BSD 3-Clause License <https://github.com/FundingCircle/jackdaw/blob/master/LICENSE>"}
-  (:require [jackdaw.serdes.fn :as j.s.fn]
-            [taoensso.nippy :as nippy])
-  (:import org.apache.kafka.common.serialization.Serdes))
-
-(defn serializer
-  "Returns an EDN-nippy serializer."
-  []
-  (j.s.fn/new-serializer {:serialize (fn [_ _ data]
-                                       (when data
-                                         (nippy/freeze data)))}))
-
-(defn deserializer
-  "Returns an EDN-nippy deserializer."
-  []
-  (j.s.fn/new-deserializer {:deserialize (fn [_ _ data]
-                                           (when data
-                                             (nippy/thaw data)))}))
-
-(defn serde
-  "Returns an EDN-nippy serde"
-  []
-  (Serdes/serdeFrom (serializer) (deserializer)))
diff --git a/src/jackdaw/serdes/json.clj b/src/jackdaw/serdes/json.clj
index cee5d58..2d2a238 100644
--- a/src/jackdaw/serdes/json.clj
+++ b/src/jackdaw/serdes/json.clj
@@ -1,43 +1,39 @@
 (ns jackdaw.serdes.json
-  "Implements JSON serializer, deserializer, and SerDe."
+  "Implements a JSON SerDes (Serializer/Deserializer)."
   {:license "BSD 3-Clause License <https://github.com/FundingCircle/jackdaw/blob/master/LICENSE>"}
   (:require [clojure.data.json :as json]
-            [clojure.java.io :as io]
-            [jackdaw.serdes.fn :as sfn])
+            [jackdaw.serdes.fn :as jsfn])
   (:import java.nio.charset.StandardCharsets
-           [org.apache.kafka.common.serialization Deserializer Serdes Serializer]))
+           org.apache.kafka.common.serialization.Serdes))
 
 (set! *warn-on-reflection* true)
 
-(defn bytes-to-string
-  "Convert a byte array to string."
-  [^bytes data]
-  (String. data StandardCharsets/UTF_8))
-
-(defn string-to-bytes
-  "Convert a string to byte array."
+(defn to-bytes
+  "Converts a string to a byte array."
   [data]
   (.getBytes ^String data StandardCharsets/UTF_8))
 
-(defn json-serializer
-  "Create a JSON serializer"
+(defn from-bytes
+  "Converts a byte array to a string."
+  [^bytes data]
+  (String. data StandardCharsets/UTF_8))
+
+(defn serializer
+  "Returns a JSON serializer."
   []
-  (sfn/new-serializer {:serialize (fn [_ _ data]
-                                    (when data
-                                      (-> data
-                                          json/write-str
-                                          string-to-bytes)))}))
+  (jsfn/new-serializer {:serialize (fn [_ _ data]
+                                     (when data
+                                       (to-bytes (json/write-str data))))}))
 
-(defn json-deserializer
-  "Create a JSON deserializer"
+(defn deserializer
+  "Returns a JSON deserializer."
   []
-  (sfn/new-deserializer {:deserialize (fn [_ _ data]
-                                        (when data
-                                          (-> data
-                                              bytes-to-string
-                                              (json/read-str :key-fn keyword))))}))
+  (jsfn/new-deserializer {:deserialize (fn [_ _ data]
+                                         (when data
+                                           (-> (from-bytes data)
+                                               (json/read-str :key-fn keyword))))}))
 
-(defn json-serde
-  "Create a JSON serde."
+(defn serde
+  "Returns a JSON serde."
   []
-  (Serdes/serdeFrom (json-serializer) (json-deserializer)))
+  (Serdes/serdeFrom (serializer) (deserializer)))
diff --git a/src/jackdaw/serdes/uuid.clj b/src/jackdaw/serdes/uuid.clj
deleted file mode 100644
index 825eb05..0000000
--- a/src/jackdaw/serdes/uuid.clj
+++ /dev/null
@@ -1,29 +0,0 @@
-(ns jackdaw.serdes.uuid
-  "Implements UUID serializer, deserializer, and SerDe."
-  {:license "BSD 3-Clause License <https://github.com/FundingCircle/jackdaw/blob/master/LICENSE>"}
-  (:require [clj-uuid :as uuid]
-            [jackdaw.serdes.fn :as sfn])
-  (:import java.nio.ByteBuffer
-           java.util.UUID
-           [org.apache.kafka.common.serialization Deserializer Serdes Serializer]))
-
-
-(defn uuid-serializer
-  "Create a UUID serializer."
-  []
-  (sfn/new-serializer {:serialize (fn [_ _ data]
-                                    (when data
-                                      (uuid/to-byte-array data)))}))
-
-(defn uuid-deserializer
-  "Create a UUID deserializer."
-  []
-  (sfn/new-deserializer {:deserialize (fn [_ _ data]
-                                        (when data
-                                          (let [bb (ByteBuffer/wrap data)]
-                                            (UUID. (.getLong bb) (.getLong bb)))))}))
-
-(defn uuid-serde
-  "Create a UUID serde"
-  []
-  (Serdes/serdeFrom (uuid-serializer) (uuid-deserializer)))


Test patch:
diff --git a/test/jackdaw/serdes/avro/integration_tests.clj b/test/jackdaw/serdes/avro/integration_test.clj
similarity index 90%
rename from test/jackdaw/serdes/avro/integration_tests.clj
rename to test/jackdaw/serdes/avro/integration_test.clj
index 611e97e..a2a341c 100644
--- a/test/jackdaw/serdes/avro/integration_tests.clj
+++ b/test/jackdaw/serdes/avro/integration_test.clj
@@ -1,4 +1,4 @@
-(ns jackdaw.serdes.avro.integration-tests
+(ns jackdaw.serdes.avro.integration-test
   (:require [clj-uuid :as uuid]
             [clojure.core.cache :as cache]
             [clojure.data.json :as json]
@@ -7,12 +7,11 @@
             [jackdaw.client :as jc]
             [jackdaw.client.log :as jcl]
             [jackdaw.data :as jd]
-            [jackdaw.serdes :as js]
             [jackdaw.serdes.avro :as avro]
             [jackdaw.serdes.avro.schema-registry :as reg])
   (:import [org.apache.avro Schema$Parser]
            [org.apache.avro.generic GenericData$Record]
-           [org.apache.kafka.common.serialization Serde]))
+           [org.apache.kafka.common.serialization Serde Serdes]))
 
 (def +type-registry+
   (merge avro/+base-schema-type-registry+
@@ -33,7 +32,7 @@
 
 (deftest mock-schema-registry
   (testing "schema can be serialized by registry client"
-    (let [serde ^Serde (avro/avro-serde +type-registry+ +mock-schema-registry+ +topic-config+)]
+    (let [serde ^Serde (avro/serde +type-registry+ +mock-schema-registry+ +topic-config+)]
       (let [msg {:customer-id (uuid/v4)
                  :address     {:value    "foo"
                                :key-path "foo.bar.baz"}}]
@@ -45,7 +44,7 @@
 
 (deftest ^:integration real-schema-registry
   (testing "schema registry set in config"
-    (let [serde ^Serde (avro/avro-serde +type-registry+ +real-schema-registry+ +topic-config+)]
+    (let [serde ^Serde (avro/serde +type-registry+ +real-schema-registry+ +topic-config+)]
       (let [msg {:customer-id (uuid/v4)
                  :address     {:value    "foo"
                                :key-path "foo.bar.baz"}}]
@@ -74,7 +73,7 @@
 ;;;; "versioned" topic configs
 
 (def serde*
-  (partial avro/avro-serde +type-registry+ +real-schema-registry+))
+  (partial avro/serde +type-registry+ +real-schema-registry+))
 
 (deftest ^:integration schema-evolution-test
   (testing "serialize then deserialize several serde versions"
@@ -86,7 +85,7 @@
            (str "test-topic-" (uuid/v4))
 
            :key-serde
-           (js/serde ::js/string)
+           (Serdes/String)
 
            :value-serde
            (serde*
diff --git a/test/jackdaw/serdes/avro_test.clj b/test/jackdaw/serdes/avro_test.clj
index 5d5b3f3..e9f8e45 100644
--- a/test/jackdaw/serdes/avro_test.clj
+++ b/test/jackdaw/serdes/avro_test.clj
@@ -39,7 +39,7 @@
         serde-config
         {:avro/schema schema-str
          :key?        false}]
-    (avro/avro-serde +registry+ schema-registry-config serde-config)))
+    (avro/serde +registry+ schema-registry-config serde-config)))
 
 (defn deserialize [serde topic x]
   (let [deserializer (.deserializer serde)]
diff --git a/test/jackdaw/serdes/edn/nippy_test.clj b/test/jackdaw/serdes/edn/nippy_test.clj
deleted file mode 100644
index 0b8b302..0000000
--- a/test/jackdaw/serdes/edn/nippy_test.clj
+++ /dev/null
@@ -1,20 +0,0 @@
-(ns jackdaw.serdes.edn.nippy-test
-  (:require [clojure.test :refer :all]
-            [jackdaw.serdes.edn.nippy :as j.s.edn.nippy]
-            [taoensso.nippy :as nippy]))
-
-(deftest edn-nippy-roundtrip-test
-  (testing "EDN data is the same after serialization and deserialization."
-    (is (= nippy/stress-data-comparable
-           (->> nippy/stress-data-comparable
-                (.serialize (j.s.edn.nippy/serializer) nil)
-                (.deserialize (j.s.edn.nippy/deserializer) nil))))))
-
-(deftest edn-nippy-reverse-roundtrip-test
-  (testing "EDN data is the same after deserialization and serialization."
-    (let [bytes (.serialize (j.s.edn.nippy/serializer)
-                            nil
-                            nippy/stress-data-comparable)]
-      (is (= (seq bytes)
-             (seq (->> (.deserialize (j.s.edn.nippy/deserializer) nil bytes)
-                       (.serialize (j.s.edn.nippy/serializer) nil))))))))
diff --git a/test/jackdaw/serdes/edn_test.clj b/test/jackdaw/serdes/edn_test.clj
index 13202e1..f2cbf1b 100644
--- a/test/jackdaw/serdes/edn_test.clj
+++ b/test/jackdaw/serdes/edn_test.clj
@@ -3,18 +3,18 @@
             [clojure.test.check.clojure-test :refer [defspec]]
             [clojure.test.check.generators :as gen]
             [clojure.test.check.properties :as prop]
-            [jackdaw.serdes.edn :as j.s.edn]))
+            [jackdaw.serdes.edn :as jse]))
 
 (defspec edn-roundtrip-test 20
   (testing "EDN data is the same after serialization and deserialization."
     (prop/for-all [x gen/any-printable]
-      (is (= x (->> (.serialize (j.s.edn/serializer) nil x)
-                    (.deserialize (j.s.edn/deserializer) nil)))))))
+      (is (= x (->> (.serialize (jse/serializer) nil x)
+                    (.deserialize (jse/deserializer) nil)))))))
 
 (defspec edn-reverse-roundtrip-test 20
   (testing "EDN data is the same after deserialization and serialization."
     (prop/for-all [x gen/any-printable]
-      (let [bytes (.serialize (j.s.edn/serializer) nil x)]
+      (let [bytes (.serialize (jse/serializer) nil x)]
         (is (= (seq bytes)
-               (seq (->> (.deserialize (j.s.edn/deserializer) nil bytes)
-                         (.serialize (j.s.edn/serializer) nil)))))))))
+               (seq (->> (.deserialize (jse/deserializer) nil bytes)
+                         (.serialize (jse/serializer) nil)))))))))
diff --git a/test/jackdaw/serdes/json_test.clj b/test/jackdaw/serdes/json_test.clj
index 1ea5685..9711cf9 100644
--- a/test/jackdaw/serdes/json_test.clj
+++ b/test/jackdaw/serdes/json_test.clj
@@ -5,16 +5,13 @@
             [clojure.test.check.clojure-test :as ct :refer [defspec]]
             [clojure.test.check.generators :as gen]
             [clojure.test.check.properties :as prop]
-            [jackdaw.serdes.json :refer :all]))
+            [jackdaw.serdes.json :as jsj]))
 
 (def string-bytes-roundtrip-property
   "A strings `s' should be the same after writing to a byte array and reading
   back as a string."
   (prop/for-all [s gen/string]
-                (= s
-                   (-> s
-                       string-to-bytes
-                       bytes-to-string))))
+                (= s (jsj/from-bytes (jsj/to-bytes s)))))
 
 (defspec string-roundtrip-test 100 string-bytes-roundtrip-property)
 
@@ -22,13 +19,13 @@
   (testing "JSON string is the same after serialization and deserialization."
     (let [s (slurp (io/resource "resources/pass1.json"))]
       (is (= (json/read-str s)
-             (json/read-str (->> (.serialize (json-serializer) nil s)
-                                 (.deserialize (json-deserializer) nil))))))))
+             (json/read-str (->> (.serialize (jsj/serializer) nil s)
+                                 (.deserialize (jsj/deserializer) nil))))))))
 
 (deftest reverse-json-roundtrip-test
   (testing "JSON bytes are the same after deserialization and serialization."
     (let [s (slurp (io/resource "resources/pass1.json"))
-          b (.serialize (json-serializer) nil {:foo_bar "baz"})]
+          b (.serialize (jsj/serializer) nil {:foo_bar "baz"})]
       (is (= (into [] b)
-             (into [] (->> (.deserialize (json-deserializer) nil b)
-                           (.serialize (json-serializer) nil))))))))
+             (into [] (->> (.deserialize (jsj/deserializer) nil b)
+                           (.serialize (jsj/serializer) nil))))))))
diff --git a/test/jackdaw/serdes/uuid_test.clj b/test/jackdaw/serdes/uuid_test.clj
deleted file mode 100644
index 7505222..0000000
--- a/test/jackdaw/serdes/uuid_test.clj
+++ /dev/null
@@ -1,27 +0,0 @@
-(ns jackdaw.serdes.uuid-test
-  (:require [clojure.test :refer :all]
-            [clojure.test.check.clojure-test :as ct :refer [defspec]]
-            [clojure.test.check.generators :as gen]
-            [clojure.test.check.properties :as prop]
-            [jackdaw.serdes.uuid :refer :all]))
-
-(def uuid-bytes-roundtrip-property
-  "A UUID should be the same after serialization and deserialization."
-  (prop/for-all [u gen/uuid]
-                (= u
-                   (->> u
-                        (.serialize (uuid-serializer) nil)
-                        (.deserialize (uuid-deserializer) nil)))))
-
-(def uuid-bytes-reverse-roundtrip-property
-  "UUID bytes are the same after deserialization and serialization."
-  (prop/for-all [u gen/uuid]
-                (let [b (.serialize (uuid-serializer) nil u)]
-                  (= (into [] b)
-                     (into [] (->> b
-                                   (.deserialize (uuid-deserializer) nil)
-                                   (.serialize (uuid-serializer) nil)))))))
-
-(defspec uuid-roundtrip-test 100 uuid-bytes-roundtrip-property)
-
-(defspec uuid-reverse-roundtrip-test 100 uuid-bytes-reverse-roundtrip-property)