CurrentPagePrefixProcessor extends NumberPrefixProcessor { @Override public String process(String inputPrefix, NameGenerationRequest request) { String retVal = ""; if (request != null && request.getPage() != null) { retVal = findAndReplace(inputPrefix, request.getPage()); } return StringUtils.isBlank(retVal) ? inputPrefix : retVal; } CurrentPagePrefixProcessor(); @Override String process(String inputPrefix, NameGenerationRequest request);  }
@Test public void nullPage() { String prefix = "prefix_[CURRENTPAGE]_[BASENAME]"; assertEquals(prefix, victim.process(prefix, nameRequest())); }
@Test public void testComplexProcess() { String prefix = "prefix_[CURRENTPAGE]_[BASENAME]"; String expected = "prefix_5_[BASENAME]"; assertEquals(expected, victim.process(prefix, nameRequest().page(page))); }
@Test public void testComplexProcessStartingPage() { String prefix = "prefix_[CURRENTPAGE12]_[BASENAME]"; String expected = "prefix_17_[BASENAME]"; assertEquals(expected, victim.process(prefix, nameRequest().page(page))); }
@Test public void testComplexProcessWithPatterStartingPage() { String prefix = "prefix_[CURRENTPAGE###10]_[BASENAME]"; String expected = "prefix_015_[BASENAME]"; assertEquals(expected, victim.process(prefix, nameRequest().page(page))); }
@Test public void testComplexProcessWithPatter() { String prefix = "prefix_[CURRENTPAGE###]_[BASENAME]"; String expected = "prefix_005_[BASENAME]"; assertEquals(expected, victim.process(prefix, nameRequest().page(page))); }
@Test public void testComplexProcessDouble() { String prefix = "prefix_[CURRENTPAGE]_[CURRENTPAGE]"; String expected = "prefix_5_5"; assertEquals(expected, victim.process(prefix, nameRequest().page(page))); }
@Test public void testComplexProcessDoubleSinglePattern() { String prefix = "prefix_[CURRENTPAGE###]_[CURRENTPAGE]"; String expected = "prefix_005_5"; assertEquals(expected, victim.process(prefix, nameRequest().page(page))); }
@Test public void testComplexProcessDoubleSinglePatternStartingPage() { String prefix = "prefix_[CURRENTPAGE###23]_[CURRENTPAGE32]"; String expected = "prefix_028_37"; assertEquals(expected, victim.process(prefix, nameRequest().page(page))); }
@Test public void testComplexProcessDoubleSinglePatternNegativeStartingPage() { String prefix = "prefix_[CURRENTPAGE###-23]_[CURRENTPAGE-5]"; String expected = "prefix_-018_0"; assertEquals(expected, victim.process(prefix, nameRequest().page(page))); }
@Test public void testComplexProcessDoubleDoublePattern() { String prefix = "prefix_[CURRENTPAGE###]_[CURRENTPAGE##]"; String expected = "prefix_005_05"; assertEquals(expected, victim.process(prefix, nameRequest().page(page))); }