### Question:
SpecialValuesReplace { @Nonnull public static String replace( @Nullable final String input, @Nonnull final Map<String, BundleInfo> resourceBundles, @Nullable final Object methodCallTarget, @Nullable final Properties properties, @Nonnull final Locale locale) { if (input == null) { return ""; } if (!Split.containsKey(input)) { return input; } List<String> parts = Split.split(input); for (int idx=0; idx<parts.size(); idx++) { String part = parts.get(idx); String prev = getPrev(parts, idx); if (isSpecialTag(part, prev)) { String value = removeQuotes(part); if (value.startsWith(KEY_ENV)) { parts.set(idx, handleENV(part)); } else if (value.startsWith(KEY_PROP)) { parts.set(idx, handleProperties(part, properties)); } else if (value.startsWith(KEY_CALL)) { parts.set(idx, handleCall(part, methodCallTarget)); } else { parts.set(idx, handleLocalize(part, resourceBundles, locale)); } } else { if (endsWithQuote(prev)) { assert prev != null; parts.set(idx-1, prev.substring(0, prev.length()-1)); } } } String result = Split.join(parts); if (log.isLoggable(Level.FINER)) { log.finer(MessageFormat.format("Parsed input \"{0}\" to \"{1}\"", input, result)); } return result; }  @Nonnull static String replace(
      @Nullable final String input,
      @Nonnull final Map<String, BundleInfo> resourceBundles,
      @Nullable final Object methodCallTarget,
      @Nullable final Properties properties,
      @Nonnull final Locale locale);  }### Answer:
@Test public void testParseSimpleInput() { Assert.assertEquals("", SpecialValuesReplace.replace(null, null, null, null, null)); Assert.assertEquals("", SpecialValuesReplace.replace("", null, null, null, null)); Assert.assertEquals("abc", SpecialValuesReplace.replace("abc", null, null, null, null)); Assert.assertEquals("${abc}", SpecialValuesReplace.replace("${abc}", null, null, null, null)); }
@Test public void testParsePropInput() { Assert.assertEquals("${PROP.doesNotExist}", SpecialValuesReplace.replace("${PROP.doesNotExist}", null, null, null, null)); System.getProperties().setProperty("nifty.test", "existsInSystem"); Properties myProperties = new Properties(); myProperties.setProperty("nifty.test", "existsInMyProperties"); Assert.assertEquals("existsInSystem", SpecialValuesReplace.replace("${PROP.nifty.test}", null, null, null, null)); Assert.assertEquals("existsInMyProperties", SpecialValuesReplace.replace("${PROP.nifty.test}", null, null, myProperties, null)); }
@Test public void testParseEnvInput() { Assert.assertEquals("${ENV.doesNotExist}", SpecialValuesReplace.replace("${ENV.doesNotExist}", null, null, null, null)); String path = SpecialValuesReplace.replace("${ENV.PATH}", null, null, null, null); Assert.assertNotNull(path); Assert.assertTrue(path.length() > 0); Assert.assertFalse("ENV.PATH".equals(path)); }
@Test public void testParseObjectInput() { Assert.assertEquals("${CALL.getValue()}", SpecialValuesReplace.replace("${CALL.getValue()}", null, null, null, null)); Assert.assertEquals("called", SpecialValuesReplace.replace("${CALL.getValue()}", null, new MyObjectCallback(), null, null)); Assert.assertEquals("${CALL.getNonExisting()}", SpecialValuesReplace.replace("${CALL.getNonExisting()}", null, null, null, null)); }
@Test public void testQuoting() { Assert.assertEquals("${CALL.getValue()}", SpecialValuesReplace.replace("\\${CALL.getValue()}", null, new MyObjectCallback(), null, null)); }
@Test public void testLocalizeBasename() { Map<String, BundleInfo> resources = new HashMap<String, BundleInfo>(); resources.put("id", new BundleInfoBasename("stuff")); assertEquals("value", SpecialValuesReplace.replace("${id.test}", resources, null, null, null)); }