### Question:
SplitAfterPredefinedSetOfPagesRadioButton extends RadioButton implements SplitParametersBuilderCreator, RestorableView, ResettableView { @Override public SimpleSplitParametersBuilder getBuilder(Consumer<String> onError) { KeyStringValueItem<PredefinedSetOfPages> selected = combo.getSelectionModel().getSelectedItem(); if (selected != null) { return new SimpleSplitParametersBuilder(selected.getKey()); } onError.accept(DefaultI18nContext.getInstance().i18n("No page selected")); return null; } SplitAfterPredefinedSetOfPagesRadioButton(ComboBox<KeyStringValueItem<PredefinedSetOfPages>> combo); @Override void resetView(); @Override SimpleSplitParametersBuilder getBuilder(Consumer<String> onError); @Override void saveStateTo(Map<String, String> data); @Override void restoreStateFrom(Map<String, String> data);  }### Answer:
@Test @Category(NoHeadless.class) public void builder() throws Exception { clickOn("#combo").clickOn("Odd pages"); final File file = folder.newFile("my.pdf"); SimpleSplitParametersBuilder builder = victim.getBuilder(onError); WaitForAsyncUtils.waitForAsyncFx(2000, () -> { builder.compress(true); FileOrDirectoryTaskOutput output = mock(FileOrDirectoryTaskOutput.class); builder.output(output); builder.existingOutput(ExistingOutputPolicy.OVERWRITE); builder.prefix("prefix"); PdfFileSource source = PdfFileSource.newInstanceNoPassword(file); builder.source(source); builder.version(PdfVersion.VERSION_1_7); SimpleSplitParameters params = builder.build(); assertTrue(params.isCompress()); assertEquals(ExistingOutputPolicy.OVERWRITE, params.getExistingOutputPolicy()); assertEquals(PdfVersion.VERSION_1_7, params.getVersion()); assertThat(params.getPages(6), contains(1, 3, 5)); assertThat(params.getPages(6), not(contains(2, 4, 6))); assertEquals("prefix", params.getOutputPrefix()); assertEquals(output, params.getOutput()); assertEquals(source, params.getSourceList().get(0)); assertEquals(OptimizationPolicy.AUTO, params.getOptimizationPolicy()); verify(onError, never()).accept(anyString()); }); }
@Test public void builderDisabledOptimization() throws Exception { clickOn("#combo").clickOn("Odd pages"); final File file = folder.newFile("my.pdf"); WaitForAsyncUtils.waitForAsyncFx(2000, () -> { SimpleSplitParametersBuilder builder = victim.getBuilder(onError); builder.compress(true); FileOrDirectoryTaskOutput output = mock(FileOrDirectoryTaskOutput.class); builder.output(output); builder.existingOutput(ExistingOutputPolicy.OVERWRITE); builder.prefix("prefix"); PdfFileSource source = PdfFileSource.newInstanceNoPassword(file); builder.source(source); builder.version(PdfVersion.VERSION_1_7); System.setProperty(SplitParametersBuilder.PDFSAM_DISABLE_SPLIT_OPTIMIZATION, Boolean.TRUE.toString()); SimpleSplitParameters params = builder.build(); assertEquals(OptimizationPolicy.NO, params.getOptimizationPolicy()); verify(onError, never()).accept(anyString()); }); System.setProperty(SplitParametersBuilder.PDFSAM_DISABLE_SPLIT_OPTIMIZATION, Boolean.FALSE.toString()); }