ViewerPreferencesUtils { public static void setBooleanPreferences(PDViewerPreferences preferences, Set<PdfBooleanPreference> enabled) throws TaskException { if (preferences == null) { throw new TaskException("Unable to set preferences on a null instance."); } for (PdfBooleanPreference current : PdfBooleanPreference.values()) { if (enabled.contains(current)) { PDFBoxActivableBooleanPreference.valueFromPdfBooleanPreference(current).enable(preferences); LOG.trace("{} = enabled.", current); } else { PDFBoxActivableBooleanPreference.valueFromPdfBooleanPreference(current).disable(preferences); LOG.trace("{} = disabled.", current); } } } private  ViewerPreferencesUtils(); static NON_FULL_SCREEN_PAGE_MODE getNFSMode(PdfNonFullScreenPageMode nfsMode); static PageMode getPageMode(PdfPageMode mode); static PageLayout getPageLayout(PdfPageLayout layout); static READING_DIRECTION getDirection(PdfDirection direction); static DUPLEX getDuplex(PdfDuplex duplex); static PRINT_SCALING getPrintScaling(PdfPrintScaling scaling); static void setBooleanPreferences(PDViewerPreferences preferences, Set<PdfBooleanPreference> enabled);  }
@Test public void testSetBooleanPreferences() throws TaskException { PDViewerPreferences preferences = mock(PDViewerPreferences.class); Set<PdfBooleanPreference> enabled = Collections.singleton(PdfBooleanPreference.CENTER_WINDOW); ViewerPreferencesUtils.setBooleanPreferences(preferences, enabled); verify(preferences).setCenterWindow(true); verify(preferences).setHideMenubar(false); verify(preferences).setHideToolbar(false); verify(preferences).setHideWindowUI(false); verify(preferences).setDisplayDocTitle(false); verify(preferences).setFitWindow(false); }
@Test(expected = TaskException.class) public void testSetBooleanPreferencesNullPref() throws TaskException { ViewerPreferencesUtils.setBooleanPreferences(null, Collections.EMPTY_SET); }