### Question:
DDocFacade implements Serializable { public void save(String path) { logger.info("Saving container to path: " + path); try { ddoc.writeToFile(new File(path)); } catch (DigiDocException e) { throw new DigiDoc4JException(e.getMessage(), e.getNestedException()); } } DDocFacade(Configuration configuration);   DDocFacade(SignedDoc ddoc); String getSignatureProfile(); DigestAlgorithm getDigestAlgorithm(); List<DataFile> getDataFiles(); int countDataFiles(); void save(String path); void save(OutputStream out); List<Signature> getSignatures(); Signature getSignature(int index); int countSignatures(); Container.DocumentType getDocumentType(); ContainerValidationResult validate(); String getVersion(); String getFormat(); Configuration getConfiguration();  }### Answer:
@Test(expected = DigiDoc4JException.class) public void testSaveThrowsException() throws Exception { DDocFacade facade = openDDocFacade("src/test/resources/testFiles/valid-containers/ddoc_for_testing.ddoc"); facade.save("/not/existing/path/testSaveThrowsException.ddoc"); }
@Test public void savesToStream() throws IOException { DDocFacade facade = openDDocFacade("src/test/resources/testFiles/valid-containers/ddoc_for_testing.ddoc"); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { facade.save(out); Assert.assertTrue(out.size() != 0); } }
@Test(expected = DigiDoc4JException.class) public void savesToStreamThrowsException() throws Exception { SignedDoc ddoc = Mockito.mock(SignedDoc.class); DigiDocException testException = new DigiDocException(100, "testException", new Throwable("test Exception")); Mockito.doThrow(testException).when(ddoc).writeToStream(ArgumentMatchers.any(OutputStream.class)); DDocFacade facade = new DDocFacade(ddoc); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { facade.save(out); } }