         (is (=  (zx/xml1-> root :dc:title  zx/text)  "Umění programování v UNIXu"))
         (is (=  (zx/xml1-> root :dc:date zx/text) "2004"))
         (is (=  (set (zx/xml-> root :dc:identifier zx/text))  
-                #{"uuid:asd" "ccnb:cnb001492461" "isbn:80-251-0225-4 (brož.)" "oclc:85131856"}))))
+                #{"urnnbn:urn:nbn:cz:mzk-0005ol" "uuid:asd" "ccnb:cnb001492461" 
+                  "isbn:80-251-0225-4 (brož.)" "oclc:85131856"}))))
 
     (fs/delete-dir tmpdir))
   )
 
+(deftest save-img-files-test
+  (testing "save img files to FOXML dir"
+    (def payload (slurp "resources/export-request.json"))
+    (def tmpdir (fs/temp-dir "test-export-to-kramerius-request-"))
+
+    (h/save-request  [[nil payload] tmpdir])
+
+    (let [metadata (read-string (slurp "resources/marcxml2mods-response-metadata.clj"))
+          payload (slurp "resources/marcxml2mods-response-payload.json")
+          actual-metadata (-> metadata (assoc :headers 
+                                              (-> metadata :headers (assoc "UUID" (.toString tmpdir)))))
+
+          [full-file preview-file result-tmpdir] 
+          (-> (h/parse-mods-files (h/save-marcxml2mods-response [actual-metadata payload]))
+              h/save-img-files)
+
+          uuid (slurp (io/file result-tmpdir "uuid"))]
+
+      (is (= (.toString result-tmpdir) (.toString tmpdir)))
+      (is (.isDirectory (io/file result-tmpdir uuid)))
+      (is (.isDirectory (io/file result-tmpdir uuid "img")))
+
+      (is (.exists (io/file result-tmpdir uuid "img" (-> full-file :filename))))
+      (is (= :img_full (-> full-file :img-type)))
+      (is (= "application/pdf" (-> full-file :mime-type)))
+      
+      (is (.exists (io/file result-tmpdir uuid "img" (-> preview-file :filename))))
+      (is (= :img_preview (-> preview-file :img-type)))
+      (is (= "image/jpeg" (-> preview-file :mime-type))))
+    
+    (fs/delete-dir tmpdir)
+    )
+  )
 
 (deftest foxml
   (testing "make FOXML"

          
          [oai_dcs response-tmpdir] (-> (h/save-marcxml2mods-response [actual-metadata payload])
                                        h/parse-mods-files
                                        h/mods->oai_dcs
                                        )
          ]

                     xml/parse
                     zip/xml-zip
                     )]
        ;(def root (-> (io/file "/tmp/aa.xml") io/input-stream xml/parse zip/xml-zip))
        (let [ref (zx/xml1-> root :datastream [(zx/attr= :ID "IMG_FULL")] :datastreamVersion :contentLocation (zx/attr :REF)) ]
          (is (= (.toString (io/file "file:/var/fedora/import/" uuid "img" (-> full-file :filename))) ref))
          )
        (let [ref (zx/xml1-> root :datastream [(zx/attr= :ID "IMG_PREVIEW")] :datastreamVersion :contentLocation (zx/attr :REF)) ]
          (is (= (.toString (io/file "file:/var/fedora/import/" uuid "img" (-> preview-file :filename))) ref))
          )
        )

      ;(pp/pprint result-tmpdir)
      ;(println (slurp (io/file result-tmpdir uuid (str uuid ".xml"))))
      )

    ;(fs/delete-dir tmpdir)
    )
  )










