row ops

row ops

--- src/temperaments/core.clj
+++ src/temperaments/core.clj
@@ -61,8 +61,9 @@
     (* tonic-freq (Math/pow 2 octave) (nth (get @tuning-map @tuning) interval))))

 (if (not (o/server-connected?))
-  (o/boot-external-server))
-  ;(o/connect-external-server 60106))
+  ;(o/boot-external-server 57110)
+  (o/connect-external-server 57110)
+)

 (require '[overtone.inst.synth :as syn])

@@ -192,43 +193,61 @@
         oldmap (get @melody-map id)
         newmap (assoc oldmap :instr val)]
     (swap! melody-map assoc id newmap)))
-
+
+(def name->note
+  {"A"       :a3,
+   "B\u266D" :a#3,
+   "B"       :b3,
+   "C"       :c4,
+   "C\u266F" :c#4,
+   "D"       :d4,
+   "E\u266D" :d#4,
+   "E"       :e4,
+   "F"       :f4,
+   "F\u266F" :f#4,
+   "G"       :g4,
+   "G\u266F" :g#4})
+
+(def note-names '("A" "B♭" "B" "C" "C♯" "D" "E♭" "E" "F" "F♯" "G" "G♯"))
+
+;; (defn invert-hash [hash]
+;;   (let [gr (group-by val hash)
+;;         pairs (map #(vector (->> % val first first) (key %)) gr)]
+;;     (into {} pairs)))
+
+;; (def note->name
+;;   (invert-hash name->note))
+
+;; (def note->midi
+;;   (let [notes (keys name->note)
+;;         midis (map o/note notes)
+;;         pairs (map vector midis notes)]
+;;     (into {} pairs)))
+
+;; (def midi->note
+;;   (invert-hash note->midi))
+
 (defn tonic-chooser [e]
   (let [val (value (.getSource e))]
-    (case val
-      "A"       (reset! tonic :a3)
-      "B\u266D" (reset! tonic :a#3)
-      "B"       (reset! tonic :b3)
-      "C"       (reset! tonic :c4)
-      "C\u266F" (reset! tonic :c#4)
-      "D"       (reset! tonic :d4)
-      "E\u266D" (reset! tonic :d#4)
-      "E"       (reset! tonic :e4)
-      "F"       (reset! tonic :f4)
-      "F\u266F" (reset! tonic :f#4)
-      "G"       (reset! tonic :g4)
-      "G\u266F" (reset! tonic :g#4))))
+    (reset! tonic (get name->note val))))

 (defn str->midi [strnote]
   (let [oct (read-string (str (last strnote)))
         len (dec (count strnote))
         val (subs strnote 0 len)
-        octch (* 12 (- oct 4))]
-    (case val
-      "C"       (+ 60 octch)
-      "C\u266F" (+ 61 octch)
-      "D"       (+ 62 octch)
-      "E\u266D" (+ 63 octch)
-      "E"       (+ 64 octch)
-      "F"       (+ 65 octch)
-      "F\u266F" (+ 66 octch)
-      "G"       (+ 67 octch)
-      "G\u266F" (+ 68 octch)
-      "A"       (+ 69 octch)
-      "B\u266D" (+ 70 octch)
-      "B"       (+ 71 octch)
-)))
-
+        corr (case val ("A" "B♭" "B") 3 4)
+        octch (* 12 (- oct corr))]
+    (+ (o/note (name->note val)) octch)))
+
+
+(defn midi->str [midi]
+  (let [diff (- midi 59)
+        corr (if (> diff 0) 0 -1)
+        oct (+ 4 corr (quot diff 12))
+        ind (mod (+ diff 2) 12)
+        nm (nth note-names ind)]
+    (s/join [nm (str oct)])))
+
 (defn tuning-chooser [e]
   (let [val (value (.getSource e))]
     (case val
@@ -559,6 +578,36 @@
          trans (translate-seq del seq)]
      (reverse trans))))

+(defn transpose-seq
+  ([n] #(transpose-seq n %))
+  ([n seq]
+   (map #(+ n %) seq)))
+
+(defn transpose-names
+  ([n] #(transpose-names n %))
+  ([n seq]
+   (let [oldnotes (map str->midi seq)
+         newnotes (transpose-seq n oldnotes)]
+     (map midi->str newnotes))))
+
+(defn invert-about
+  ([center] #(invert-about center %))
+  ([center nt]
+   (let [diff (- nt center)]
+     (int (- center diff)))))
+
+(defn invert-seq
+  ([center] #(invert-seq center %))
+  ([center seq]
+   (map (invert-about center) seq)))
+
+(defn invert-names
+  ([n] #(invert-names n %))
+  ([n seq]
+   (let [oldnotes (map str->midi seq)
+         newnotes (invert-seq n oldnotes)]
+     (map midi->str newnotes))))
+
 (defn transform-dict [dict trans]
   (let [kws (keys dict)
         oldvals (vals dict)
@@ -589,6 +638,22 @@
                                            (transform-necklace
                                                    (translate-seq (get-e-val e))
                                                    id typekw))])]
+    (horizontal-panel :items [reflect-button translabel transbox])))
+
+(defn make-rowops-panel [id]
+  (let [reflect-button (button :text "Invert!"
+                               :listen [:action
+                                        (fn [e]
+                                          (transform-necklace
+                                           (invert-names (+ (o/note @tonic) 3.5))
+                                           id :pitches))])
+        translabel (label "Transpose: ")
+        transbox (combobox :model (range -6 7)
+                           :id (keyword (s/join ["kb-" id "-mel-transpose"]))
+                           :listen [:action (fn [e]
+                                           (transform-necklace
+                                                   (transpose-names (get-e-val e))
+                                                   id :pitches))])]
     (horizontal-panel :items [reflect-button translabel transbox])))

 ;;;;;;;;;;;;;; transforms end
@@ -629,10 +694,12 @@
     (swap! melody-map assoc id {:pitches numcbs, :beats numcbs,
                                 :root f, :instr "Default"})
     (add-note-circles id pan)
-    (let [mel-controls (make-transform-panel id :pitches)
+    (let [rowops (make-rowops-panel id)
+          mel-controls (make-transform-panel id :pitches)
           rhy-controls (make-transform-panel id :beats)
-          verticalpanel (vertical-panel :items [mel-controls pan rhy-controls
-                                                chinstr playsolo controls])]
+          verticalpanel (vertical-panel :items [rowops mel-controls pan
+                                                rhy-controls chinstr
+                                                playsolo controls])]
       (config! f :content verticalpanel)
       (-> f pack! show!)
       f)))


Check multiple instance health in parallel

--- src/maestro/messages/health.clj
+++ src/maestro/messages/health.clj
@@ -42,9 +42,16 @@
     {:url url
      :successful? (ok-response? url)}))

+(defn- choose-map-fn
+  [ip-addresses]
+  (if (> (count ip-addresses) 1)
+    pmap
+    map))
+
 (defn- check-instances-health
   [ip-addresses port healthcheck-path]
-  (let [check-results (map #(check-instance-health % port healthcheck-path) ip-addresses)]
+  (let [map-fn (choose-map-fn ip-addresses)
+        check-results (map-fn #(check-instance-health % port healthcheck-path) ip-addresses)]
     (log/write (format "%s came back [%s]." (util/pluralise (count check-results) "Healthcheck") (str/join ", " (map (fn [r] (format "%s => %s" (:url r) (:successful? r))) check-results))))
     check-results))


♻ Cleanup

♻ Cleanup

--- src/territory_bro/api.clj
+++ src/territory_bro/api.clj
@@ -132,16 +132,14 @@
       (assert (not (str/blank? name)) ; TODO: test this
               {:name name})
       (db/with-db [conn {}]
-        (let [user-id (current-user-id)]
-          (binding [events/*current-user* user-id]
-            ;; TODO: use api-command!
-            (let [events (dispatcher/command! conn state {:command/type :congregation.command/create-congregation
-                                                          :command/time (Instant/now)
-                                                          :command/user user-id
-                                                          :congregation/id (UUID/randomUUID)
-                                                          :congregation/name name})
-                  cong-id (:congregation/id (first events))]
-              (ok {:id cong-id}))))))))
+        (let [user-id (current-user-id)
+              events (dispatcher/command! conn state {:command/type :congregation.command/create-congregation
+                                                      :command/time (Instant/now)
+                                                      :command/user user-id
+                                                      :congregation/id (UUID/randomUUID)
+                                                      :congregation/name name})
+              cong-id (:congregation/id (first events))]
+          (ok {:id cong-id}))))))

 (defn list-congregations [request]
   (auth/with-authenticated-user request


Refactor, simplify

Refactor, simplify

--- src/buildviz/analyse/wait_times.clj
+++ src/buildviz/analyse/wait_times.clj
@@ -7,14 +7,13 @@
                  builds)))

 (defn- build-wait-time [{:keys [job build-id start]} triggering-build]
-  (when-let [triggering-build-end (:end triggering-build)]
-    (let [wait-time (- start
-                       triggering-build-end)]
-      {:job job
-       :build-id build-id
-       :start start
-       :wait-time wait-time
-       :triggered-by (select-keys triggering-build [:job :build-id])})))
+  (let [wait-time (- start
+                     (:end triggering-build))]
+    {:job job
+     :build-id build-id
+     :start start
+     :wait-time wait-time
+     :triggered-by (select-keys triggering-build [:job :build-id])}))

 ;; Jenkins for example may report multiple builds of the same jobs as trigger,
 ;; if the triggered job is slow to schedule, and multiple triggering builds
@@ -29,6 +28,7 @@
   (when-let [triggered-builds (->> (:triggered-by build)
                                    (map #(find-build % all-builds))
                                    (remove nil?)
+                                   (filter :end)
                                    seq)]
     ;; If a job needs multiple preceding jobs to be triggered, then only the
     ;; latest will finally fulfill the requirement for a successful trigger,


Removed deleted examples from top contribs calculation

--- src/clj/clojuredocs/pages/intro.clj
+++ src/clj/clojuredocs/pages/intro.clj
@@ -118,7 +118,7 @@

 (defn top-contribs []
   (let [scores (atom {})]
-    (doseq [{:keys [author _id]} (mon/fetch :examples)]
+    (doseq [{:keys [author _id]} (mon/fetch :examples :where {:deleted-at nil})]
       (let [editors (->> (mon/fetch :example-histories :where {:example-id _id})
                          (map :editor))]
         (swap! scores update-in [author] #(+ 4 (or % 0)))


Setup builtin images and collections in the state.

--- src/uxbox/main/state.cljs
+++ src/uxbox/main/state.cljs
@@ -8,6 +8,7 @@
 (ns uxbox.main.state
   (:require [beicon.core :as rx]
             [lentes.core :as l]
+            [uxbox.main.library :as library]
             [uxbox.util.rstore :as rs]
             [uxbox.util.i18n :refer (tr)]
             [uxbox.util.storage :refer (storage)]))
@@ -33,6 +34,8 @@
    :undo {}
    :profile nil
    :workspace nil
+   :images-by-id library/+images-by-id+
+   :image-colls-by-id library/+image-collections-by-id+
    :shapes-by-id nil
    :elements-by-id nil
    :colors-by-id nil


better log4j2 config resource handling

better log4j2 config resource handling

--- src/clojure/zensols/actioncli/log4j2.clj
+++ src/clojure/zensols/actioncli/log4j2.clj
@@ -57,10 +57,10 @@
   with [[clojure.java.io/input-stream]].  If **res** is a string, interpret as
   a resource."
   [res]
-  (let [res (if (string? res)
-              (io/resource res)
-              res)]
-    (with-open [in (io/input-stream res)]
+  (let [stream (cond (string? res) (io/input-stream (io/resource res))
+                     (instance? java.io.InputStream res)
+                     true (io/input-stream res))]
+    (with-open [in stream]
       (LogUtil/config in))
     (log/debugf "configured with XML resource: %s" res)))


Fix indentation for docstring of defsetting :page_facing_up:

--- src/metabase/models/setting.clj
+++ src/metabase/models/setting.clj
@@ -160,10 +160,10 @@
    You may optionally pass any of the kwarg OPTIONS below, which are kept as part of the
    metadata of the `Setting` under the key `::options`:

-     *  `:internal` - This `Setting` is for internal use and shouldn't be exposed in the UI (i.e., not
-                      returned by the corresponding endpoints). Default: `false`
-     *  `:getter` - A custom getter fn, which takes no arguments. Overrides the default implementation.
-     *  `:setter` - A custom setter fn, which takes a single argument. Overrides the default implementation."
+   *  `:internal` - This `Setting` is for internal use and shouldn't be exposed in the UI (i.e., not
+                    returned by the corresponding endpoints). Default: `false`
+   *  `:getter` - A custom getter fn, which takes no arguments. Overrides the default implementation.
+   *  `:setter` - A custom setter fn, which takes a single argument. Overrides the default implementation."
   [nm description & [default-value & {:as options}]]
   {:pre [(symbol? nm)
          (string? description)]}


Fix invalid call, which was preventing rails from starting up.

--- src/circle/backend/build.clj
+++ src/circle/backend/build.clj
@@ -72,7 +72,7 @@

 (defn project-name [b]
   {:pre [(-> @b :_project_id)]}
-  (-> @b :_project_id (project/fetch-by-id) :name))
+  (-> @b :_project_id (mongo/fetch-by-id :projects) :name))

 (defn build [{:keys [build_num    ;; int
                      vcs_url


update start routine

update start routine

--- src/clj/lesezeichen/core.clj
+++ src/clj/lesezeichen/core.clj
@@ -78,16 +78,17 @@
 (defn -main [& args]
   (init server-state (first args))
   (init-schema (:schema @server-state))
+  (add-user {:email "eve@topiq.es"})
   (start-server (:port @server-state)))

 (comment

-  (init-schema "schema.edn")
+  (init server-state "resources/server-config.edn")
+
+  (init-schema (:schema @server-state))

   (add-user {:email "eve@topiq.es"})
-
-  (init server-state "resources/server-config.edn")

   (def server (start-server (:port @server-state)))


add news page

add news page

--- src/clj/modern_cljs/core.clj
+++ src/clj/modern_cljs/core.clj
@@ -5,11 +5,9 @@
             [ring.middleware.json :refer [wrap-json-response]]
             [ring.util.response :refer [response]]
             [compojure.route :as route]
-            [ring.middleware.json :as middleware]
             [ring.middleware.cors :refer [wrap-cors]]
             [modern-cljs.views :as views]
             [modern-cljs.views.layout :as layout]
-            [cheshire.core :as json]
             [modern-cljs.service.browse-news-service :as browse-news-service]
             [modern-cljs.service.add-news-service :as add-news-service]))

@@ -20,16 +18,16 @@
            ; to serve document root address
            (GET "/" [] (layout/application "Home" (views/news-list)))
            (GET "/news/:id" [id] (layout/application "Read News" (views/browse-news id)))
-           (GET "/add-news" [] "Add News Page" (layout/application (views/add-news-page)))
+           (GET "/add-news" [] (layout/application "Add News Page" (views/add-news-page)))

            (route/resources "/") ; to serve static pages saved in resources/public directory
            (route/not-found "Page not found")) ; if page is not found

 (defroutes api-routes
-           (context "/api" []
-             (POST "/add-news" [] add-news-service/add-news)
-             (POST "/add-comment" [] browse-news-service/add-comment)
-             (POST "/delete-comment" [] browse-news-service/remove-comment)))
+   (context "/api" []
+     (POST "/add-news" [] add-news-service/add-news)
+     (POST "/add-comment" [] browse-news-service/add-comment)
+     (POST "/delete-comment" [] browse-news-service/remove-comment)))

 (defn wrap-log-request [handler]
@@ -45,8 +43,7 @@
       ))

 (def api-handler
-  (->
-      (handler/api api-routes)))
+  (-> (handler/api api-routes)))

 (def handler
   (routes                                                   ;;got it here http://stackoverflow.com/questions/30303256/registering-multiple-handlers-while-running-server


remove wrap-frame-options

remove wrap-frame-options

--- src/clj/movement/handler.clj
+++ src/clj/movement/handler.clj
@@ -492,7 +492,7 @@
                     (wrap-params)
                     (wrap-session)
                     (wrap-defaults site-defaults)
-                    (wrap-frame-options :sameorigin #_{:allow-from "http://www.movementsession.com"}))]
+                    #_(wrap-frame-options {:allow-from "http://www.movementsession.com"}))]
     (if (env :dev?)
       (wrap-reload (wrap-exceptions handler))
       handler)))


Fix plugin-fun memoization

Fix plugin-fun memoization

--- src/clj/salava/core/util.clj
+++ src/clj/salava/core/util.clj
@@ -9,6 +9,7 @@
             [clojure.java.shell :refer [sh]]
             [clj.qrgen :as q]
             [clj-time.coerce :as tc]
+            [salava.core.helper :refer [plugin-str]]
             [pantomime.mime :refer [extension-for-name mime-type-of]]
             [buddy.core.codecs :refer [base64->bytes base64->str bytes->base64]]))

@@ -179,17 +180,16 @@
     (re-find #"^[0-9]+$" s) (Long. s)
     (re-find #"^\d{4}-\d\d-\d\d" s) (some-> (tc/to-long s) (quot 1000))))

-(defn plugin-fun
+(def plugin-fun
   (memoize
     (fn [plugins nspace name]
       (let [fun (fn [p]
                   (try
                     (let [sym (symbol (str "salava." p "." nspace "/" name))]
-                      (require (symbol (namespace sym)) :reload)
+                      (require (symbol (namespace sym)))
                       (resolve sym))
                     (catch Throwable _)))]
         (->> plugins
              (map #(str/replace (plugin-str %) #"/" "."))
              (map fun)
-             (filter function?))))))
-
+             (filter #(not (nil? %))))))))


use println for logging

use println for logging

--- src/cljs/clojexcms/core.cljs
+++ src/cljs/clojexcms/core.cljs
@@ -3,6 +3,8 @@
             [om.core :as om :include-macros true]
             [om.dom :as dom :include-macros true]
             [taoensso.sente :as sente :refer (cb-success?)]))
+
+(enable-console-print!)

 (defonce app-state (atom {:text "Hello Chestnut!"}))

@@ -17,17 +19,17 @@

 (defmethod event-msg-handler :default ; Fallback
   [{:as ev-msg :keys [event]}]
-  (.log js/console "Unhandled event: %s" event))
+  (println "Unhandled event:" event))

 (defmethod event-msg-handler :chsk/state
   [{:as ev-msg :keys [?data]}]
   (if (= ?data {:first-open? true})
-    (.log js/console "Channel socket successfully established!")
-    (.log js/console "Channel socket state change: %s" ?data)))
+    (println "Channel socket successfully established!")
+    (println "Channel socket state change:" ?data)))

 (defmethod event-msg-handler :chsk/recv
   [{:as ev-msg :keys [?data]}]
-  (.log js/console "Push event from server: %s" ?data))
+  (println "Push event from server:" ?data))

 (defn main []
   (sente/start-chsk-router! ch-chsk event-msg-handler)


Refactor initial view into defcomponent.

--- src/cljs/yadnd5ecs/core.cljs
+++ src/cljs/yadnd5ecs/core.cljs
@@ -7,12 +7,13 @@

 (def app-state (atom {:text "Hello Chestnut!"}))

+(defcomponent app-view
+  [app owner]
+  (render [_]
+          (dom/h1 (:text app))))
+
 (defn main []
   (om/root
-    (fn [app owner]
-      (reify
-        om/IRender
-        (render [_]
-          (dom/h1 (:text app)))))
+    app-view
     app-state
     {:target (. js/document (getElementById "app"))}))


Also mangle map schema :values.

Also mangle map schema :values.

--- src/clojure/abracad/avro.clj
+++ src/clojure/abracad/avro.clj
@@ -25,16 +25,16 @@
   "Mange the value of key `k` in map `m`."
   [m k] (let [x (m k)] (if-not (named? x) m (assoc m k (-> x name mangle)))))

+(def ^:private mangled-names
+  [:name :namespace :type :items :values])
+
 (defn ^:private schema-mangle
   "If `form` is a map, mangle the values of the `:name`, `:namespace`,
 and `:type` keys."
   [form]
   (if-not (map? form)
     form
-    (-> (mangle-value form :name)
-        (mangle-value ,,,, :namespace)
-        (mangle-value ,,,, :type)
-        (mangle-value ,,,, :items))))
+    (reduce mangle-value form mangled-names)))

 (defn ^:private clj->json
   "Parse Clojure data into a JSON schema."


(MAINT) Prefer clj-time/seconds over clj-time/secs

The latter is deprecated in favor of the former; we should no longer see
deprecation warnings during `lein test` for this.

--- src/clj/puppetlabs/puppetserver/certificate_authority.clj
+++ src/clj/puppetlabs/puppetserver/certificate_authority.clj
@@ -163,7 +163,7 @@
   [ca-ttl :- schema/Int]
   (let [now        (time/now)
         not-before (time/minus now (time/days 1))
-        not-after  (time/plus now (time/secs ca-ttl))]
+        not-after  (time/plus now (time/seconds ca-ttl))]
     {:not-before (.toDate not-before)
      :not-after  (.toDate not-after)}))


Fix broken Thurloe status link

Fix broken Thurloe status link

--- src/cljs/org/broadinstitute/firecloud_ui/page/status.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/status.cljs
@@ -34,8 +34,12 @@
            [:div {} "Response text:" [:br] (-> (:xhr response) .-responseText)]]))])
    :component-did-mount
    (fn [{:keys [props state]}]
-     (utils/ajax-orch (:path (:request props))
-                      {:on-done #(swap! state assoc :response %)}))})
+     (if (= (:path (:request props)) "/profile")
+       (utils/ajax-orch (:path (:request props))
+                        {:on-done #(swap! state assoc :response %)}
+                        :service-prefix "/service/register")
+       (utils/ajax-orch (:path (:request props))
+                        {:on-done #(swap! state assoc :response %)})))})

 (defn render []
@@ -46,4 +50,4 @@
     [StatusLine {:label "Orchestration" :request {:path "/status/ping"}}]
     [StatusLine {:label "Rawls" :request {:path "/workspaces"}}]
     [StatusLine {:label "Agora" :request {:path "/methods"}}]
-    [StatusLine {:label "Thurloe" :request {:path "/register/profile"}}]]))
+    [StatusLine {:label "Thurloe" :request {:path "/profile"}}]]))


get rid of ..

get rid of ..

--- src/forex/module/account/common.clj
+++ src/forex/module/account/common.clj
@@ -12,22 +12,6 @@
      ~@body))

 ;;TODO: do we need all of these assertions?
-(comment
-  (defn g []
-    (def o (order! {:symbol "EURUSD"
-		    :price 1.31133
-		    :type :sell-stop
-		    :lots 0.1}))))
-
-(defn oo []
-  (def o
-    (order! {:type :sell-stop
-	     :lots 0.1
-	     :symbol "USDCHF"
-	     :price 0.9332
-	     :sl 0.9388
-	     :tp 0.9275
-	     })))

 (def- value-to-order-type
   {0 :buy 1 :sell 2 :buy-limit


use optional named argument for exit-code in die function

--- src/fscrawler_tika_convert/core.clj
+++ src/fscrawler_tika_convert/core.clj
@@ -171,9 +171,9 @@
     (lcons/blocking-subscribe ch queue-name handle-message :auto-ack false)))

 (defn die
-  [msg exitcode]
+  [msg & {:keys [exit-code] :or {exit-code 1}}]
   (println "Error:" msg)
-  (System/exit exitcode))
+  (System/exit exit-code))

 (defn setup-logging!
@@ -201,11 +201,11 @@
                  ["--inisection" "(required) section to use from configuration file"]
                  ["--iniconfig" "(required) ini configuration filename"])]
     (when (:help options)
-      (die banner 0))
+      (die banner :exit-code 0))
     (when-not (:iniconfig options)
-      (die "--iniconfig option missing" 1))
+      (die "--iniconfig option missing"))
     (when-not (:inisection options)
-      (die "--inisection option missing" 1))
+      (die "--inisection option missing"))
     options))

@@ -242,11 +242,14 @@
                                "from ini file" iniconfig)
                  (ini/read-ini iniconfig))
         section (or (config inisection)
-                    (die (str "section " inisection " missing in " iniconfig) 1))
+                    (die (str "section " inisection " missing in " iniconfig)))
+        fscrawler-section (or (config "fscrawler") {})
+        max-size (Integer. (fscrawler-section "max_size"))
         filesystems (trimmed-lines-from-string (section "filesystems"))]
     (when (zero? (count filesystems))
-      (die (str "no filesystems defined in section " inisection " in " iniconfig) 1))
-
+      (die (str "no filesystems defined in section " inisection " in " iniconfig)))
+
+    (println "max-size is" max-size)
     (periodically 250 reap-futures)

     (let [futures (doall (for [filesystem filesystems]
@@ -256,4 +259,4 @@
           @f
           (catch Throwable err
             (trace/print-stack-trace err)
-            (die (str "thread unexpectedly died with error " err) 1)))))))
+            (die (str "thread unexpectedly died with error " err))))))))


CMR-2810 fixes indentation in tests

CMR-2810 fixes indentation in tests

--- access-control-app/int_test/cmr/access_control/int_test/permission_check_test.clj
+++ access-control-app/int_test/cmr/access_control/int_test/permission_check_test.clj
@@ -65,379 +65,379 @@

 ;; Commented out. See CMR-3224

- (deftest collection-simple-catalog-item-identity-permission-check-test
-   ;; tests ACLs which grant access to collections based on provider id and/or entry title
-   (let [token (e/login (u/conn-context) "user1" ["group-create-group"])
-         ;; helper for easily creating a group, returns concept id
-         create-group #(:concept_id (u/create-group token (u/make-group %)))
-         ;; then create a group that contains our user, so we can find collections that grant access to this user
-         user1-group (create-group {:name "groupwithuser1" :members ["user1"]})
-         ;; create some collections
-         ingest-prov1-collection #(u/ingest-collection token {:provider-id "PROV1"
-                                                            :entry-title (str % " entry title")
-                                                            :native-id %
-                                                            :short-name %})
-         coll1 (ingest-prov1-collection "coll1")
-         coll2 (ingest-prov1-collection "coll2")
-         coll3 (ingest-prov1-collection "coll3")
-         gran1 (mdb/save-concept (u/conn-context)
-                                 {:format "application/echo10+xml"
-                                  :metadata granule-metadata
-                                  :concept-type :granule
-                                  :provider-id "PROV1"
-                                  :native-id "gran1"
-                                  :revision-id 1
-                                  :extra-fields {:short-name "gran1"
-                                                 :entry-title "gran1"
-                                                 :entry-id "gran1"
-                                                 :granule-ur "gran1ur"
-                                                 :version-id "v1"
-                                                 :parent-collection-id coll1
-                                                 :parent-entry-title "coll1"}})
-         ;; local helpers to make the body of the test cleaner
-         create-acl #(:concept_id (ac/create-acl (u/conn-context) % {:token token}))
-         update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})
-         get-collection-permissions #(get-permissions %1 coll1)
-         get-granule-permissions #(get-permissions %1 (:concept-id gran1))]
-
-     (testing "no permissions granted"
-       (are [user permissions]
-         (= {"C1200000001-PROV1" permissions}
-            (get-collection-permissions user))
-         :guest []
-         :registered []
-         "user1" []))
-
-     (testing "collection level permissions"
-       (let [acl-concept-id (create-acl {:group_permissions [{:permissions [:read :order]
-                                                              :user_type :guest}]
-                                         :catalog_item_identity {:name "coll1 read and order"
-                                                                 :collection_applicable true
-                                                                 :provider_id "PROV1"}})]
-         (u/wait-until-indexed)
-
-         (testing "for guest users"
-           (are [user permissions]
-             (= {"C1200000001-PROV1" permissions}
-                (get-collection-permissions user))
-             :guest ["read" "order"]
-             :registered []
-             "user1" []))
-
-         (testing "for registered users"
-           (update-acl acl-concept-id
-                       {:group_permissions [{:permissions [:read :order]
-                                             :user_type :registered}]
-                        :catalog_item_identity {:name "coll1 read and order"
-                                                :collection_applicable true
-                                                :provider_id "PROV1"}})
-           (are [user permissions]
-             (= {"C1200000001-PROV1" permissions}
-                (get-collection-permissions user))
-             :guest []
-             :registered ["read" "order"]
-             "user1" ["read" "order"]))
-
-         (testing "acls granting access to specific groups"
-
-           (update-acl acl-concept-id
-                       {:group_permissions [{:permissions [:read :order]
-                                             :group_id user1-group}]
-                        :catalog_item_identity {:name "coll1 read and order"
-                                                :collection_applicable true
-                                                :provider_id "PROV1"}})
-
-           (are [user permissions]
-             (= {"C1200000001-PROV1" permissions}
-                (get-collection-permissions user))
-             :guest []
-             :registered []
-             "user1" ["read" "order"]
-             "user2" [])
-
-           (testing "with a complex ACL distributing permissions across multiple groups"
-             (let [user2-group1 (create-group {:name "group1withuser2" :members ["user2"]})
-                   user2-group2 (create-group {:name "group2withuser1and2" :members ["user1" "user2"]})]
-               (u/wait-until-indexed)
-               (create-acl {:group_permissions [{:permissions [:read] :group_id user1-group}
-                                                {:permissions [:read] :group_id user2-group1}
-                                                {:permissions [:order] :group_id user2-group2}]
-                            :catalog_item_identity {:name "PROV1 complex ACL"
+(deftest collection-simple-catalog-item-identity-permission-check-test
+  ;; tests ACLs which grant access to collections based on provider id and/or entry title
+  (let [token (e/login (u/conn-context) "user1" ["group-create-group"])
+        ;; helper for easily creating a group, returns concept id
+        create-group #(:concept_id (u/create-group token (u/make-group %)))
+        ;; then create a group that contains our user, so we can find collections that grant access to this user
+        user1-group (create-group {:name "groupwithuser1" :members ["user1"]})
+        ;; create some collections
+        ingest-prov1-collection #(u/ingest-collection token {:provider-id "PROV1"
+                                                             :entry-title (str % " entry title")
+                                                             :native-id %
+                                                             :short-name %})
+        coll1 (ingest-prov1-collection "coll1")
+        coll2 (ingest-prov1-collection "coll2")
+        coll3 (ingest-prov1-collection "coll3")
+        gran1 (mdb/save-concept (u/conn-context)
+                                {:format "application/echo10+xml"
+                                 :metadata granule-metadata
+                                 :concept-type :granule
+                                 :provider-id "PROV1"
+                                 :native-id "gran1"
+                                 :revision-id 1
+                                 :extra-fields {:short-name "gran1"
+                                                :entry-title "gran1"
+                                                :entry-id "gran1"
+                                                :granule-ur "gran1ur"
+                                                :version-id "v1"
+                                                :parent-collection-id coll1
+                                                :parent-entry-title "coll1"}})
+        ;; local helpers to make the body of the test cleaner
+        create-acl #(:concept_id (ac/create-acl (u/conn-context) % {:token token}))
+        update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})
+        get-collection-permissions #(get-permissions %1 coll1)
+        get-granule-permissions #(get-permissions %1 (:concept-id gran1))]
+
+    (testing "no permissions granted"
+      (are [user permissions]
+        (= {"C1200000001-PROV1" permissions}
+           (get-collection-permissions user))
+        :guest []
+        :registered []
+        "user1" []))
+
+    (testing "collection level permissions"
+      (let [acl-concept-id (create-acl {:group_permissions [{:permissions [:read :order]
+                                                             :user_type :guest}]
+                                        :catalog_item_identity {:name "coll1 read and order"
+                                                                :collection_applicable true
+                                                                :provider_id "PROV1"}})]
+        (u/wait-until-indexed)
+
+        (testing "for guest users"
+          (are [user permissions]
+            (= {"C1200000001-PROV1" permissions}
+               (get-collection-permissions user))
+            :guest ["read" "order"]
+            :registered []
+            "user1" []))
+
+        (testing "for registered users"
+          (update-acl acl-concept-id
+                      {:group_permissions [{:permissions [:read :order]
+                                            :user_type :registered}]
+                       :catalog_item_identity {:name "coll1 read and order"
+                                               :collection_applicable true
+                                               :provider_id "PROV1"}})
+          (are [user permissions]
+            (= {"C1200000001-PROV1" permissions}
+               (get-collection-permissions user))
+            :guest []
+            :registered ["read" "order"]
+            "user1" ["read" "order"]))
+
+        (testing "acls granting access to specific groups"
+
+          (update-acl acl-concept-id
+                      {:group_permissions [{:permissions [:read :order]
+                                            :group_id user1-group}]
+                       :catalog_item_identity {:name "coll1 read and order"
+                                               :collection_applicable true
+                                               :provider_id "PROV1"}})
+
+          (are [user permissions]
+            (= {"C1200000001-PROV1" permissions}
+               (get-collection-permissions user))
+            :guest []
+            :registered []
+            "user1" ["read" "order"]
+            "user2" [])
+
+          (testing "with a complex ACL distributing permissions across multiple groups"
+            (let [user2-group1 (create-group {:name "group1withuser2" :members ["user2"]})
+                  user2-group2 (create-group {:name "group2withuser1and2" :members ["user1" "user2"]})]
+              (u/wait-until-indexed)
+              (create-acl {:group_permissions [{:permissions [:read] :group_id user1-group}
+                                               {:permissions [:read] :group_id user2-group1}
+                                               {:permissions [:order] :group_id user2-group2}]
+                           :catalog_item_identity {:name "PROV1 complex ACL"
+                                                   :collection_applicable true
+                                                   :provider_id "PROV1"}})
+              (are [user permissions]
+                (= {"C1200000001-PROV1" permissions}
+                   (get-collection-permissions user))
+                :guest []
+                :registered []
+                "user1" ["read" "order"]
+                "user2" ["read" "order"]))))
+
+        (testing "acls granting access to collection by collection identifier"
+          (testing "by entry title"
+            (create-acl
+              {:group_permissions [{:permissions [:read]
+                                    :user_type :guest}]
+               :catalog_item_identity {:name "coll2 guest read"
+                                       :collection_applicable true
+                                       :collection_identifier {:entry_titles ["coll2 entry title"]}
+                                       :provider_id "PROV1"}})
+            (testing "for collection in ACL's entry titles"
+              (are [user permissions]
+                (= {"C1200000002-PROV1" permissions}
+                   (get-permissions user "C1200000002-PROV1"))
+                :guest ["read"]
+                :registered []))
+            (testing "for collection not in ACL's entry titles"
+              (are [user permissions]
+                (= {"C1200000003-PROV1" permissions}
+                   (get-permissions user "C1200000003-PROV1"))
+                :guest []
+                :registered []))))))
+
+    (testing "granule level permissions"
+      (testing "no permissions granted"
+        (is (= {"G1200000004-PROV1" []}
+               (get-granule-permissions "user1")))))))
+
+(deftest collection-catalog-item-identifier-access-value-test
+  ;; tests ACLs which grant access to collections based on their access value
+  (let [token (e/login (u/conn-context) "user1" [])
+        ingest-access-value-collection (fn [short-name access-value]
+                                         (u/ingest-collection token {:entry-title (str short-name " entry title")
+                                                                     :short-name short-name
+                                                                     :native-id short-name
+                                                                     :provider-id "PROV1"
+                                                                     :access-value access-value}))
+        ;; one collection with a low access value
+        coll1 (ingest-access-value-collection "coll1" 1)
+        ;; one with an intermediate access value
+        coll2 (ingest-access-value-collection "coll2" 4)
+        ;; one with a higher access value
+        coll3 (ingest-access-value-collection "coll3" 9)
+        ;; and one with no access value
+        coll4 (ingest-access-value-collection "coll4" nil)
+        create-acl #(:concept_id (ac/create-acl (u/conn-context) % {:token token}))
+        update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})
+        get-coll-permissions #(get-permissions :guest coll1 coll2 coll3 coll4)]
+    (u/wait-until-indexed)
+
+    (testing "no permissions granted"
+      (is (= {"C1200000000-PROV1" []
+              "C1200000001-PROV1" []
+              "C1200000002-PROV1" []
+              "C1200000003-PROV1" []}
+             (get-coll-permissions))))
+
+    (let [acl-id (create-acl
+                   {:group_permissions [{:permissions [:read]
+                                         :user_type :guest}]
+                    :catalog_item_identity {:name "coll2 guest read"
+                                            :collection_applicable true
+                                            :collection_identifier {:access_value {:min_value 1 :max_value 10}}
+                                            :provider_id "PROV1"}})]
+
+      (testing "ACL matching all access values"
+        (is (= {"C1200000000-PROV1" ["read"]
+                "C1200000001-PROV1" ["read"]
+                "C1200000002-PROV1" ["read"]
+                "C1200000003-PROV1" []}
+               (get-coll-permissions))))
+
+      (testing "ACL matching only high access values"
+        (update-acl acl-id {:group_permissions [{:permissions [:read]
+                                                 :user_type :guest}]
+                            :catalog_item_identity {:name "coll2 guest read"
                                                     :collection_applicable true
+                                                    :collection_identifier {:access_value {:min_value 4 :max_value 10}}
                                                     :provider_id "PROV1"}})
-               (are [user permissions]
-                 (= {"C1200000001-PROV1" permissions}
-                    (get-collection-permissions user))
-                 :guest []
-                 :registered []
-                 "user1" ["read" "order"]
-                 "user2" ["read" "order"]))))
-
-         (testing "acls granting access to collection by collection identifier"
-           (testing "by entry title"
-             (create-acl
-               {:group_permissions [{:permissions [:read]
-                                     :user_type :guest}]
-                :catalog_item_identity {:name "coll2 guest read"
-                                        :collection_applicable true
-                                        :collection_identifier {:entry_titles ["coll2 entry title"]}
-                                        :provider_id "PROV1"}})
-             (testing "for collection in ACL's entry titles"
-               (are [user permissions]
-                 (= {"C1200000002-PROV1" permissions}
-                    (get-permissions user "C1200000002-PROV1"))
-                 :guest ["read"]
-                 :registered []))
-             (testing "for collection not in ACL's entry titles"
-               (are [user permissions]
-                 (= {"C1200000003-PROV1" permissions}
-                    (get-permissions user "C1200000003-PROV1"))
-                 :guest []
-                 :registered []))))))
-
-     (testing "granule level permissions"
-       (testing "no permissions granted"
-         (is (= {"G1200000004-PROV1" []}
-                (get-granule-permissions "user1")))))))
-
- (deftest collection-catalog-item-identifier-access-value-test
-   ;; tests ACLs which grant access to collections based on their access value
-   (let [token (e/login (u/conn-context) "user1" [])
-         ingest-access-value-collection (fn [short-name access-value]
-                                          (u/ingest-collection token {:entry-title (str short-name " entry title")
-                                                                    :short-name short-name
-                                                                    :native-id short-name
-                                                                    :provider-id "PROV1"
-                                                                    :access-value access-value}))
-         ;; one collection with a low access value
-         coll1 (ingest-access-value-collection "coll1" 1)
-         ;; one with an intermediate access value
-         coll2 (ingest-access-value-collection "coll2" 4)
-         ;; one with a higher access value
-         coll3 (ingest-access-value-collection "coll3" 9)
-         ;; and one with no access value
-         coll4 (ingest-access-value-collection "coll4" nil)
-         create-acl #(:concept_id (ac/create-acl (u/conn-context) % {:token token}))
-         update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})
-         get-coll-permissions #(get-permissions :guest coll1 coll2 coll3 coll4)]
-     (u/wait-until-indexed)
-
-     (testing "no permissions granted"
-       (is (= {"C1200000000-PROV1" []
-               "C1200000001-PROV1" []
-               "C1200000002-PROV1" []
-               "C1200000003-PROV1" []}
-              (get-coll-permissions))))
-
-     (let [acl-id (create-acl
-                    {:group_permissions [{:permissions [:read]
-                                          :user_type :guest}]
-                     :catalog_item_identity {:name "coll2 guest read"
-                                             :collection_applicable true
-                                             :collection_identifier {:access_value {:min_value 1 :max_value 10}}
-                                             :provider_id "PROV1"}})]
-
-       (testing "ACL matching all access values"
-         (is (= {"C1200000000-PROV1" ["read"]
-                 "C1200000001-PROV1" ["read"]
-                 "C1200000002-PROV1" ["read"]
-                 "C1200000003-PROV1" []}
-                (get-coll-permissions))))
-
-       (testing "ACL matching only high access values"
-         (update-acl acl-id {:group_permissions [{:permissions [:read]
-                                                  :user_type :guest}]
-                             :catalog_item_identity {:name "coll2 guest read"
-                                                     :collection_applicable true
-                                                     :collection_identifier {:access_value {:min_value 4 :max_value 10}}
-                                                     :provider_id "PROV1"}})
-
-         (is (= {"C1200000000-PROV1" []
-                 "C1200000001-PROV1" ["read"]
-                 "C1200000002-PROV1" ["read"]
-                 "C1200000003-PROV1" []}
-                (get-coll-permissions))))
-
-       (testing "ACL matching only one access value"
-         (update-acl acl-id {:group_permissions [{:permissions [:read]
-                                                  :user_type :guest}]
-                             :catalog_item_identity {:name "coll2 guest read"
-                                                     :collection_applicable true
-                                                     :collection_identifier {:access_value {:min_value 4 :max_value 5}}
-                                                     :provider_id "PROV1"}})
-
-         (is (= {"C1200000000-PROV1" []
-                 "C1200000001-PROV1" ["read"]
-                 "C1200000002-PROV1" []
-                 "C1200000003-PROV1" []}
-                (get-coll-permissions))))
-
-       (testing "ACL matching only collections with undefined access values"
-         (update-acl acl-id {:group_permissions [{:permissions [:read]
-                                                  :user_type :guest}]
-                             :catalog_item_identity {:name "coll2 guest read"
-                                                     :collection_applicable true
-                                                     :collection_identifier {:access_value {:min_value 1
-                                                                                :max_value 10
-                                                                                :include_undefined_value true}}
-                                                     :provider_id "PROV1"}})
-
-         (is (= {"C1200000000-PROV1" ["read"]
-                 "C1200000001-PROV1" ["read"]
-                 "C1200000002-PROV1" ["read"]
-                 "C1200000003-PROV1" ["read"]}
-                (get-coll-permissions)))))))
-
- (deftest collection-catalog-item-identifier-temporal-test
-   ;; tests ACLs that grant access based on a collection's temporal range
-   (let [token (e/login (u/conn-context) "user1" [])
-         ingest-temporal-collection (fn [short-name start-year end-year]
-                                      (u/ingest-collection token {:entry-title (str short-name " entry title")
-                                                                :short-name short-name
-                                                                :native-id short-name
-                                                                :provider-id "PROV1"
-                                                                :temporal-range {:BeginningDateTime (t/date-time start-year)
-                                                                                :EndingDateTime (t/date-time end-year)}}))
-         coll1 (ingest-temporal-collection "coll1" 2001 2002)
-         coll2 (ingest-temporal-collection "coll2" 2004 2005)
-         coll3 (ingest-temporal-collection "coll3" 2007 2009)
-         ;; coll4 will have no temporal extent, and should not be granted any permissions by our ACLs in this test
-         coll4 (u/ingest-collection token {:entry-id "coll4"
-                                         :native-id "coll4"
-                                         :short-name "coll4"
-                                         :entry-title "non-temporal coll4"
-                                         :provider-id "PROV1"
-                                         :no-temporal true})
-         create-acl #(:concept_id (ac/create-acl (u/conn-context) % {:token token}))
-         update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})
-         get-coll-permissions #(get-permissions :guest coll1 coll2 coll3 coll4)]
-     (u/wait-until-indexed)
-     (is (= {"C1200000000-PROV1" []
-             "C1200000001-PROV1" []
-             "C1200000002-PROV1" []
-             "C1200000003-PROV1" []}
-            (get-coll-permissions)))
-
-     (let [acl-id (create-acl
-                    {:group_permissions [{:permissions [:read]
-                                          :user_type :guest}]
-                     :catalog_item_identity {:name "coll2 guest read"
-                                             :collection_applicable true
-                                             :collection_identifier {:temporal {:start_date "2000-01-01T00:00:00Z"
-                                                                                :end_date "2010-01-01T00:00:00Z"
-                                                                                :mask "intersect"}}
-                                             :provider_id "PROV1"}})]
-
-       (testing "\"intersect\" mask"
-         (is (= {"C1200000000-PROV1" ["read"]
-                 "C1200000001-PROV1" ["read"]
-                 "C1200000002-PROV1" ["read"]
-                 "C1200000003-PROV1" []}
-                (get-coll-permissions))))
-
-       (testing "\"disjoint\" mask"
-         (update-acl acl-id {:group_permissions [{:permissions [:read]
-                                                  :user_type :guest}]
-                             :catalog_item_identity {:name "coll2 guest read"
-                                                     :collection_applicable true
-                                                     :collection_identifier {:temporal {:start_date "2003-01-01T00:00:00Z"
-                                                                                :end_date "2006-01-01T00:00:00Z"
-                                                                                :mask "disjoint"}}
-                                                     :provider_id "PROV1"}})
-         (is (= {"C1200000000-PROV1" ["read"]
-                 "C1200000001-PROV1" []
-                 "C1200000002-PROV1" ["read"]
-                 "C1200000003-PROV1" []}
-                (get-coll-permissions))))
-
-       (testing "\"contains\" mask"
-         (update-acl acl-id {:group_permissions [{:permissions [:read]
-                                                  :user_type :guest}]
-                             :catalog_item_identity {:name "coll2 guest read"
-                                                     :collection_applicable true
-                                                     :collection_identifier {:temporal {:start_date "2003-01-01T00:00:00Z"
-                                                                                :end_date "2006-01-01T00:00:00Z"
-                                                                                :mask "contains"}}
-                                                     :provider_id "PROV1"}})
-         (is (= {"C1200000000-PROV1" []
-                 "C1200000001-PROV1" ["read"]
-                 "C1200000002-PROV1" []
-                 "C1200000003-PROV1" []}
-                (get-coll-permissions)))))))
-
- ;; For CMR-3210:
- ;; * granule provider permissions (read/order) for guest, registered, and groups
- ;; * granule specific permissions (update/delete) for guest, registered, and groups
- ;; * granule permissions based on access value
- ;; * granule permissions based on temporal
- ;; * granule permissions applied for collection applicable false??? <-- ask Jason
-
- (deftest collection-provider-level-permission-check-test
-   ;; Tests ACLs which grant the provider-level update/delete permissions to collections
-   (let [token (e/login (u/conn-context) "user1" ["group-create-group"])
-         ;; then create a group that contains our user, so we can find collections that grant access to this user
-         group (u/make-group {:name "groupwithuser1" :members ["user1"]})
-         created-group-concept-id (:concept_id (u/create-group token group))
-         ;; create some collections
-         coll1-umm (assoc example-collection-record :EntryTitle "coll1 entry title")
-         coll1-metadata (umm-spec/generate-metadata (u/conn-context) coll1-umm :echo10)
-         coll1 (u/ingest-collection token {:provider-id "PROV1"
-                                         :entry-title "coll1"
-                                         :native-id "coll1"
-                                         :short-name "coll1"})
-         ;; local helpers to make the body of the test cleaner
-         create-acl #(ac/create-acl (u/conn-context) % {:token token})
-         update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})
-         get-coll1-permissions #(get-permissions % coll1)]
-
-     (testing "no permissions granted"
-       (are [user permissions]
-         (= {"C1200000001-PROV1" permissions}
-            (get-coll1-permissions user))
-         :guest []
-         :registered []
-         "user1" []))
-
-     (testing "provider level permissions"
-       (let [acl {:group_permissions [{:permissions [:update :delete]
-                                       :user_type :guest}]
-                  :provider_identity {:provider_id "PROV1"
-                                      :target "INGEST_MANAGEMENT_ACL"}}
-             acl-concept-id (:concept_id (create-acl acl))]
-         (u/wait-until-indexed)
-
-         (are [user permissions]
-           (= {"C1200000001-PROV1" permissions}
-              (get-coll1-permissions user))
-           :guest ["update" "delete"]
-           :registered []
-           "user1" [])
-
-         (testing "granted to registered users"
-           (update-acl acl-concept-id
-                       {:group_permissions [{:permissions [:update :delete]
-                                             :user_type :registered}]
-                        :provider_identity {:provider_id "PROV1"
-                                            :target "INGEST_MANAGEMENT_ACL"}})
-
-           (are [user permissions]
-             (= {"C1200000001-PROV1" permissions}
-                (get-coll1-permissions user))
-             :guest []
-             :registered ["update" "delete"]
-             "user1" ["update" "delete"]))
-
-         (testing "granted to specific groups"
-           (update-acl acl-concept-id
-                       {:group_permissions [{:permissions [:update :delete]
-                                             :group_id created-group-concept-id}]
-                        :provider_identity {:provider_id "PROV1"
-                                            :target "INGEST_MANAGEMENT_ACL"}})
-
-           (are [user permissions]
-             (= {"C1200000001-PROV1" permissions}
-                (get-coll1-permissions user))
-             :guest []
-             :registered []
-             "user1" ["update" "delete"]
-             "user2" []))))))
+
+        (is (= {"C1200000000-PROV1" []
+                "C1200000001-PROV1" ["read"]
+                "C1200000002-PROV1" ["read"]
+                "C1200000003-PROV1" []}
+               (get-coll-permissions))))
+
+      (testing "ACL matching only one access value"
+        (update-acl acl-id {:group_permissions [{:permissions [:read]
+                                                 :user_type :guest}]
+                            :catalog_item_identity {:name "coll2 guest read"
+                                                    :collection_applicable true
+                                                    :collection_identifier {:access_value {:min_value 4 :max_value 5}}
+                                                    :provider_id "PROV1"}})
+
+        (is (= {"C1200000000-PROV1" []
+                "C1200000001-PROV1" ["read"]
+                "C1200000002-PROV1" []
+                "C1200000003-PROV1" []}
+               (get-coll-permissions))))
+
+      (testing "ACL matching only collections with undefined access values"
+        (update-acl acl-id {:group_permissions [{:permissions [:read]
+                                                 :user_type :guest}]
+                            :catalog_item_identity {:name "coll2 guest read"
+                                                    :collection_applicable true
+                                                    :collection_identifier {:access_value {:min_value 1
+                                                                                :max_value 10
+                                                                                :include_undefined_value true}}
+                                                    :provider_id "PROV1"}})
+
+        (is (= {"C1200000000-PROV1" ["read"]
+                "C1200000001-PROV1" ["read"]
+                "C1200000002-PROV1" ["read"]
+                "C1200000003-PROV1" ["read"]}
+               (get-coll-permissions)))))))
+
+(deftest collection-catalog-item-identifier-temporal-test
+  ;; tests ACLs that grant access based on a collection's temporal range
+  (let [token (e/login (u/conn-context) "user1" [])
+        ingest-temporal-collection (fn [short-name start-year end-year]
+                                     (u/ingest-collection token {:entry-title (str short-name " entry title")
+                                                                 :short-name short-name
+                                                                 :native-id short-name
+                                                                 :provider-id "PROV1"
+                                                                 :temporal-range {:BeginningDateTime (t/date-time start-year)
+                                                                                :EndingDateTime (t/date-time end-year)}}))
+        coll1 (ingest-temporal-collection "coll1" 2001 2002)
+        coll2 (ingest-temporal-collection "coll2" 2004 2005)
+        coll3 (ingest-temporal-collection "coll3" 2007 2009)
+        ;; coll4 will have no temporal extent, and should not be granted any permissions by our ACLs in this test
+        coll4 (u/ingest-collection token {:entry-id "coll4"
+                                          :native-id "coll4"
+                                          :short-name "coll4"
+                                          :entry-title "non-temporal coll4"
+                                          :provider-id "PROV1"
+                                          :no-temporal true})
+        create-acl #(:concept_id (ac/create-acl (u/conn-context) % {:token token}))
+        update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})
+        get-coll-permissions #(get-permissions :guest coll1 coll2 coll3 coll4)]
+    (u/wait-until-indexed)
+    (is (= {"C1200000000-PROV1" []
+            "C1200000001-PROV1" []
+            "C1200000002-PROV1" []
+            "C1200000003-PROV1" []}
+           (get-coll-permissions)))
+
+    (let [acl-id (create-acl
+                   {:group_permissions [{:permissions [:read]
+                                         :user_type :guest}]
+                    :catalog_item_identity {:name "coll2 guest read"
+                                            :collection_applicable true
+                                            :collection_identifier {:temporal {:start_date "2000-01-01T00:00:00Z"
+                                                                               :end_date "2010-01-01T00:00:00Z"
+                                                                               :mask "intersect"}}
+                                            :provider_id "PROV1"}})]
+
+      (testing "\"intersect\" mask"
+        (is (= {"C1200000000-PROV1" ["read"]
+                "C1200000001-PROV1" ["read"]
+                "C1200000002-PROV1" ["read"]
+                "C1200000003-PROV1" []}
+               (get-coll-permissions))))
+
+      (testing "\"disjoint\" mask"
+        (update-acl acl-id {:group_permissions [{:permissions [:read]
+                                                 :user_type :guest}]
+                            :catalog_item_identity {:name "coll2 guest read"
+                                                    :collection_applicable true
+                                                    :collection_identifier {:temporal {:start_date "2003-01-01T00:00:00Z"
+                                                                                :end_date "2006-01-01T00:00:00Z"
+                                                                                :mask "disjoint"}}
+                                                    :provider_id "PROV1"}})
+        (is (= {"C1200000000-PROV1" ["read"]
+                "C1200000001-PROV1" []
+                "C1200000002-PROV1" ["read"]
+                "C1200000003-PROV1" []}
+               (get-coll-permissions))))
+
+      (testing "\"contains\" mask"
+        (update-acl acl-id {:group_permissions [{:permissions [:read]
+                                                 :user_type :guest}]
+                            :catalog_item_identity {:name "coll2 guest read"
+                                                    :collection_applicable true
+                                                    :collection_identifier {:temporal {:start_date "2003-01-01T00:00:00Z"
+                                                                                :end_date "2006-01-01T00:00:00Z"
+                                                                                :mask "contains"}}
+                                                    :provider_id "PROV1"}})
+        (is (= {"C1200000000-PROV1" []
+                "C1200000001-PROV1" ["read"]
+                "C1200000002-PROV1" []
+                "C1200000003-PROV1" []}
+               (get-coll-permissions)))))))
+
+;; For CMR-3210:
+;; * granule provider permissions (read/order) for guest, registered, and groups
+;; * granule specific permissions (update/delete) for guest, registered, and groups
+;; * granule permissions based on access value
+;; * granule permissions based on temporal
+;; * granule permissions applied for collection applicable false??? <-- ask Jason
+
+(deftest collection-provider-level-permission-check-test
+  ;; Tests ACLs which grant the provider-level update/delete permissions to collections
+  (let [token (e/login (u/conn-context) "user1" ["group-create-group"])
+        ;; then create a group that contains our user, so we can find collections that grant access to this user
+        group (u/make-group {:name "groupwithuser1" :members ["user1"]})
+        created-group-concept-id (:concept_id (u/create-group token group))
+        ;; create some collections
+        coll1-umm (assoc example-collection-record :EntryTitle "coll1 entry title")
+        coll1-metadata (umm-spec/generate-metadata (u/conn-context) coll1-umm :echo10)
+        coll1 (u/ingest-collection token {:provider-id "PROV1"
+                                          :entry-title "coll1"
+                                          :native-id "coll1"
+                                          :short-name "coll1"})
+        ;; local helpers to make the body of the test cleaner
+        create-acl #(ac/create-acl (u/conn-context) % {:token token})
+        update-acl #(ac/update-acl (u/conn-context) %1 %2 {:token token})
+        get-coll1-permissions #(get-permissions % coll1)]
+
+    (testing "no permissions granted"
+      (are [user permissions]
+        (= {"C1200000001-PROV1" permissions}
+           (get-coll1-permissions user))
+        :guest []
+        :registered []
+        "user1" []))
+
+    (testing "provider level permissions"
+      (let [acl {:group_permissions [{:permissions [:update :delete]
+                                      :user_type :guest}]
+                 :provider_identity {:provider_id "PROV1"
+                                     :target "INGEST_MANAGEMENT_ACL"}}
+            acl-concept-id (:concept_id (create-acl acl))]
+        (u/wait-until-indexed)
+
+        (are [user permissions]
+          (= {"C1200000001-PROV1" permissions}
+             (get-coll1-permissions user))
+          :guest ["update" "delete"]
+          :registered []
+          "user1" [])
+
+        (testing "granted to registered users"
+          (update-acl acl-concept-id
+                      {:group_permissions [{:permissions [:update :delete]
+                                            :user_type :registered}]
+                       :provider_identity {:provider_id "PROV1"
+                                           :target "INGEST_MANAGEMENT_ACL"}})
+
+          (are [user permissions]
+            (= {"C1200000001-PROV1" permissions}
+               (get-coll1-permissions user))
+            :guest []
+            :registered ["update" "delete"]
+            "user1" ["update" "delete"]))
+
+        (testing "granted to specific groups"
+          (update-acl acl-concept-id
+                      {:group_permissions [{:permissions [:update :delete]
+                                            :group_id created-group-concept-id}]
+                       :provider_identity {:provider_id "PROV1"
+                                           :target "INGEST_MANAGEMENT_ACL"}})
+
+          (are [user permissions]
+            (= {"C1200000001-PROV1" permissions}
+               (get-coll1-permissions user))
+            :guest []
+            :registered []
+            "user1" ["update" "delete"]
+            "user2" []))))))


Removed unused function.

Removed unused function.

--- src/cmr/opendap/rest/middleware.clj
+++ src/cmr/opendap/rest/middleware.clj
@@ -134,10 +134,3 @@
   For more details, see the docstring above for `wrap-auth`."
   {:data
     {:middleware [#(wrap-auth % system)]}})
-
-
-(defn manager
-  ""
-  [handler system]
-  (fn [request]
-    ))


Updated mongo safe high function to be more general and return last error information

--- src/leiningen/new/cljskel/setup.clj
+++ src/leiningen/new/cljskel/setup.clj
@@ -128,25 +128,40 @@
     true
     (catch Exception e (warn e) false)))

+(defn get-last-error [db concern]
+  (let [last-error (.getLastError (mc/get-db) concern)]
+    {:server-used (.toString (.get last-error "serverUsed"))
+     :ok (.ok last-error)
+     :updated-existing (.get last-error "updatedExisting")
+     :n (.get last-error "n")
+     :connection-id (.get last-error "connectionId")
+     :wtime (.get last-error "wtime")
+     :error-message (.getErrorMessage last-error)
+     :exception (.getException last-error)}))
+
 (defn write-error-message [concern error]
-  (format  "Write concern %s was not met within %dms, mongo error message: %s"
+  (format "Write concern %s was not met within %dms, mongo error message: %s"
            (.getWString concern) (.getWtimeout concern) (.getErrorMessage error)))

-(defn get-if-error [concern]
-  (let [cmd-res (.getLastError (mc/get-db) concern)]
-    (if (not (.ok cmd-res))
-      cmd-res)))
+(defn throw-mongo-excep [error-msg]
+  (throw (MongoException. error-msg)))
+
+(defn check-write-concern [concern fail-func]
+  (let [last-error (get-last-error (mc/get-db) concern)]
+    (if (:ok last-error)
+      last-error
+      (fail-func (write-error-message concern last-error)))))

 (defn check-write-concerns []
-  (if-let [desired-error (get-if-error @desired-concern)]
-    (do (warn (write-error-message @desired-concern desired-error))
-        (if-let [required-error (get-if-error @required-concern)]
-          (throw (MongoException. (write-error-message @required-concern required-error)))))))
+  (if-let [first-success (check-write-concern @desired-concern #(warn %))]
+    first-success
+    (if-let [second-success (check-write-concern @required-concern throw-mongo-excep)]
+      second-success)))

-(defn safe-insert [coll doc]
-  (let [db (mc/get-db)]
-    (try
-      (do (.requestEnsureConnection db)
-       (mco/insert coll doc)
-       (check-write-concerns))
-      (finally (.requestDone db)))))
+(defn perform-safe [mongo-call]
+  (let [db (monger.core/get-db)]
+     (try
+       (do (.requestEnsureConnection db)
+           (mongo-call)
+           (inbox.setup/check-write-concerns))
+       (finally (.requestDone db)))))


Extend repl code to allow for incomplete counterexamples

Signed-off-by: Daniel Borchmann <25857343a15bf1edafebc2912e82ecf775c585c1@mailbox.tu-dresden.de>

--- src/conexp/fca/exploration/repl.clj
+++ src/conexp/fca/exploration/repl.clj
@@ -36,8 +36,8 @@
             (remove #{:default} (keys (methods run-repl-command))))))

 (defn- eval-command
-  "Runs the given REPL command query with state, context ctx and
-  implication impl."
+  "Runs the given REPL command query with state, in the case the query uniquely determines
+  a command.  If not, an error message is printed and state is returned."
   [query state]
   (if (= query 'abort)
     (throw (Exception. "Abnormal abortion from attribute exploration"))
@@ -61,12 +61,15 @@
            (println t)
            state))))))

+;;
+
 (defn counterexample-via-repl
-  "Starts a repl for counterexamples."
+  "Starts a repl for counterexamples, which must be specified completely."
   [ctx knowledge impl]
   (loop [state {:context ctx,
                 :knowledge knowledge,
-                :implication impl}]
+                :implication impl
+                :complete-counterexamples? true}]
     (let [query  (ask "counterexample> "
                       #(read-string (str (read-line)))
                       (constantly true)
@@ -76,12 +79,34 @@
         (recur result)
         [(:object state) (set (:positives state))]))))

+(defn incomplete-counterexample-via-repl
+  "Starts a repl for counterexamples, which may be incomplete."
+  [possible-ctx certain-ctx knowledge impl]
+  (loop [state {:possible-context possible-ctx,
+                :certain-context certain-ctx,
+                :knowledge knowledge,
+                :implication impl
+                :complete-counterexamples? false}]
+    (let [query  (ask "counterexample> "
+                      #(read-string (str (read-line)))
+                      (constantly true)
+                      "counterexample> "),
+          result (eval-command query state)]
+      (if result
+        (recur result)
+        [(:object state) (set (:positives state)) (set (:negatives state))]))))
+
+;; REPL commands
+
 (defmacro- define-repl-fn [name doc & body]
   `(do
      (defmethod run-repl-command '~name
        ~'[_ state]
-       (let [~'ctx  (:context ~'state),
-             ~'impl (:implication ~'state)]
+       (let [~'objects    (objects (or (:context ~'state)
+                                       (:possible-context ~'state)))
+             ~'attributes (attributes (or (:context ~'state)
+                                          (:possible-context ~'state))),
+             ~'impl       (:implication ~'state)]
          ~@body))
      (defmethod help-repl-command '~name
        ~'[_]
@@ -92,25 +117,25 @@
   (assoc state :object
          (ask (str "Please enter new object: ")
               #(read-string (str (read-line)))
-              #(not (contains? (objects ctx) %))
+              #(not (contains? objects %))
               "This object is already present, please enter a new one: ")))

 (define-repl-fn attributes
   "Enter all attributes the object has."
   (let [new-attributes (ask (str "Please enter the attributes the new object should have: ")
                             #(read-string (str "#{" (read-line) "}"))
-                            #(subset? % (attributes ctx))
+                            #(subset? % attributes)
                             (str "The attributes have to be present in the given context.\n"
                                  "Please enter new attributes: "))]
     (-> state
         (assoc :positives new-attributes)
-        (assoc :negatives (difference (attributes ctx) new-attributes)))))
+        (assoc :negatives (difference attributes new-attributes)))))

 (define-repl-fn positives
   "Give some attributes the object definitively has."
   (let [positives (ask (str "Please enter attributes the new object definitively has: ")
                        #(read-string (str "#{" (read-line) "}"))
-                       #(and (subset? % (attributes ctx))
+                       #(and (subset? % attributes)
                              (not (exists [m (:negatives state)]
                                     (contains? % m))))
                        (str "The attributes are invalid or already marked as negative.\n"
@@ -121,7 +146,7 @@
   "Give some attributes the object definitively has not."
   (let [negatives (ask (str "Please enter attributes the new object definitively has not: ")
                        #(read-string (str "#{" (read-line) "}"))
-                       #(and (subset? % (attributes ctx))
+                       #(and (subset? % attributes)
                              (not (exists [m (:positives state)]
                                     (contains? % m))))
                        (str "The attributes are invalid or already marked as positive.\n"
@@ -130,7 +155,7 @@

 (define-repl-fn complete-example
   "Adds all attributes, which are not positive, to the negatives."
-  (let [non-pos (difference (attributes ctx) (set (:positives state)))]
+  (let [non-pos (difference attributes (set (:positives state)))]
     (assoc state :negatives non-pos)))

 (define-repl-fn saturate-partial-example
@@ -140,7 +165,7 @@
         [pos neg] (saturate-partial-example (:knowledge state)
                                             old-pos
                                             old-neg
-                                            (difference (attributes ctx)
+                                            (difference attributes
                                                         old-pos
                                                         old-neg))]
     (-> state
@@ -149,13 +174,14 @@

 (defn- valid-counterexample?
   "Checks the given example for being valid."
-  [state ctx impl]
+  [state attributes impl]
   (let [new-atts    (union (set (:positives state)) (set (:negatives state))),
         return      (atom true)]
     (when-not (contains? state :object),
       (println "You need to set a name for the new object.")
       (reset! return false))
-    (when-not (= (attributes ctx) new-atts)
+    (when (and (:complete-counterexamples? state)
+               (not= attributes new-atts))
       (println "You have not specified a complete counterexample.")
       (reset! return false))
     (let [not-respected (filter (fn [impl]
@@ -173,12 +199,12 @@

 (define-repl-fn check-counterexample
   "Checks the given counterexample for being valid."
-  (valid-counterexample? state ctx impl)
+  (valid-counterexample? state attributes impl)
   state)

 (define-repl-fn quit
   "Quit the REPL, if the given counterexample is valid."
-  (if (valid-counterexample? state ctx impl)
+  (if (valid-counterexample? state attributes impl)
     nil
     state))

@@ -203,7 +229,11 @@

 (define-repl-fn context
   "Prints the current context."
-  (println ctx)
+  (if (:context state)
+    (println (:context state))
+    (do
+      (println (:possible-context state))
+      (println (:certain-context state))))
   state)

 (define-repl-fn knowledge


fix error in commit 6098470

fix error in commit 6098470

Stacktrace:
```
Caused by: clojure.lang.ArityException: Wrong number of args (1) passed to: core/get-in
	at clojure.lang.AFn.throwArity(AFn.java:429)
	at clojure.lang.AFn.invoke(AFn.java:32)
	at github_bot_app.action.auto_label$run_action.invokeStatic(auto_label.clj:65)
	at github_bot_app.action.auto_label$run_action.invoke(auto_label.clj:29)
```

--- src/github_bot_app/action/auto_label.clj
+++ src/github_bot_app/action/auto_label.clj
@@ -62,7 +62,7 @@
    (and (= event
            "pull_request_review")
         (= (:action payload) "submitted")
-        (= (get-in [:review :state]) "approved"))
+        (= (get-in payload [:review :state]) "approved"))
    (let [issue-user (get-in payload [:issue :user :login])
          review-user (get-in payload [:review :user :login])]
     (when (not (= issue-user review-user))


Removed old propagate  denotesSubClassOf rule

--- resources/rules/post_identifier_merge/entity/type/propigate_denotesSubClassOf.clj
+++ resources/rules/post_identifier_merge/entity/type/propigate_denotesSubClassOf.clj
@@ -1,6 +0,0 @@
-;; ice identifiers have relations that attempt to encode type
-;;   this rule propigates those types onto the actualy entities
-`{:name "propigate-denotesSubClassOf"
-  :head ((?/entity rdfs/subClassOf ?/sc))
-  :body ((_/ice kiao/denotesSubClassOf ?/sc)
-         (_/ice obo/IAO_0000219 ?/entity))} ; denotes


DSDEEPB-2393: Fix ordering bug

DSDEEPB-2393: Fix ordering bug

--- src/cljs/org/broadinstitute/firecloud_ui/page/workspace/data/entity_selector.cljs
+++ src/cljs/org/broadinstitute/firecloud_ui/page/workspace/data/entity_selector.cljs
@@ -34,7 +34,7 @@
                         {:header "Entity Name" :starting-width 200
                          :as-text #(get-in % [0 "name"]) :sort-by :text
                          :content-renderer
-                         (fn [[entity index]]
+                         (fn [[index entity]]
                            (style/create-link {:text (entity "name")
                                                :onClick #(swap! state update-in [:selected]
                                                            (if source? conj disj) index)}))}]
@@ -48,14 +48,14 @@
                          attribute-keys)))
            data (fn [source?]
                   (replace
-                    (into [] (zipmap (range) (:entities props)))
+                    (mapv vector (range) (:entities props))
                     (if source?
                       (difference (-> (:entities props) count range set) (:selected @state))
                       (:selected @state))))
-           ->row (fn [[index entity]]
+           ->row (fn [[index entity :as item]]
                    (concat
                      [(entity "entityType")
-                      [entity index]]
+                      item]
                      (map (fn [k] (get-in entity ["attributes" k])) attribute-keys)))
            create-table (fn [source?]
                           [:div {:style {:float (if source? "left" "right") :width box-width


RS | 99 | cljs: register-form integration tests are now independent of each other using clean-setup

--- test-cljs/stonecutter/test/integration/register_form.cljs
+++ test-cljs/stonecutter/test/integration/register_form.cljs
@@ -11,9 +11,6 @@

 (defonce index-page-template (load-template "public/index.html"))

-(defn setup-index-page! []
-  (tu/set-html! index-page-template))
-
 (def email-of-length-255
   (str (tu/string-of-length 251) "@x.y"))

@@ -28,38 +25,49 @@
 (def too-short-password "short")
 (def too-long-password (tu/string-of-length 255))

+(defn reset-registration-form-atom! []
+  (reset! app/registration-form-state rfc/default-state))
+
+(defn clean-setup! []
+  (tu/set-html! index-page-template)
+  (app/start)
+  (reset-registration-form-atom!))
+
 (defn invalid-password-state! []
+  (clean-setup!)
   (tu/enter-text (rfd/input-selector :registration-password) blank-string)
   (tu/lose-focus (rfd/input-selector :registration-password)))

 (deftest on-input
-         (setup-index-page!)
-         (app/start)
          (testing "inputing text in first name field will cause field invalid class to disappear"
+                  (clean-setup!)
                   (dom/add-class! (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
                   (tu/enter-text (rfd/input-selector :registration-first-name) valid-name)
                   (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class))
          (testing "inputing text in last name field will cause field invalid class to disappear"
+                  (clean-setup!)
                   (dom/add-class! (rfd/form-row-selector :registration-last-name) rfd/field-invalid-class)
                   (tu/enter-text (rfd/input-selector :registration-last-name) valid-name)
                   (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-last-name) rfd/field-invalid-class))
          (testing "inputing text in email address field will cause field invalid class to disappear"
+                  (clean-setup!)
                   (dom/add-class! (rfd/form-row-selector :registration-email) rfd/field-invalid-class)
                   (tu/enter-text (rfd/input-selector :registration-email) valid-email)
                   (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-email) rfd/field-invalid-class))

          (testing "password"
                   (testing "- inputing valid password causes field valid class to appear"
-                           (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-password) rfd/field-valid-class)
+                           (clean-setup!)
                            (tu/enter-text (rfd/input-selector :registration-password) valid-password)
                            (tu/test-field-has-class (rfd/form-row-selector :registration-password) rfd/field-valid-class))
                   (testing "- from valid password to invalid password causes field valid class to disappear"
-                           (tu/test-field-has-class (rfd/form-row-selector :registration-password) rfd/field-valid-class)
+                           (clean-setup!)
+                           (dom/add-class! (rfd/form-row-selector :registration-password) rfd/field-valid-class)
                            (tu/enter-text (rfd/input-selector :registration-password) too-short-password)
                            (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-password) rfd/field-valid-class))
                   (testing "- from invalid password to valid password causes field valid class to appear and field invalid class to disappear"
+                           (clean-setup!)
                            (dom/add-class! (rfd/form-row-selector :registration-password) rfd/field-invalid-class)
-                           (dom/remove-class! (rfd/form-row-selector :registration-password) rfd/field-valid-class)
                            (tu/enter-text (rfd/input-selector :registration-password) valid-password)
                            (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-password) rfd/field-invalid-class)
                            (tu/test-field-has-class (rfd/form-row-selector :registration-password) rfd/field-valid-class))
@@ -92,49 +100,46 @@

 (deftest losing-focus
-         (setup-index-page!)
-         (app/start)
-
          (testing "first-name"
                   (testing "- losing focus when blank adds invalid field class and validation message"
+                           (clean-setup!)
                            (tu/lose-focus (rfd/input-selector :registration-first-name))
-                           (check-first-name-has-blank-validation-errors)))
-
-         (testing "- losing focus when too-long adds invalid field class and validation message"
-                  (tu/set-value (rfd/input-selector :registration-first-name) too-long-name)
-                  (tu/lose-focus (rfd/input-selector :registration-first-name))
-                  (tu/test-field-has-class (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
-                  (tu/element-has-text (rfd/validation-selector :registration-first-name)
-                                         (get-in dom/translations [:index :register-first-name-too-long-validation-message])))
-
-         (testing "- losing focus when valid removes invalid field class and validation message"
-                  (tu/test-field-has-class (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
-                  (tu/element-has-text (rfd/validation-selector :registration-first-name)
-                                         (get-in dom/translations [:index :register-first-name-too-long-validation-message]))
-
-                  (tu/set-value (rfd/input-selector :registration-first-name) valid-name)
-                  (tu/lose-focus (rfd/input-selector :registration-first-name))
-
-                  (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
-                  (tu/element-has-no-text (rfd/validation-selector :registration-first-name)))
+                           (check-first-name-has-blank-validation-errors))
+
+                  (testing "- losing focus when too-long adds invalid field class and validation message"
+                           (clean-setup!)
+                           (tu/set-value (rfd/input-selector :registration-first-name) too-long-name)
+                           (tu/lose-focus (rfd/input-selector :registration-first-name))
+                           (tu/test-field-has-class (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
+                           (tu/element-has-text (rfd/validation-selector :registration-first-name)
+                                                (get-in dom/translations [:index :register-first-name-too-long-validation-message])))
+
+                  (testing "- losing focus when valid removes invalid field class and there is novalidation message"
+                           (clean-setup!)
+                           (dom/add-class! (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
+                           (tu/set-value (rfd/input-selector :registration-first-name) valid-name)
+                           (tu/lose-focus (rfd/input-selector :registration-first-name))
+
+                           (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
+                           (tu/element-has-no-text (rfd/validation-selector :registration-first-name))))

          (testing "last-name"
                   (testing "- losing focus when blank adds invalid field class and validation message"
+                           (clean-setup!)
                            (tu/lose-focus (rfd/input-selector :registration-last-name))
                            (check-last-name-has-blank-validation-errors))

                   (testing "- losing focus when too-long adds invalid field class and validation message"
+                           (clean-setup!)
                            (tu/set-value (rfd/input-selector :registration-last-name) too-long-name)
                            (tu/lose-focus (rfd/input-selector :registration-last-name))
                            (tu/test-field-has-class (rfd/form-row-selector :registration-last-name) rfd/field-invalid-class)
                            (tu/element-has-text (rfd/validation-selector :registration-last-name)
                                                   (get-in dom/translations [:index :register-last-name-too-long-validation-message])))

-                  (testing "- losing focus when valid removes invalid field class and validation message"
-                           (tu/test-field-has-class (rfd/form-row-selector :registration-last-name) rfd/field-invalid-class)
-                           (tu/element-has-text (rfd/validation-selector :registration-last-name)
-                                                  (get-in dom/translations [:index :register-last-name-too-long-validation-message]))
-
+                  (testing "- losing focus when valid removes invalid field class and there is no validation message"
+                           (clean-setup!)
+                           (dom/add-class! (rfd/form-row-selector :registration-last-name) rfd/field-invalid-class)
                            (tu/set-value (rfd/input-selector :registration-last-name) valid-name)
                            (tu/lose-focus (rfd/input-selector :registration-last-name))

@@ -143,36 +148,36 @@

          (testing "email-address"
                   (testing "- losing focus when invalid adds invalid field class and validation message"
+                           (clean-setup!)
                            (tu/set-value (rfd/input-selector :registration-email) invalid-email)
                            (tu/lose-focus (rfd/input-selector :registration-email))
                            (check-email-address-has-invalid-validation-errors))

                   (testing "- losing focus when too-long adds invalid field class and validation message"
+                           (clean-setup!)
                            (tu/set-value (rfd/input-selector :registration-email) too-long-email)
                            (tu/lose-focus (rfd/input-selector :registration-email))
                            (tu/test-field-has-class (rfd/form-row-selector :registration-email) rfd/field-invalid-class)
                            (tu/element-has-text (rfd/validation-selector :registration-email)
                                                   (get-in dom/translations [:index :register-email-address-too-long-validation-message])))

-                  (testing "- losing focus when valid removes invalid field class and validation message"
-                           (tu/test-field-has-class (rfd/form-row-selector :registration-email) rfd/field-invalid-class)
-                           (tu/element-has-text (rfd/validation-selector :registration-email)
-                                                  (get-in dom/translations [:index :register-email-address-too-long-validation-message]))
-
+                  (testing "- losing focus when valid removes invalid field class and there is no validation message"
+                           (clean-setup!)
+                           (dom/add-class! (rfd/form-row-selector :registration-email) rfd/field-invalid-class)
                            (tu/set-value (rfd/input-selector :registration-email) valid-email)
                            (tu/lose-focus (rfd/input-selector :registration-email))

                            (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-email) rfd/field-invalid-class)
                            (tu/element-has-no-text (rfd/validation-selector :registration-email))))

-
-
          (testing "password"
                   (testing "- losing focus when blank adds invalid field class and validation message"
+                           (clean-setup!)
                            (tu/lose-focus (rfd/input-selector :registration-password))
                            (check-password-has-blank-validation-errors))

                   (testing "- losing focus when too short adds invalid field class and validation message"
+                           (clean-setup!)
                            (tu/set-value (rfd/input-selector :registration-password) too-short-password)
                            (tu/lose-focus (rfd/input-selector :registration-password))
                            (tu/test-field-has-class (rfd/form-row-selector :registration-password) rfd/field-invalid-class)
@@ -180,17 +185,16 @@
                                                   (get-in dom/translations [:index :register-password-too-short-validation-message])))

                   (testing "- losing focus when too long adds invalid field class and validation message"
+                           (clean-setup!)
                            (tu/set-value (rfd/input-selector :registration-password) too-long-password)
                            (tu/lose-focus (rfd/input-selector :registration-password))
                            (tu/test-field-has-class (rfd/form-row-selector :registration-password) rfd/field-invalid-class)
                            (tu/element-has-text (rfd/validation-selector :registration-password)
                                                   (get-in dom/translations [:index :register-password-too-long-validation-message])))

-                  (testing "- losing focus when valid removes invalid field class and validation message"
-                           (tu/test-field-has-class (rfd/form-row-selector :registration-password) rfd/field-invalid-class)
-                           (tu/element-has-text (rfd/validation-selector :registration-password)
-                                                  (get-in dom/translations [:index :register-password-too-long-validation-message])) ; gg|rs 18Sept - what about (element-has-any-text ...) ?
-
+                  (testing "- losing focus when valid removes invalid field class and there is no validation message"
+                           (clean-setup!)
+                           (dom/add-class! (rfd/form-row-selector :registration-password) rfd/field-invalid-class)
                            (tu/set-value (rfd/input-selector :registration-password) valid-password)
                            (tu/lose-focus (rfd/input-selector :registration-password))

@@ -198,10 +202,8 @@
                            (tu/element-has-no-text (rfd/validation-selector :registration-password)))))

 (deftest submitting-invalid-forms
-         (setup-index-page!)
-         (app/start)
-
          (testing "submitting empty form"
+                  (clean-setup!)
                   (tu/press-submit rfd/register-form-element-selector)
                   (check-first-name-has-blank-validation-errors)
                   (check-last-name-has-blank-validation-errors)
@@ -210,7 +212,8 @@
                   (tu/has-focus? (rfd/input-selector :registration-first-name)))

          (testing "submitting form with only valid first-name"
-                  (tu/enter-text (rfd/input-selector :registration-first-name) valid-name)
+                  (clean-setup!)
+                  (tu/set-value (rfd/input-selector :registration-first-name) valid-name)
                   (tu/press-submit rfd/register-form-element-selector)
                   (check-last-name-has-blank-validation-errors)
                   (check-email-address-has-invalid-validation-errors)
@@ -218,36 +221,38 @@
                   (tu/has-focus? (rfd/input-selector :registration-last-name)))

          (testing "submitting form with only valid first-name and last-name"
-                  (tu/enter-text (rfd/input-selector :registration-last-name) valid-name)
+                  (clean-setup!)
+                  (tu/set-value (rfd/input-selector :registration-first-name) valid-name)
+                  (tu/set-value (rfd/input-selector :registration-last-name) valid-name)
                   (tu/press-submit rfd/register-form-element-selector)
                   (check-email-address-has-invalid-validation-errors)
                   (check-password-has-blank-validation-errors)
                   (tu/has-focus? (rfd/input-selector :registration-email)))

          (testing "submitting form with only valid first-name, last-name and email-address"
-                  (tu/enter-text (rfd/input-selector :registration-email) valid-email)
+                  (clean-setup!)
+                  (tu/set-value (rfd/input-selector :registration-first-name) valid-name)
+                  (tu/set-value (rfd/input-selector :registration-last-name) valid-name)
+                  (tu/set-value (rfd/input-selector :registration-email) valid-email)
                   (tu/press-submit rfd/register-form-element-selector)
                   (check-password-has-blank-validation-errors)
                   (tu/has-focus? (rfd/input-selector :registration-password))))

-(defn default-state [] (atom rfc/default-state))
-
 (deftest prevent-default-submit
-         (setup-index-page!)
-         (app/start)
-
          (testing "prevents default when page has errors"
+                  (clean-setup!)
                   (let [submit-event (tu/create-event :submit)]
-                    (rfc/block-invalid-submit (default-state) submit-event)
+                    (rfc/block-invalid-submit app/registration-form-state submit-event)
                     (tu/default-prevented? submit-event true)))

          (testing "doesn't prevent default when inputs are valid"
+                  (clean-setup!)
                   (let [submit-event (tu/create-event :submit)]
                     (tu/enter-text (rfd/input-selector :registration-first-name) valid-name)
                     (tu/enter-text (rfd/input-selector :registration-last-name) valid-name)
                     (tu/enter-text (rfd/input-selector :registration-email) valid-email)
                     (tu/enter-text (rfd/input-selector :registration-password) valid-password)
-                    (rfc/block-invalid-submit (default-state) submit-event)
+                    (rfc/block-invalid-submit app/registration-form-state submit-event)
                     (testing "all error classes are removed"
                              (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
                              (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-last-name) rfd/field-invalid-class)


Fix diff of 1 between num-tests and trial-number

Makes both values to be the same in c.t.c/failure, meaning
the total count of trials

--- src/main/clojure/clojure/test/check.cljc
+++ src/main/clojure/clojure/test/check.cljc
@@ -91,14 +91,15 @@
               result-map-rose (gen/call-gen property r1 size)
               result-map (rose/root result-map-rose)
               result (:result result-map)
-              args (:args result-map)]
+              args (:args result-map)
+              so-far (inc so-far)]
           (if (not-falsey-or-exception? result)
-            (let [so-far' (inc so-far)]
+            (do
               (reporter-fn {:type :trial
                             :property property
-                            :so-far so-far'
+                            :so-far so-far
                             :num-tests num-tests})
-              (recur so-far' rest-size-seq r2))
+              (recur so-far rest-size-seq r2))
             (failure property result-map-rose so-far size created-seed reporter-fn)))))))

 (defn- smallest-shrink
@@ -159,6 +160,6 @@
     {:result result
      :seed seed
      :failing-size size
-     :num-tests (inc trial-number)
+     :num-tests trial-number
      :fail (vec failing-args)
      :shrunk (shrink-loop failing-rose-tree)}))