                    :product-specific-attributes [gpsa]
                    :beginning-date-time "1966-12-12T07:00:00.000-05:00"
                    :ending-date-time "1967-10-12T07:00:00.000-05:00"}
-        gran-data2 {:platform-refs [pr2]
-                    :spatial-coverage gran-spatial-rep
-                    :two-d-coordinate-system g-two-d-cs
-                    :product-specific-attributes [gpsa]
-                    :beginning-date-time "1966-12-12T07:00:00.000-05:00"
-                    :ending-date-time "1967-10-12T07:00:00.000-05:00"}
         echo10-coll (dc/collection coll-data)
         _ (d/ingest "PROV1" echo10-coll {:format :echo10})
         dif-coll (dc/collection (assoc coll-data :entry-title "short_name2_version"

          (is (= exp-errors
                 (flatten (map (fn [error] (:errors error))
                               (:errors (d/ingest "PROV1" gran {:format :echo10 :allow-failure? true}))))))

          "ECHO10 collection-referencing the platform alias"
          []
          gran-for-echo10-coll

          "ECHO10 collection"
          []
          gran-for-echo10-coll2

          "DIF collection"
          ["The following list of 2D Coordinate System names did not exist in the referenced parent collection: [BRAVO]."]

;; two-d-coordinate-system - start-coordinate-1, end-coordinate-1, start-coordinate-2, end-coordinate-2
;; must fall within bounds defined in parent collection

;; This test demonstrates how granule's platform references the collection's platform and
;; the platform aliases defined in the humanizer.
(deftest granule-match-parent-collection-platform-alias-test
  (let [psa1 (dc/psa {:name "a-float" :data-type :float :min-value 1.0 :max-value 10.0})
        gpsa (dg/psa "a-float" [7.0])
        projects (dc/projects "proj")
        mbr1 (umm-s/set-coordinate-system :geodetic (m/mbr 10 10 20 0))
        gran-spatial-rep (apply dg/spatial [mbr1])
        two-d-cs {:name "BRAVO"
                  :coordinate-1 {:min-value 100
                                 :max-value 200}
                  :coordinate-2 {:min-value 300
                                 :max-value 400}}
        g-two-d-cs (dg/two-d-coordinate-system
                     {:name "BRAVO"
                      :start-coordinate-1 110
                      :end-coordinate-1 130
                      :start-coordinate-2 300
                      :end-coordinate-2 328})

        i1 (dc/instrument {:short-name "instrumentA"})
        ir1 (dg/instrument-ref {:short-name "instrumentA"})
        i2 (dc/instrument {:short-name "instrumentB"})
        ir2 (dg/instrument-ref {:short-name "instrumentB"})

        c-p1 (dc/platform {:short-name "Terra" :instruments [i1]})
        c-p2 (dc/platform {:short-name "Foo"})
        c-p3 (dc/platform {:short-name "AM-1" :instruments [i2]})

        g-pr1 (dg/platform-ref {:short-name "Terra"})
        g-pr2 (dg/platform-ref {:short-name "Terra" :instrument-refs [ir1]})
        g-pr3 (dg/platform-ref {:short-name "Terra" :instrument-refs [ir2]})
        g-pr4 (dg/platform-ref {:short-name "Foo"})
        g-pr5 (dg/platform-ref {:short-name "AM-1"})
        g-pr6 (dg/platform-ref {:short-name "AM-1" :instrument-refs [ir1]})
        g-pr7 (dg/platform-ref {:short-name "AM-1" :instrument-refs [ir2]})
        g-pr8 (dg/platform-ref {:short-name "Bar"})

        coll-data1 {:entry-title "short_name1_version"
                    :short-name "short_name1"
                    :version-id "version"
                    :product-specific-attributes [psa1]
                    :platforms [c-p1 c-p2]
                    :organizations [(dc/org :distribution-center "Larc")]
                    :science-keywords [(dc/science-keyword {:category "upcase"
                                                            :topic "Cool"
                                                            :term "Mild"})]
                    :projects projects
                    :spatial-coverage (dc/spatial {:gsr :geodetic})
                    :two-d-coordinate-systems [two-d-cs]
                    :related-urls [(dc/related-url {:type "type" :url "htt://www.foo.com"})]
                    :beginning-date-time "1965-12-12T07:00:00.000-05:00"
                    :ending-date-time "1967-12-12T07:00:00.000-05:00"}

       coll-data2 {:entry-title "short_name2_version"
                   :short-name "short_name2"
                   :version-id "version"
                   :product-specific-attributes [psa1]
                   :platforms [c-p1 c-p3]
                   :organizations [(dc/org :distribution-center "Larc")]
                   :science-keywords [(dc/science-keyword {:category "upcase"
                                                           :topic "Cool"
                                                           :term "Mild"})]
                   :projects projects
                   :spatial-coverage (dc/spatial {:gsr :geodetic})
                   :two-d-coordinate-systems [two-d-cs]
                   :related-urls [(dc/related-url {:type "type" :url "htt://www.foo.com"})]
                   :beginning-date-time "1965-12-12T07:00:00.000-05:00"
                   :ending-date-time "1967-12-12T07:00:00.000-05:00"}
        
       gran-data1 {:platform-refs [g-pr1]
                   :spatial-coverage gran-spatial-rep
                   :two-d-coordinate-system g-two-d-cs
                   :product-specific-attributes [gpsa]
                   :beginning-date-time "1966-12-12T07:00:00.000-05:00"
                   :ending-date-time "1967-10-12T07:00:00.000-05:00"}

        gran-data2 {:platform-refs [g-pr2]
                   :spatial-coverage gran-spatial-rep
                   :two-d-coordinate-system g-two-d-cs
                   :product-specific-attributes [gpsa]
                   :beginning-date-time "1966-12-12T07:00:00.000-05:00"
                   :ending-date-time "1967-10-12T07:00:00.000-05:00"}

        gran-data3 {:platform-refs [g-pr3]
                   :spatial-coverage gran-spatial-rep
                   :two-d-coordinate-system g-two-d-cs
                   :product-specific-attributes [gpsa]
                   :beginning-date-time "1966-12-12T07:00:00.000-05:00"
                   :ending-date-time "1967-10-12T07:00:00.000-05:00"}

        gran-data4 {:platform-refs [g-pr4]
                   :spatial-coverage gran-spatial-rep
                   :two-d-coordinate-system g-two-d-cs
                   :product-specific-attributes [gpsa]
                   :beginning-date-time "1966-12-12T07:00:00.000-05:00"
                   :ending-date-time "1967-10-12T07:00:00.000-05:00"}

        gran-data5 {:platform-refs [g-pr5]
                   :spatial-coverage gran-spatial-rep
                   :two-d-coordinate-system g-two-d-cs
                   :product-specific-attributes [gpsa]
                   :beginning-date-time "1966-12-12T07:00:00.000-05:00"
                   :ending-date-time "1967-10-12T07:00:00.000-05:00"}

        gran-data6 {:platform-refs [g-pr6]
                   :spatial-coverage gran-spatial-rep
                   :two-d-coordinate-system g-two-d-cs
                   :product-specific-attributes [gpsa]
                   :beginning-date-time "1966-12-12T07:00:00.000-05:00"
                   :ending-date-time "1967-10-12T07:00:00.000-05:00"}

        gran-data7 {:platform-refs [g-pr7]
                   :spatial-coverage gran-spatial-rep
                   :two-d-coordinate-system g-two-d-cs
                   :product-specific-attributes [gpsa]
                   :beginning-date-time "1966-12-12T07:00:00.000-05:00"
                   :ending-date-time "1967-10-12T07:00:00.000-05:00"}
     
        gran-data8 {:platform-refs [g-pr8]
                   :spatial-coverage gran-spatial-rep
                   :two-d-coordinate-system g-two-d-cs
                   :product-specific-attributes [gpsa]
                   :beginning-date-time "1966-12-12T07:00:00.000-05:00"
                   :ending-date-time "1967-10-12T07:00:00.000-05:00"}
 
        echo10-coll1 (dc/collection coll-data1)
        _ (d/ingest "PROV1" echo10-coll1 {:format :echo10})
        echo10-coll2 (dc/collection coll-data2)
        _ (d/ingest "PROV1" echo10-coll2 {:format :echo10})
 
        gran-Terra-coll1 (dg/granule echo10-coll1 gran-data1)
        gran-AM-1-coll1 (dg/granule echo10-coll1 gran-data5)
        gran-Foo-coll1 (dg/granule echo10-coll1 gran-data4)
        gran-Bar-coll1 (dg/granule echo10-coll1 gran-data8)
        gran-AM-1-InstrumentA-coll1 (dg/granule echo10-coll1 gran-data6)

        gran-Terra-coll2 (dg/granule echo10-coll2 gran-data1)
        gran-AM-1-coll2 (dg/granule echo10-coll2 gran-data5)
        gran-AM-1-InstrumentA-coll2 (dg/granule echo10-coll2 gran-data6)
        gran-AM-1-InstrumentB-coll2 (dg/granule echo10-coll2 gran-data7)
        gran-Terra-InstrumentA-coll2 (dg/granule echo10-coll2 gran-data2)
        gran-Terra-InstrumentB-coll2 (dg/granule echo10-coll2 gran-data3)
        gran-Foo-coll2 (dg/granule echo10-coll2 gran-data4)]

    (are3 [exp-errors gran]
          (is (= exp-errors
                 (flatten (map (fn [error] (:errors error))
                               (:errors (d/ingest "PROV1" gran {:format :echo10 :allow-failure? true}))))))

          "gran-Terra-coll1 success test"
          []
          gran-Terra-coll1

          "gran-AM-1-coll1 success test"
          []
          gran-AM-1-coll1

          "gran-Foo-coll1 success test"
          []
          gran-Foo-coll1

          "gran-AM-1-InstrumentA-coll1 success test"
          []
          gran-AM-1-InstrumentA-coll1
 
          "gran-Bar-coll1 failure test"
          ["The following list of Platform short names did not exist in the referenced parent collection: [Bar]."]
          gran-Bar-coll1 

          "gran-Terra-coll2 success test"
          []
          gran-Terra-coll2

          "gran-AM-1-coll2 success test"
          []
          gran-AM-1-coll2

          "gran-AM-1-InstrumentA-coll2 success test"
          []
          gran-AM-1-InstrumentA-coll2

          "gran-AM-1-InstrumentB-coll2 success test"
          []
          gran-AM-1-InstrumentB-coll2

          "gran-Terra-InstrumentA-coll2 success test"
          []
          gran-Terra-InstrumentA-coll2

          "gran-Terra-InstrumentB-coll2 failure test"
          ["The following list of Instrument short names did not exist in the referenced parent collection: [instrumentB]."]
          gran-Terra-InstrumentB-coll2

          "gran-Foo-coll2 failure test"
          ["The following list of Platform short names did not exist in the referenced parent collection: [Foo]."]
          gran-Foo-coll2)))

;; This tests demonstrates limitations of various collection formats because they do not support
;; fields referenced by a child granule.
(deftest granule-match-parent-collection-test
