### Question:
RotateSelectionPane extends MultipleSelectionPane implements TaskParametersBuildStep<RotateParametersBuilder> { @Override public void apply(RotateParametersBuilder builder, Consumer<String> onError) { try { table().getItems().stream().filter(s -> !Objects.equals("0", trim(s.pageSelection.get()))) .forEach(i -> builder.addInput(i.descriptor().toPdfFileSource(), i.toPageRangeSet())); 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()); } } RotateSelectionPane(String ownerModule); @Override void apply(RotateParametersBuilder builder, Consumer<String> onError);  }### Answer:
@Test public void empty() { victim.apply(builder, onError); verify(onError).accept(anyString()); verify(builder, never()).addInput(any(), any()); }
@Test public void emptyPageSelection() throws Exception { populate(); when(builder.hasInput()).thenReturn(Boolean.TRUE); victim.apply(builder, onError); verify(onError, never()).accept(anyString()); ArgumentCaptor<Set> ranges = ArgumentCaptor.forClass(Set.class); verify(builder).addInput(any(), ranges.capture()); assertTrue(ranges.getValue().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<Set> ranges = ArgumentCaptor.forClass(Set.class); verify(builder).addInput(any(), ranges.capture()); assertEquals(2, ranges.getValue().size()); }
@Test public void converstionException() throws Exception { populate(); doThrow(new ConversionException("message")).when(builder).addInput(any(), any()); victim.apply(builder, onError); verify(builder).addInput(any(), any()); verify(onError).accept(eq("message")); }
@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(), any()); }