### Question:
XMLFileModelPersister implements ModelPersister { @Override public void saveModel(Model model, @Nullable String modelName) throws IllegalStateException { requireNonNull(model, "model"); LOG.debug("Saving model '{}', modelName is '{}'.", model.getName(), modelName); File modelFile = new File(dataDirectory, MODEL_FILE_NAME); checkState(dataDirectory.isDirectory() || dataDirectory.mkdirs(), "%s is not an existing directory and could not be created, either.", dataDirectory.getPath()); checkState(!modelFile.exists() || modelFile.isFile(), "%s exists, but is not a regular file", modelFile.getPath()); try { if (modelFile.exists()) { createBackup(); } try (OutputStream outStream = new FileOutputStream(modelFile)) { XMLModelWriter writer = writerProvider.get(); writer.writeXMLModel(model, modelName, outStream); } } catch (IOException exc) { throw new IllegalStateException("Exception saving model", exc); } } @Inject  XMLFileModelPersister(@ApplicationHome File directory,
                               Provider<XMLModelReader> readerProvider,
                               Provider<XMLModelWriter> writerProvider); @Override Optional<String> getPersistentModelName(); @Override void saveModel(Model model, @Nullable String modelName); @Override void loadModel(Model model); @Override boolean hasSavedModel(); @Override void removeModel();  }### Answer:
@Test public void testSaveModelShouldWriteXMLModel() throws IOException { Model model = createTestModel(MODEL_NAME); persister.saveModel(model, null); verify(writer, times(1)) .writeXMLModel(any(Model.class), any(), any(OutputStream.class)); assertEquals(persistedModel, model); }