ContextFileWorker { public static boolean recentPresentationAlreadyPresent(final File contextFile, final RecentPresentation recentPresentation) throws ContextFileException { checkContextFileValidity(contextFile); final InputStream input; try { input = getInputStreamForFile(contextFile); } catch (IOException e) { throw new ContextFileException(e); } return recentPresentationAlreadyPresent(input, recentPresentation); } 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 testRecentPresentationAlreadyPresent() { final RecentPresentation recentPresentation1 = new RecentPresentation("presentation1.sfx", LocalDateTime.now()); final RecentPresentation recentPresentation2 = new RecentPresentation("presentation2.sfx", LocalDateTime.now().plusDays(2)); final String xml = this.createXmlStringFromRecentPresentations(recentPresentation1, recentPresentation2); final ByteArrayInputStream input = new ByteArrayInputStream(xml.getBytes(UTF_8)); assertTrue(ContextFileWorker.recentPresentationAlreadyPresent(input, recentPresentation2)); }
@Test public void testRecentPresentationAlreadyPresentWhenNot() { final RecentPresentation recentPresentation1 = new RecentPresentation("presentation1.sfx", LocalDateTime.now()); final RecentPresentation recentPresentation2 = new RecentPresentation("presentation2.sfx", LocalDateTime.now().plusDays(2)); final String xml = this.createXmlStringFromRecentPresentations(recentPresentation1); final ByteArrayInputStream input = new ByteArrayInputStream(xml.getBytes(UTF_8)); assertFalse(ContextFileWorker.recentPresentationAlreadyPresent(input, recentPresentation2)); }