Permalink
Browse files

nested json flow test

  • Loading branch information...
1 parent 891a233 commit 8f6c0d7c57f55b53e813597a60a558f85a8baf0f @jstrate jstrate committed Mar 10, 2010
Showing with 20 additions and 0 deletions.
  1. +20 −0 test/cascading/clojure/flow_test.clj
@@ -72,3 +72,23 @@
(c/exec flow)
(is (= "{\"inc-age\":24,\"up-name\":\"FOO\"}\n{\"inc-age\":15,\"up-name\":\"BAR\"}\n"
(ds/slurp* (ju/file sink "part-00000")))))))))
+
+(defn nested-transform
+ {:fn> ["up-bar"]}
+ [foo]
+ [(.toUpperCase (foo "bar"))])
+
+(deftest nested-json-map-line-test
+ (with-log-level :warn
+ (with-tmp-files [source (temp-dir "source")
+ sink (temp-path "sink")]
+ (let [lines [{"foo" {"bar" "baz"}}]]
+ (write-lines-in source "source.data" (map json/generate-string lines))
+ (let [trans (-> (c/pipe "j") (c/map #'nested-transform :< ["foo"]))
+ flow (c/flow
+ {"j" (c/lfs-tap (c/json-map-line ["foo"]) source)}
+ (c/lfs-tap (c/json-map-line ["up-bar"]) sink)
+ trans)]
+ (c/exec flow)
+ (is (= "{\"up-bar\":\"BAZ\"}\n"
+ (ds/slurp* (ju/file sink "part-00000")))))))))

0 comments on commit 8f6c0d7

Please sign in to comment.