### Question:
TemplateMessageInterpolator extends DelegatingMessageInterpolator { @Override public String doInterpolate(String messageTemplate, Context context) { Map<String, Object> attributes = context.getConstraintDescriptor() .getAttributes(); return stringInterpolator.interpolate(messageTemplate, attributes); } TemplateMessageInterpolator(MessageInterpolator delegate,
                                     StringInterpolator stringInterpolator); @Override String doInterpolate(String messageTemplate, Context context);  }### Answer:
@Test public void testDoInterpolate() { String str = "My ${var1} string"; Map<String, Object> variables = ImmutableMap.<String, Object> of("var1", "value1"); ConstraintDescriptor descriptor = mock(ConstraintDescriptor.class); when(context.getConstraintDescriptor()).thenReturn(descriptor); when(descriptor.getAttributes()).thenReturn(variables); assertEquals("My value1 string", interpolator.doInterpolate(str, context)); }