### Question:
DynamicPathTemplate implements Serializable { private String replaceDynamicPart(Map<String, String> attributes) { return StringSubstitutor.replace(dynamicPart, attributes); } DynamicPathTemplate(String rawPath); List<String> getPlaceholderNames(); Map<String, String> getPlaceholderAttributes(List<String> values); String replaceDynamicPart(List<String> values); List<String> extractValuesFrom(Map<String, String> attributes); final String staticPrefix; final String dynamicPart; }### Answer:
@Test public void testReplaceDynamicPart() { final DynamicPathTemplate path = new DynamicPathTemplate("tmp/${bar:-b}-${foo:-f}/test"); assertEquals("hi-there/test", path.replaceDynamicPart(ImmutableList.of("hi", "there"))); }
@Test(expected = IllegalArgumentException.class) public void testReplaceDynamicPartThrows() { final DynamicPathTemplate path = new DynamicPathTemplate("tmp/${bar:-b}-${foo:-f}/test"); assertEquals("hi-there/test", path.replaceDynamicPart(ImmutableList.of("hi"))); }
@Test public void testWithoutDynamicPart() { final DynamicPathTemplate path = new DynamicPathTemplate("tmp/"); assertEquals("", path.replaceDynamicPart(ImmutableList.of())); }