            [cmr.common.util :refer [are2]]
            [cmr.access-control.int-test.fixtures :as fixtures]
            [cmr.access-control.test.util :as u]
-           [cmr.umm-spec.umm-spec-core :as umm-spec]
+           [cmr.umm.umm-core :as umm-core]
+           [cmr.umm.umm-granule :as umm-g]
            [cmr.umm-spec.test.expected-conversion :refer [example-collection-record]]
-           [clj-time.core :as t]))
+           [clj-time.core :as t]
+           [cmr.common.util :as util]))
 
 (use-fixtures :once (fixtures/int-test-fixtures))
 

                                                 :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 (= {coll1 ["read"]
                coll2 ["read"]
                coll3 ["read"]
                coll4 ["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/save-collection {: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/save-collection {:entry-id "coll4"
                                  :native-id "coll4"

(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" [])
        save-access-value-collection (fn [short-name access-value]
                                         (u/save-collection {: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 (save-access-value-collection "coll1" 1)
        ;; one with an intermediate access value
        coll2 (save-access-value-collection "coll2" 4)
        ;; one with a higher access value
        coll3 (save-access-value-collection "coll3" 9)
        ;; and one with no access value
        coll4 (save-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)]
