Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

nested json flow test

  • Loading branch information...
commit 8f6c0d7c57f55b53e813597a60a558f85a8baf0f 1 parent 891a233
Jared Strate authored March 09, 2010

Showing 1 changed file with 20 additions and 0 deletions. Show diff stats Hide diff stats

  1. 20  test/cascading/clojure/flow_test.clj
20  test/cascading/clojure/flow_test.clj
@@ -72,3 +72,23 @@
72 72
          (c/exec flow)
73 73
          (is (= "{\"inc-age\":24,\"up-name\":\"FOO\"}\n{\"inc-age\":15,\"up-name\":\"BAR\"}\n"
74 74
                 (ds/slurp* (ju/file sink "part-00000")))))))))
  75
+
  76
+(defn nested-transform
  77
+  {:fn> ["up-bar"]}
  78
+  [foo]
  79
+  [(.toUpperCase (foo "bar"))])
  80
+
  81
+(deftest nested-json-map-line-test
  82
+  (with-log-level :warn
  83
+    (with-tmp-files [source (temp-dir "source")
  84
+                     sink   (temp-path "sink")]
  85
+    (let [lines [{"foo" {"bar" "baz"}}]]
  86
+      (write-lines-in source "source.data" (map json/generate-string lines))
  87
+      (let [trans (-> (c/pipe "j") (c/map #'nested-transform :< ["foo"]))
  88
+            flow (c/flow
  89
+                  {"j" (c/lfs-tap (c/json-map-line ["foo"]) source)}
  90
+                  (c/lfs-tap (c/json-map-line ["up-bar"]) sink)
  91
+                  trans)]
  92
+        (c/exec flow)
  93
+        (is (= "{\"up-bar\":\"BAZ\"}\n"
  94
+               (ds/slurp* (ju/file sink "part-00000")))))))))

0 notes on commit 8f6c0d7

Please sign in to comment.
Something went wrong with that request. Please try again.