BasenamePrefixProcessor implements PrefixProcessor { @Override public String process(String inputPrefix, NameGenerationRequest request) { if (nonNull(request) && isNotBlank(request.getOriginalName())) { return inputPrefix.replace("[BASENAME]", request.getOriginalName()); } return inputPrefix; }  @Override String process(String inputPrefix, NameGenerationRequest request);  }
@Test public void nullName() { String prefix = "prefix_[BASENAME]"; assertEquals(prefix, victim.process(prefix, nameRequest())); }
@Test public void testComplexProcess() { String prefix = "prefix_[BASENAME]"; String originalName = "name"; String expected = "prefix_name"; assertEquals(expected, victim.process(prefix, nameRequest().originalName(originalName))); }
@Test public void testComplexProcessStripExtension() { String prefix = "prefix_[BASENAME]"; String originalName = "name.pdf"; String expected = "prefix_name"; assertEquals(expected, victim.process(prefix, nameRequest().originalName(originalName))); }
@Test public void testComplexProcessStripExtensionOneCharName() { String prefix = "prefix_[BASENAME]"; String originalName = "x.pdf"; String expected = "prefix_x"; assertEquals(expected, victim.process(prefix, nameRequest().originalName(originalName))); }
@Test public void testUnescapedRegexInBasename() { String prefix = "[BASENAME]"; String originalName = "x$5.pdf"; String expected = "x$5"; assertEquals(expected, victim.process(prefix, nameRequest().originalName(originalName))); }