/** * Executes this placeholder for the given {@link String} by searching all occurrences of the regular expression * supplied in the constructor and replaces them with the retrieved replacement from * {@link #getReplacementFor(String)}. If the regular expression does not match, an exact copy of the given * {@link String} is returned. * * @param formatPattern to be processed * @return the given {@code formatPattern} containing the generated replacements instead of matching patterns */ public String process(String formatPattern) { ReplacementData data = ReplacementData.of(method, idx, Arrays.asList(parameters)); return super.process(data, formatPattern); }
protected String getReplacementFor(String placeholder) { ReplacementData data = ReplacementData.of(method, idx, Arrays.asList(parameters)); return super.getReplacementFor(placeholder, data); } }
/** * @return the list of placeholders used to create the display name for each dataprovider test case */ protected List<? extends BasePlaceholder> getDefaultPlaceholders() { List<BasePlaceholder> result = new ArrayList<>(); result.add(new ArgumentPlaceholder()); result.add(new CanonicalClassNamePlaceholder()); // must be before SimpleClassNamePlaceholder result.add(new CompleteMethodSignaturePlaceholder()); // must be before SimpleClassNamePlaceholder result.add(new IndexPlaceholder()); result.add(new NamedArgumentPlaceholder()); result.add(new SimpleClassNamePlaceholder()); result.add(new SimpleMethodNamePlaceholder()); return result; }
/** * Executes this placeholder for the given {@link String} by searching all occurrences of the regular expression * supplied in the constructor and replaces them with the retrieved replacement from * {@link #getReplacementFor(String)}. If the regular expression does not match, an exact copy of the given * {@link String} is returned. * * @param formatPattern to be processed * @return the given {@code formatPattern} containing the generated replacements instead of matching patterns */ public String process(String formatPattern) { ReplacementData data = ReplacementData.of(method, idx, Arrays.asList(parameters)); return super.process(data, formatPattern); }
protected String getReplacementFor(String placeholder) { ReplacementData data = ReplacementData.of(method, idx, Arrays.asList(parameters)); return super.getReplacementFor(placeholder, data); } }
@Test public void testProcessShouldReplacePlaceholder() { // Given: final Method method = Methods.anyMethod(); ReplacementData data = ReplacementData.of(method, 0, Arrays.<Object>asList(0)); // When: String result = underTest.process(data, "%m"); // Then: assertThat(result).isEqualTo(method.getName()); } }