                                                             :version-id "v1"
                                                             :short-name "s1"}})
         coll2 (save-collection "REG_PROV" 2 {:extra-fields {:entry-id "entry-2"
-                                                              :entry-title "et2"
-                                                              :version-id "v1"
-                                                              :short-name "s2"}})
+                                                            :entry-title "et2"
+                                                            :version-id "v1"
+                                                            :short-name "s2"}})
         associated-tag (util/create-and-save-tag 1)
         tag-association1 (util/create-and-save-tag-association coll1 associated-tag 1 3)
         tag-association2 (util/create-and-save-tag-association coll2 associated-tag 2 2)]
     (testing "find latest revisions"
       (are3 [tag-associations params]
-            (= (set tag-associations)
+        (is (= (set tag-associations)
                (set (->> (util/find-latest-concepts :tag-association params)
                          :concepts
-                         (map #(dissoc % :provider-id :revision-date :transaction-id)))))
-
-            "by associated-concept-id"
-            [tag-association1] {:associated-concept-id "C1200000000-REG_PROV"}
-
-            "with metadata"
-            [tag-association1 tag-association2] {}
-
-            "exclude metadata"
-            [(dissoc tag-association1 :metadata) (dissoc tag-association2 :metadata)] {:exclude-metadata true}))
+                         (map #(dissoc % :provider-id :revision-date :transaction-id))))))
+
+        "by associated-concept-id"
+        [tag-association1] {:associated-concept-id "C1200000000-REG_PROV"}
+
+        "with metadata"
+        [tag-association1 tag-association2] {}
+
+        "exclude metadata"
+        [(dissoc tag-association1 :metadata) (dissoc tag-association2 :metadata)] {:exclude-metadata true}))
 
     (testing "find all revisions"
       (let [num-of-tag-associations (-> (util/find-concepts :tag-association {})

    (testing "find with parameters"
      (testing "latest revisions"
        (are3 [groups params]
              (= (set (map util/expected-concept groups))
                 (set (-> (util/find-latest-concepts :access-group params)
                          :concepts
                          concepts-for-comparison)))
              ;; These are the only valid combinations for groups
              "provider-id, native-id"
              [group1] {:provider-id "REG_PROV" :native-id "native-id 1"}

              "no metadata"
              [(dissoc group1 :metadata)] {:provider-id "REG_PROV"
                                           :exclude-metadata true}))

      (testing "all revisions"
        (are3 [rev-count params]
              (= rev-count
                 (count (-> (util/find-concepts :access-group params)
                            :concepts)))
              "provider-id, native-id - three revisons"
              3 {:provider-id "REG_PROV" :native-id "native-id 1"}
              "everything"
              5 {})))))

(deftest find-variables
  (let [variable1 (util/create-and-save-variable "REG_PROV" 1 3)
        variable2 (util/create-and-save-variable "REG_PROV" 2 2)]
    (testing "find latest revsions"
      (are3 [variables params]
        (= (set variables)
           (set (->> (util/find-latest-concepts :variable params)
                     :concepts
                     (map #(dissoc % :provider-id :revision-date :transaction-id :created-at)))))

        "with metadata"
        [variable1 variable2]
        {:provider-id "REG_PROV"}

        "find none - bad provider-id"
        []
        {:provider-id "PROV_NONE"}

        "exclude metadata"
        [(dissoc variable1 :metadata) (dissoc variable2 :metadata)]
        {:provider-id "REG_PROV" :exclude-metadata true}))
    (testing "find all revisions"
      (let [num-of-variables (-> :variable
                                 (util/find-concepts {:provider-id "REG_PROV"})
                                 :concepts
                                 count)]
        (is (= 5 num-of-variables))))))

(ns cmr.metadata-db.int-test.concepts.search-test
  "Contains integration tests for searching concepts."
  (:require
   [clj-time.core :as t]
   [clojure.test :refer :all]
   [cmr.common.time-keeper :as tk]
   [cmr.common.util :refer [are3]]
   [cmr.metadata-db.int-test.utility :as util]
   [cmr.metadata-db.services.messages :as msg]))

(use-fixtures :each (util/reset-database-fixture {:provider-id "REG_PROV" :small false}
                                                 {:provider-id "REG_PROV1" :small false}
                                                 {:provider-id "SMAL_PROV1" :small true}
                                                 {:provider-id "SMAL_PROV2" :small true}))

(defn- concepts-for-comparison
  "Removes revision-date, transaction-id, and created-at from concepts so they can be compared."
  [concepts]
  (map #(dissoc % :revision-date :transaction-id :created-at) concepts))
