FileNumberPrefixProcessor extends NumberPrefixProcessor { @Override public String process(String inputPrefix, NameGenerationRequest request) { String retVal = ""; if (request != null && request.getFileNumber() != null) { retVal = findAndReplace(inputPrefix, request.getFileNumber()); } return StringUtils.isBlank(retVal) ? inputPrefix : retVal; } FileNumberPrefixProcessor(); @Override String process(String inputPrefix, NameGenerationRequest request);  }
@Test public void nullFileNumber() { String prefix = "prefix_[FILENUMBER]_[BASENAME]"; assertEquals(prefix, victim.process(prefix, nameRequest())); }
@Test public void testComplexProcess() { String prefix = "prefix_[FILENUMBER]_[BASENAME]"; String expected = "prefix_5_[BASENAME]"; assertEquals(expected, victim.process(prefix, nameRequest().fileNumber(fileNumber))); }
@Test public void testComplexProcessStartingPage() { String prefix = "prefix_[FILENUMBER12]_[BASENAME]"; String expected = "prefix_17_[BASENAME]"; assertEquals(expected, victim.process(prefix, nameRequest().fileNumber(fileNumber))); }
@Test public void testComplexProcessWithPatter() { String prefix = "prefix_[FILENUMBER###]_[BASENAME]"; String expected = "prefix_005_[BASENAME]"; assertEquals(expected, victim.process(prefix, nameRequest().fileNumber(fileNumber))); }
@Test public void testComplexProcessWithPatterStartingPage() { String prefix = "prefix_[FILENUMBER###10]_[BASENAME]"; String expected = "prefix_015_[BASENAME]"; assertEquals(expected, victim.process(prefix, nameRequest().fileNumber(fileNumber))); }
@Test public void testComplexProcessDouble() { String prefix = "prefix_[FILENUMBER]_[FILENUMBER]"; String expected = "prefix_5_5"; assertEquals(expected, victim.process(prefix, nameRequest().fileNumber(fileNumber))); }
@Test public void testComplexProcessDoubleSinglePattern() { String prefix = "prefix_[FILENUMBER###]_[FILENUMBER]"; String expected = "prefix_005_5"; assertEquals(expected, victim.process(prefix, nameRequest().fileNumber(fileNumber))); }
@Test public void testComplexProcessDoubleSinglePatternStartingPage() { String prefix = "prefix_[FILENUMBER###23]_[FILENUMBER32]"; String expected = "prefix_028_37"; assertEquals(expected, victim.process(prefix, nameRequest().fileNumber(fileNumber))); }
@Test public void testComplexProcessDoubleSinglePatternNegativeStartingPage() { String prefix = "prefix_[FILENUMBER###-23]_[FILENUMBER-2]"; String expected = "prefix_-018_3"; assertEquals(expected, victim.process(prefix, nameRequest().fileNumber(fileNumber))); }
@Test public void testComplexProcessDoubleDoublePattern() { String prefix = "prefix_[FILENUMBER###]_[FILENUMBER##]"; String expected = "prefix_005_05"; assertEquals(expected, victim.process(prefix, nameRequest().fileNumber(fileNumber))); }