### Question:
AlternateMixSelectionPane extends MultipleSelectionPane implements TaskParametersBuildStep<AlternateMixParametersBuilder> { @Override public void apply(AlternateMixParametersBuilder builder, Consumer<String> onError) { if (table().getItems().isEmpty()) { onError.accept(DefaultI18nContext.getInstance().i18n("No PDF document has been selected")); } else { for (SelectionTableRowData row : table().getItems()) { String step = defaultIfBlank(row.pace.get(), "1").trim(); if (step.matches("[1-9]\\d*")) { PdfMixInput input = new PdfMixInput(row.descriptor().toPdfFileSource(), row.reverse.get(), Integer.parseInt(step)); input.addAllPageRanges(row.toPageRangeSet()); builder.addInput(input); } else { onError.accept(DefaultI18nContext.getInstance().i18n("Select a positive integer number as pace")); break; } } } } AlternateMixSelectionPane(String ownerModule); @Override void apply(AlternateMixParametersBuilder 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 invalidPace() throws Exception { populate(); victim.table().getItems().get(0).pace.set("Chuck"); victim.apply(builder, onError); verify(onError).accept(anyString()); verify(builder, never()).addInput(any()); }
@Test public void zeroPace() throws Exception { populate(); victim.table().getItems().get(0).pace.set("0"); victim.apply(builder, onError); verify(onError).accept(anyString()); verify(builder, never()).addInput(any()); }
@Test public void validInput() throws Exception { populate(); when(builder.hasInput()).thenReturn(Boolean.TRUE); victim.table().getItems().get(0).reverse.set(true); victim.table().getItems().get(0).pace.set("3"); victim.table().getItems().get(0).pageSelection.set("3-5,8"); victim.apply(builder, onError); verify(onError, never()).accept(anyString()); ArgumentCaptor<PdfMixInput> input = ArgumentCaptor.forClass(PdfMixInput.class); verify(builder).addInput(input.capture()); assertEquals(3, input.getValue().getStep()); assertTrue(input.getValue().isReverse()); assertThat(input.getValue().getPages(10), contains(3, 4, 5, 8)); }