### Question:
JsonWorkspaceService implements WorkspaceService { @Override public void saveWorkspace(Map<String, Map<String, String>> data, File destination) { requireNotNullArg(destination, "Destination file cannot be null"); LOG.debug(DefaultI18nContext.getInstance().i18n("Saving workspace data to {0}", destination.getAbsolutePath())); try { JSON.std.with(JSON.Feature.PRETTY_PRINT_OUTPUT).without(JSON.Feature.WRITE_NULL_PROPERTIES) .write(data, destination); LOG.info(DefaultI18nContext.getInstance().i18n("Workspace saved")); } catch (Exception e) { throw new RuntimeException(e); } }  @Override void saveWorkspace(Map<String, Map<String, String>> data, File destination); @Override @SuppressWarnings("unchecked") Map<String, Map<String, String>> loadWorkspace(File workspace);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void saveNull() { victim.saveWorkspace(Collections.emptyMap(), null); }
@Test public void saveWorkspace() throws IOException { File file = folder.newFile(); assertFalse(FileUtils.readLines(file, StandardCharsets.UTF_8).size() > 0); Map<String, Map<String, String>> data = new HashMap<>(); Map<String, String> moduleData = new HashMap<>(); moduleData.put("key", "value"); data.put("module", moduleData); victim.saveWorkspace(data, file); assertTrue(FileUtils.readLines(file, StandardCharsets.UTF_8).size() > 0); }
@Test(expected = RuntimeException.class) public void saveWorkspaceReadOnly() throws IOException { File file = folder.newFile(); file.setReadOnly(); Map<String, Map<String, String>> data = new HashMap<>(); Map<String, String> moduleData = new HashMap<>(); moduleData.put("key", "value"); data.put("module", moduleData); victim.saveWorkspace(data, file); }