 
     (testing "retrieve metadata from search by concept-id/revision-id"
       (testing "collections and granules"
-        (are2 [item format-key accept concept-id revision-id]
+        (are3 [item format-key accept concept-id revision-id]
               (let [response (search/retrieve-concept
                                concept-id
                                revision-id

            [cmr.system-int-test.data2.kml :as dk]
            [cmr.system-int-test.utils.url-helper :as url]
            [cmr.umm.echo10.collection :as c]
            [cmr.common.util :refer [are2] :as util]
            [cmr.transmit.config :as transmit-config]
            [cmr.common.mime-types :as mt]
            [cheshire.core :as json]

        (is (= (:entry-title umm-coll) (:EntryTitle parsed-collection)))))))

(defn- expected-umm-json
  "Returns the expected umm json in the expected-version for the given metadata whose umm
  json version is source-version."
  [metadata expected-version source-version]
  (umm-spec/generate-metadata
    test-context
    (umm-spec/parse-metadata
      test-context :collection {:format :umm-json :version source-version} metadata)
    (format "%s;version=%s" mt/umm-json expected-version)))

(deftest umm-json-version-retrieval-test
  (e/grant-registered-users (s/context) (e/coll-catalog-item-id "provguid1" ["The entry title V5"]))
  (let [user1-token (e/login (s/context) "user1")
        coll expected-conversion/example-collection-record
        original-umm-version "1.0"
        original-mime-type (format "%s;version=%s" mt/umm-json original-umm-version)
        json (umm-spec/generate-metadata test-context coll original-mime-type)
        ;; ingest the collection with umm json metadata in version 1.0
        {:keys [concept-id]} (d/ingest-concept-with-metadata {:provider-id  "PROV1"
                                                              :concept-type :collection
                                                              :format original-mime-type
                                                              :metadata json})]
    (index/wait-until-indexed)

    (are3 [requested-version expected-version]
          (let [accept-header (if requested-version
                                (format "%s;version=%s" mt/umm-json requested-version)
                                mt/umm-json)
                ;; retrieve the collection by concept id and the given umm json version in accept header
                response (search/retrieve-concept concept-id nil
                                                  {:query-params {:token user1-token}
                                                   :accept accept-header})
                response-concept-type (get-in response [:headers "Content-Type"])]

            (is (= 200 (:status response)))
            ;; retrieved result matches the expected umm json which is converted from the original
            ;; umm json version to the expected version
            (is (= (expected-umm-json json expected-version original-umm-version) (:body response)))
            (is (= mt/umm-json (mt/base-mime-type-of response-concept-type)))
            (is (= expected-version (mt/version-of response-concept-type))))

          "default version"
          nil ver/current-version

          "original umm version, 1.0"
          original-umm-version original-umm-version

          "an intermediate version, 1.2"
          "1.2" "1.2"

          "specific latest version"
          ver/current-version ver/current-version)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
