### Question:
StreamDocument extends CommonDocument { @Override public void save(String filePath) { logger.debug("File Path: " + filePath); try { FileOutputStream fileOutputStream = new FileOutputStream(filePath); try { IOUtils.copy(getTemporaryFileAsStream(), fileOutputStream); } finally { fileOutputStream.close(); } } catch (IOException e) { logger.error(e.getMessage()); throw new DSSException(e); } } StreamDocument(InputStream stream, String documentName, MimeType mimeType); @Override InputStream openStream(); @Override void setName(String s); @Override String getAbsolutePath(); @Override MimeType getMimeType(); @Override void setMimeType(MimeType mimeType); @Override void save(String filePath); @Override String getDigest(DigestAlgorithm digestAlgorithm);  }### Answer:
@Test public void save() throws Exception { this.document.save("streamDocumentSaveTest.txt"); Assert.assertTrue(Files.exists(Paths.get("streamDocumentSaveTest.txt"))); FileReader fileReader = new FileReader("streamDocumentSaveTest.txt"); int read = fileReader.read(); fileReader.close(); Assert.assertEquals(65, read); Files.deleteIfExists(Paths.get("streamDocumentSaveTest.txt")); }
@Test public void createDocumentFromStreamedDataFile() throws Exception { String file = this.getFileBy("txt"); try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(new byte[]{0x041})) { DataFile dataFile = new DataFile(byteArrayInputStream, file, "text/plain"); StreamDocument streamDocument = new StreamDocument(dataFile.getStream(), dataFile.getName(), MimeType.fromMimeTypeString(dataFile.getMediaType())); streamDocument.save(file); } try (FileInputStream fileInputStream = new FileInputStream(file)) { Assert.assertArrayEquals(new byte[]{0x041}, IOUtils.toByteArray(fileInputStream)); } }