 
 (def false-pred (constantly false))
 
-(def gen-tasks-and-subset
-  "Returns a vector of two elements.
-   The first represents a seq of downstream
-   tasks, and the second represents a subset
-   of that seq."
+(def predicates
+  {true ::true-red
+   false ::false-pred})
+
+(defn flow-condition-gen [from-task]
+  (gen/hash-map
+   :flow/from (gen/return from-task)
+   :flow/exclude-keys (gen/vector gen/keyword)))
+
+(defn flow-to-all-gen [base-gen]
   (gen/bind
-   (gen/vector gen/keyword)
-   (fn [downstream]
-     (gen/bind
-      (gen/choose 0 (count downstream))
-      (fn [size]
-        (gen/bind
-         (gen/shuffle (take size downstream))
-         (fn [flow-to]
-           (gen/return [downstream flow-to]))))))))
+   base-gen
+   (fn [v]
+     (let [g (gen/hash-map :flow/to (gen/return :all))]
+       (gen/fmap #(merge v %) g)))))
+
+(defn flow-to-none-gen [base-gen]
+  (gen/bind
+   base-gen
+   (fn [v]
+     (let [g (gen/hash-map :flow/to (gen/return :none))]
+       (gen/fmap #(merge v %) g)))))
+
+(defn flow-to-tasks-gen [base-gen]
+  (gen/bind
+   base-gen
+   (fn [v]
+     (let [g (gen/hash-map :flow/to (gen/vector gen/keyword))]
+       (gen/fmap #(merge v %) g)))))
+
+(defn true-flow-condition-gen [base-gen]
+  (gen/bind
+   base-gen
+   (fn [v]
+     (let [g (gen/return ::true-pred)
+           true-gen (gen/hash-map :flow/predicate g)]
+       (gen/fmap #(merge v %) true-gen)))))
+
+(defn false-flow-condition-gen [base-gen]
+  (gen/bind
+   base-gen
+   (fn [v]
+     (let [g (gen/return ::false-pred)
+           false-gen (gen/hash-map :flow/predicate g)]
+       (gen/fmap #(merge v %) false-gen)))))
+
+(defn short-circuit-flow-condition-gen [base-gen]
+  (gen/bind
+   base-gen
+   (fn [v]
+     (let [g (gen/hash-map :flow/short-circuit? (gen/return true))]
+       (gen/fmap #(merge v %) g)))))
+
+(defn exception-flow-condition-gen [base-gen]
+  (gen/bind
+   base-gen
+   (fn [v]
+     (let [g (gen/hash-map
+              :flow/thrown-exception? (gen/return true)
+              :flow/short-circuit? (gen/return true)
+              :flow/post-transform (gen/one-of
+                                    [(gen/return nil)
+                                     (gen/return ::post-transform)]))]
+       (gen/fmap #(merge v %) g)))))
+
+(defn retry-flow-condition-gen [base-gen]
+  (gen/bind
+   base-gen
+   (fn [v]
+     (let [g (gen/hash-map :flow/action (gen/return :retry))]
+       (gen/fmap #(merge v %) g)))))
 
 (deftest nil-flow-conditions
   "No flow condition routes to all downstream tasks"

  (checking
   "The matching flow condition limits the downstream selection"
   (times 50)
   [[downstream flow-to] gen-tasks-and-subset]
   (let [task :a
         fcs [{:flow/from task
               :flow/to flow-to
               :flow/predicate ::true-pred}]
         compiled (c/compile-fc-norms fcs task)
         results
         (t/route-data
          {:onyx.core/compiled-norm-fcs compiled} nil nil fcs downstream)]
     (is (= (into #{} flow-to) (:flow results)))
     (is (nil? (:action results))))))

(deftest conj-downstream-tasks-together

          {:onyx.core/compiled-norm-fcs compiled} nil nil flow-conditions downstream)]
     (is (= (into #{} (mapcat :flow/to flow-conditions)) (:flow results)))
     (is (nil? (:action results))))))



