### Question:
MergeSelectionPane extends MultipleSelectionPane implements TaskParametersBuildStep<MergeParametersBuilder> { @Override public void apply(MergeParametersBuilder builder, Consumer<String> onError) { try { table().getItems().stream().filter(s -> !Objects.equals("0", trim(s.pageSelection.get()))) .map(i -> new PdfMergeInput(i.descriptor().toPdfFileSource(), i.toPageRangeSet())) .forEach(builder::addInput); if (!builder.hasInput()) { onError.accept(DefaultI18nContext.getInstance().i18n("No PDF document has been selected")); } } catch (ConversionException e) { LOG.error(e.getMessage()); onError.accept(e.getMessage()); } } MergeSelectionPane(String ownerModule); @Override void apply(MergeParametersBuilder builder, Consumer<String> onError);  }### Answer:
@Test public void empty() { victim.apply(builder, onError); verify(onError).accept(anyString()); verify(builder, never()).addInput(any()); }
@Test public void emptyByZeroPagesSelected() throws Exception { populate(); victim.table().getItems().get(0).pageSelection.set("0"); victim.apply(builder, onError); verify(onError).accept(anyString()); verify(builder, never()).addInput(any()); }
@Test public void emptyPageSelection() throws Exception { populate(); when(builder.hasInput()).thenReturn(Boolean.TRUE); victim.apply(builder, onError); verify(onError, never()).accept(anyString()); ArgumentCaptor<PdfMergeInput> input = ArgumentCaptor.forClass(PdfMergeInput.class); verify(builder).addInput(input.capture()); assertTrue(input.getValue().getPageSelection().isEmpty()); }
@Test public void notEmptyPageSelection() throws Exception { populate(); when(builder.hasInput()).thenReturn(Boolean.TRUE); victim.table().getItems().get(0).pageSelection.set("1,3-10"); victim.apply(builder, onError); verify(onError, never()).accept(anyString()); ArgumentCaptor<PdfMergeInput> input = ArgumentCaptor.forClass(PdfMergeInput.class); verify(builder).addInput(input.capture()); assertEquals(2, input.getValue().getPageSelection().size()); }
@Test public void converstionException() throws Exception { populate(); doThrow(new ConversionException("message")).when(builder).addInput(any()); victim.apply(builder, onError); verify(builder).addInput(any()); verify(onError).accept(eq("message")); }