@Test(expected = ValidateFormException.class)
public void shouldThrowExceptionWhenFieldsIsInvalid() throws Exception {

    IObject serverForm = mock(IObject.class);
    IObject clientForm = mock(IObject.class);
    ValidateFormDataMessage message = mock(ValidateFormDataMessage.class);
    when(message.getFormFromRequest()).thenReturn(clientForm);
    when(message.getForm()).thenReturn(serverForm);
    Iterator serverIterator = mock(Iterator.class);
    when(serverForm.iterator()).thenReturn(serverIterator);
    Map.Entry entry = mock(Map.Entry.class);
    IFieldName fieldFieldName = mock(IFieldName.class);
    when(serverIterator.next()).thenReturn(entry, null);
    when(serverIterator.hasNext()).thenReturn(false);
    when(entry.getKey()).thenReturn(fieldFieldName);
    IObject fieldIObject = mock(IObject.class);
    when(serverForm.getValue(fieldFieldName)).thenReturn(fieldIObject);
    when(rulesF.in(fieldIObject)).thenReturn("обязательное");
    when(clientForm.getValue(fieldFieldName)).thenReturn("");
    IObject resultObject = mock(IObject.class);
    IKey iobjectKey = mock(IKey.class);
    when(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject")).thenReturn(iobjectKey);
    when(IOC.resolve(iobjectKey)).thenReturn(resultObject);
    actor.validate(message);
}