### Question:
BrowsablePdfInputField extends BrowsableFileField implements TaskParametersBuildStep<SinglePdfSourceTaskParametersBuilder<?>> { @Override public void apply(SinglePdfSourceTaskParametersBuilder<?> builder, Consumer<String> onError) { getTextField().validate(); if (getTextField().getValidationState() == ValidationState.VALID) { builder.source(new PdfFileSourceAdapter(getTextField().getText()).getPdfFileSource()); } else { onError.accept(DefaultI18nContext.getInstance().i18n("The selected PDF file is invalid")); } } BrowsablePdfInputField(); @Override void apply(SinglePdfSourceTaskParametersBuilder<?> builder, Consumer<String> onError);  }### Answer:
@Test public void valid() throws IOException { BrowsablePdfInputField victim = new BrowsablePdfInputField(); File value = folder.newFile("test.pdf"); victim.getTextField().setText(value.getAbsolutePath()); victim.apply(builder, onError); verify(builder).source(argThat(hasProperty("source", equalTo(value)))); verify(onError, never()).accept(anyString()); }
@Test public void invalid() { BrowsablePdfInputField victim = new BrowsablePdfInputField(); victim.enforceValidation(true, true); victim.getTextField().setText("ChuckNorris"); victim.apply(builder, onError); verify(builder, never()).source(any()); verify(onError).accept(anyString()); }