PrefixAndSuffixPageTitlePostProcessor implements PageTitlePostProcessor { @Override public String process(String pageTitle) { return this.prefix.orElse("") .concat(pageTitle) .concat(this.suffix.orElse("")); } PrefixAndSuffixPageTitlePostProcessor(String prefix, String suffix); @Override String process(String pageTitle);  }
@Test public void process_pageTitlePostProcessorWithPrefixAndSuffix_returnsPageTitleWithPrefixAndSuffix() { PrefixAndSuffixPageTitlePostProcessor prefixAndSuffixPageTitlePostProcessor = new PrefixAndSuffixPageTitlePostProcessor("prefix-", "-suffix"); String postProcessedPageTitle = prefixAndSuffixPageTitlePostProcessor.process("page-title"); assertThat(postProcessedPageTitle, is("prefix-page-title-suffix")); }
@Test public void process_pageTitlePostProcessorWithOnlyPrefix_returnsPageTitleWithPrefix() { PrefixAndSuffixPageTitlePostProcessor prefixAndSuffixPageTitlePostProcessor = new PrefixAndSuffixPageTitlePostProcessor("prefix-", null); String postProcessedPageTitle = prefixAndSuffixPageTitlePostProcessor.process("page-title"); assertThat(postProcessedPageTitle, is("prefix-page-title")); }
@Test public void process_pageTitlePostProcessorWithOnlySuffix_returnsPageTitleWithSuffix() { PrefixAndSuffixPageTitlePostProcessor prefixAndSuffixPageTitlePostProcessor = new PrefixAndSuffixPageTitlePostProcessor(null, "-suffix"); String postProcessedPageTitle = prefixAndSuffixPageTitlePostProcessor.process("page-title"); assertThat(postProcessedPageTitle, is("page-title-suffix")); }
@Test public void process_pageTitlePostProcessorWithoutPrefixAndSuffix_returnsPageTitleWithoutPrefixOrSuffix() { PrefixAndSuffixPageTitlePostProcessor prefixAndSuffixPageTitlePostProcessor = new PrefixAndSuffixPageTitlePostProcessor(null, null); String postProcessedPageTitle = prefixAndSuffixPageTitlePostProcessor.process("page-title"); assertThat(postProcessedPageTitle, is("page-title")); }