PrefixTypesChain { public String process(String prefix, NameGenerationRequest request) { LOG.trace("Performing prefix processing with first level prefix chain"); String retVal = processChain(prefix, request, prefixesChanin); if (prefixesChanin.isEmpty()) { retVal = prefixPrepend.process(retVal, request); } if (!ensureUniqueness) { retVal = pageNumberPrepend.process(retVal, request); } return extensionProcessor.process(toSafeFilename(retVal), request); } PrefixTypesChain(String prefix); String process(String prefix, NameGenerationRequest request);  }
@Test public void current() { String prefix = "prefix_[CURRENTPAGE]"; assertEquals("prefix_5.pdf", new PrefixTypesChain(prefix).process(prefix, nameRequest().originalName("name").page(5))); }
@Test public void currentAndBasename() { String prefix = "prefix_[CURRENTPAGE]_[BASENAME]"; assertEquals("prefix_5_name.pdf", new PrefixTypesChain(prefix).process(prefix, nameRequest().originalName("name").page(5))); }
@Test public void noComplexPrefixYesPage() { String prefix = "prefix_"; assertEquals("5_prefix_name.pdf", new PrefixTypesChain(prefix).process(prefix, nameRequest().originalName("name").page(5))); }
@Test public void noComplexPrefixNoPage() { String prefix = "prefix_"; assertEquals("prefix_name.pdf", new PrefixTypesChain(prefix).process(prefix, nameRequest().originalName("name"))); }
@Test public void basenameYesPage() { String prefix = "prefix_[BASENAME]"; assertEquals("5_prefix_name.pdf", new PrefixTypesChain(prefix).process(prefix, nameRequest().originalName("name").page(5))); }
@Test public void basenameNoPage() { String prefix = "prefix_[BASENAME]"; assertEquals("prefix_name.pdf", new PrefixTypesChain(prefix).process(prefix, nameRequest().originalName("name"))); }
@Test public void filenumberAndExtension() { String prefix = "prefix_[FILENUMBER]_[BASENAME]"; assertEquals("prefix_3_name.txt", new PrefixTypesChain(prefix).process(prefix, nameRequest("txt").originalName("name.pdf").fileNumber(3))); }
@Test public void invalidCharsText() { String prefix = "[TEXT] [BASENAME]"; assertEquals("This has some name.txt", new PrefixTypesChain(prefix).process(prefix, nameRequest("txt").originalName("name.pdf").text(" This \n \u00A0 has \t some $§°éç"))); }