### Question:
BarcodeExtractor { public String extractFromPdf(String input) { if (input != null && input.endsWith(".pdf")) { Matcher m = p.matcher(input); if (m.find()) return m.group(); } return ""; }  String extractFromPdf(String input); String extract(String input); final static BarcodeExtractor instance; }### Answer:
@Test public void testExtractFromFileName() throws Exception { assertThat(instance.extractFromPdf("test this file name with barcode :1990010086151, is it right ?.pdf"), equalTo("1990010086151")); assertThat(instance.extractFromPdf(" 1990010086151-this is the pdf, is it right ?.pdf"), equalTo("1990010086151")); }
@Test public void testExtractFromBlankBarcode() throws Exception { assertThat(instance.extractFromPdf("test this file name with barcode :, is it right ?.pdf"), equalTo("")); }
@Test public void testExtractForNullInput() throws Exception { assertThat(instance.extractFromPdf(null), equalTo("")); }