### Question:
MessageLookupContextRenderer extends
        ToStringValidationContextRenderer { @Override public String render(OValContext context) { if (context instanceof FieldContext) { final FieldContext ctx = (FieldContext) context; final String className = ctx.getField().getDeclaringClass().getName(); final String fieldName = ctx.getField().getName(); final String key = className + "." + fieldName; return messages.getMessage(key, key); } return super.render(context); } MessageLookupContextRenderer(MessageSource messages); @Override String render(OValContext context);  }### Answer:
@Test public void testRenderOValContextNonFieldContext() { final OValContext ovalContext = new ClassContext(MessageLookupContextRendererTest.class); final String expectedResult = MessageLookupContextRendererTest.class.getName(); final String result = testee.render(ovalContext); verify(messages, times(0)).getMessage(any(String.class), any(Object[].class), anyString(), any(Locale.class)); assertThat(result).isEqualTo(expectedResult); }
@Test public void testRenderOValContext() throws Exception { final String fieldName = "messages"; final OValContext ovalContext = new FieldContext( MessageLookupContextRendererTest.class .getDeclaredField(fieldName)); final String code = MessageLookupContextRendererTest.class.getName() + "." + fieldName; final String expectedResult = "Teststring"; when(messages.getMessage(code, null, code, locale)).thenReturn( expectedResult); final String result = testee.render(ovalContext); assertThat(result).isEqualTo(expectedResult); }