                      :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-A (dc/collection coll-data-A)
-        _ (d/ingest "PROV1" echo10-coll-A {:format :echo10})
-        echo10-coll-B (dc/collection coll-data-B)
-        _ (d/ingest "PROV1" echo10-coll-B {:format :echo10})
-        gran-A-for-echo10-coll-A (dg/granule echo10-coll-A gran-data-A)
-        gran-B-for-echo10-coll-A (dg/granule echo10-coll-A gran-data-B)
-        gran-A-for-echo10-coll-B (dg/granule echo10-coll-B gran-data-A)
-        gran-B-for-echo10-coll-B (dg/granule echo10-coll-B gran-data-B)]
+        echo10-coll-A (data-umm-c/collection coll-data-A)
+        _ (d/ingest-umm-spec-collection "PROV1" echo10-coll-A {:format :echo10})
+        echo10-coll-B (data-umm-c/collection coll-data-B)
+        _ (d/ingest-umm-spec-collection "PROV1" echo10-coll-B {:format :echo10})
+        gran-A-for-echo10-coll-A (dg/granule-with-umm-spec-collection echo10-coll-A (:concept-id echo10-coll-A) gran-data-A)
+        gran-B-for-echo10-coll-A (dg/granule-with-umm-spec-collection echo10-coll-A (:concept-id echo10-coll-A) gran-data-B)
+        gran-A-for-echo10-coll-B (dg/granule-with-umm-spec-collection echo10-coll-B (:concept-id echo10-coll-B) gran-data-A)
+        gran-B-for-echo10-coll-B (dg/granule-with-umm-spec-collection echo10-coll-B (:concept-id echo10-coll-B) gran-data-B)]
 
     (are3 [exp-errors gran]
           (is (= exp-errors

         []
         :dif10

         ["Collection TilingIdentificationSystemName [BRAVO] is referenced by existing granules, cannot be removed. Found 1 granules."]
         :iso19115

         ["Collection additional attribute [a-float] is referenced by existing granules, cannot be removed. Found 1 granules."
          "Collection TilingIdentificationSystemName [BRAVO] is referenced by existing granules, cannot be removed. Found 1 granules."
          "Collection changing from GEODETIC granule spatial representation to NO_SPATIAL is not allowed when the collection has granules. Found 1 granules."]
         :iso-smap)))


;; 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
  (let [psa1 (data-umm-c/additional-attribute {:Name "a-float" :DataType "FLOAT" :ParameterRangeBegin 1.0 :ParameterRangeEnd 10.0})
        gpsa (dg/psa "a-float" [7.0])
        i1 (data-umm-c/instrument {:ShortName "instrument-Sn A"})
        ir1 (dg/instrument-ref {:short-name "instrument-Sn A"})
        p1 (data-umm-c/platform {:ShortName "platform-Sn A" :Instruments [i1]})
        pr1 (dg/platform-ref {:short-name "platform-Sn A" :instrument-refs [ir1]})
        projects (data-umm-c/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 {:TilingIdentificationSystemName "BRAVO"
                  :Coordinate1 {:MinimumValue 100
                                :MaximumValue 200}
                  :Coordinate2 {:MinimumValue 300
                                :MaximumValue 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})
        coll-data {:EntryTitle "short_name1_version"
                   :ShortName "short_name1"
                   :Version "version"
                   :AdditionalAttributes [psa1]
                   :Platforms[p1]
                   :DataCenters [(data-umm-c/data-center ["DISTRIBUTOR"] "Larc")]
                   :ScienceKeywords [(data-umm-c/science-keyword {:Category "upcase"
                                                           :Topic "Cool"
                                                           :Term "Mild"})]
                   :Projects projects
                   :SpatialExtent (data-umm-c/spatial {:gsr "GEODETIC"})
                   :TilingIdentificationSystems [two-d-cs]
                   :RelatedUrls [(data-umm-c/related-url {:Type "type" :URL "http://www.foo.com"})]
                   :TemporalExtents [(data-umm-c/temporal-extent
                                      {:beginning-date-time "1965-12-12T07:00:00.000-05:00"
                                       :ending-date-time "1967-12-12T07:00:00.000-05:00"})]}
        gran-data {:platform-refs [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"}
        echo10-coll (data-umm-c/collection coll-data)
        _ (d/ingest-umm-spec-collection "PROV1" echo10-coll {:format :echo10})
        dif-coll (data-umm-c/collection (assoc coll-data :EntryTitle "short_name2_version"
                                       :ShortName "short_name2"))
        _ (d/ingest-umm-spec-collection "PROV1" dif-coll {:format :dif})
        dif10-coll (data-umm-c/collection (assoc coll-data :EntryTitle "short_name3_version"
                                         :ShortName "short_name3"))
        _ (d/ingest-umm-spec-collection "PROV1" dif10-coll {:format :dif10})
        iso19115-coll (data-umm-c/collection (assoc coll-data :EntryTitle "short_name4_version"
                                            :ShortName "short_name4"))
        _ (d/ingest-umm-spec-collection "PROV1" iso19115-coll {:format :iso19115})
        iso-smap-coll (data-umm-c/collection (assoc coll-data :EntryTitle "short_name5_version"
                                            :ShortName "short_name5"))
        _ (d/ingest-umm-spec-collection "PROV1" iso-smap-coll {:format :iso-smap})
        gran-for-echo10-coll (dg/granule-with-umm-spec-collection echo10-coll (:concept-id echo10-coll) gran-data)
        gran-for-dif-coll (dg/granule-with-umm-spec-collection dif-coll (:concept-id dif-coll) gran-data)
        gran-for-dif10-coll (dg/granule-with-umm-spec-collection dif10-coll (:concept-id dif-coll) gran-data)
        gran-for-iso19115-coll (dg/granule-with-umm-spec-collection iso19115-coll (:concept-id iso19115-coll) gran-data)
        gran-for-iso-smap-coll (dg/granule-with-umm-spec-collection iso-smap-coll (:concept-id iso-smap-coll) gran-data)]

    (are3 [exp-errors gran]
          (is (= exp-errors
