ContextFileWorker { protected static Node createNodeFromRecentPresentation(final Document document, final RecentPresentation recentPresentation) { if (recentPresentation == null || recentPresentation.getOpenedDateTime() == null || recentPresentation.getAbsolutePath().trim().isEmpty()) { return null; } final Element recentPresentationNode = document.createElement(RECENT_PRESENTATION_TAG); final Element idNode = document.createElement(ID_TAG); idNode.setTextContent(recentPresentation.getId()); recentPresentationNode.appendChild(idNode); final Element fileNode = document.createElement(FILE_TAG); fileNode.setTextContent(recentPresentation.getNormalizedPath()); recentPresentationNode.appendChild(fileNode); final Element openedDateTimeNode = document.createElement(OPENED_DATE_TIME_TAG); openedDateTimeNode.setTextContent(recentPresentation.getOpenedDateTime().toString()); recentPresentationNode.appendChild(openedDateTimeNode); return recentPresentationNode; } private  ContextFileWorker(); static Set<RecentPresentation> readRecentPresentationFromFile(final File contextFile); static void saveRecentPresentationToFile(final File contextFile, final RecentPresentation recentPresentation); static void updateRecentPresentationInFile(final File contextFile, final RecentPresentation recentPresentation); static boolean recentPresentationAlreadyPresent(final File contextFile, final RecentPresentation recentPresentation); static Set<RecentPresentation> purgeRecentPresentations(final InputStream input, final OutputStream output, final long numberOfRecentPresentationsToKeep);  }
@Test public void createNodeFromRecentPresentation() throws Exception { final String xml = "<slideshowfx></slideshowfx>"; final Document document = createDocumentFromString(xml); final String path = "presentation.sfx"; final LocalDateTime openedDateTime = LocalDateTime.now(); final RecentPresentation recentPresentation = new RecentPresentation(path, openedDateTime); final Node createdNode = ContextFileWorker.createNodeFromRecentPresentation(document, recentPresentation); assertRecentPresentationNode(createdNode, recentPresentation); }