### Question:
CaptionComponentWrapper implements ComponentWrapper { @Override public void setValidationMessages(MessageList messagesForProperty) { if (component instanceof AbstractComponent) { AbstractComponent field = (AbstractComponent)component; field.setComponentError(getErrorHandler(messagesForProperty)); } } CaptionComponentWrapper(Component component, WrapperType wrapperType);  CaptionComponentWrapper(String id, Component component, WrapperType wrapperType); @Override void setId(String id); @Override void setLabel(String labelText); @Override void setEnabled(boolean enabled); @Override void setVisible(boolean visible); @Override void setTooltip(String text); @Override Component getComponent(); @Override void setValidationMessages(MessageList messagesForProperty); @Override WrapperType getType(); @Override void registerBinding(Binding binding); @Override String toString();  }### Answer:
@Test public void testSetValidationMessages() { AbstractComponent component = mock(AbstractComponent.class); CaptionComponentWrapper wrapper = new CaptionComponentWrapper("testID", component, WrapperType.FIELD); ArgumentCaptor<ErrorMessage> errorMessageCaptor = ArgumentCaptor.forClass(ErrorMessage.class); MessageList messages = new MessageList(Message.newError("e", "testError"), Message.newWarning("w", "testWarning")); wrapper.setValidationMessages(messages); verify(component).setComponentError(errorMessageCaptor.capture()); @NonNull ErrorMessage errorMessage = errorMessageCaptor.getValue(); assertThat(errorMessage.getErrorLevel(), is(ErrorLevel.ERROR)); assertThat(errorMessage.getFormattedHtmlMessage(), containsString("testError")); assertThat(errorMessage.getFormattedHtmlMessage(), containsString("testWarning")); }
@Test public void testSetValidationMessages_Empty() { AbstractComponent component = mock(AbstractComponent.class); CaptionComponentWrapper wrapper = new CaptionComponentWrapper("testID", component, WrapperType.FIELD); MessageList messages = new MessageList(); wrapper.setValidationMessages(messages); verify(component).setComponentError(null); }