Search in sources :

Example 1 with EditorEvent

use of com.vaadin.flow.component.grid.editor.EditorEvent in project flow-components by vaadin.

the class EditorImplTest method save_editorIsOpened_editorIsInBufferedMode_beanIsInvalid_editorIsNotClosed.

@Test
public void save_editorIsOpened_editorIsInBufferedMode_beanIsInvalid_editorIsNotClosed() {
    editor.getBinder().forField(new TextField()).withValidator(value -> !value.equals("bar"), "").bind(ValueProvider.identity(), (item, value) -> {
    });
    editor.editItem("bar");
    fakeClientResponse();
    editor.refreshedItems.clear();
    editor.setBuffered(true);
    AtomicReference<StatusChangeEvent> statusEventCapture = new AtomicReference<>();
    AtomicReference<EditorEvent<String>> saveEventCapture = new AtomicReference<>();
    AtomicReference<EditorEvent<String>> closeEventCapture = new AtomicReference<>();
    Assert.assertFalse(doSave(statusEventCapture, saveEventCapture, closeEventCapture));
    Assert.assertEquals(0, editor.refreshedItems.size());
    Assert.assertNotNull(statusEventCapture.get());
    Assert.assertNull(saveEventCapture.get());
    Assert.assertNull(closeEventCapture.get());
    Assert.assertTrue(statusEventCapture.get().hasValidationErrors());
}
Also used : VaadinSession(com.vaadin.flow.server.VaadinSession) Grid(com.vaadin.flow.component.grid.Grid) ValueProvider(com.vaadin.flow.function.ValueProvider) Binder(com.vaadin.flow.data.binder.Binder) EditorImpl(com.vaadin.flow.component.grid.editor.EditorImpl) Test(org.junit.Test) EditorEvent(com.vaadin.flow.component.grid.editor.EditorEvent) StatusChangeEvent(com.vaadin.flow.data.binder.StatusChangeEvent) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) List(java.util.List) Rule(org.junit.Rule) UI(com.vaadin.flow.component.UI) Assert(org.junit.Assert) ExpectedException(org.junit.rules.ExpectedException) TextField(com.vaadin.flow.component.textfield.TextField) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) EditorEvent(com.vaadin.flow.component.grid.editor.EditorEvent) StatusChangeEvent(com.vaadin.flow.data.binder.StatusChangeEvent) TextField(com.vaadin.flow.component.textfield.TextField) AtomicReference(java.util.concurrent.atomic.AtomicReference) Test(org.junit.Test)

Aggregations

UI (com.vaadin.flow.component.UI)1 Grid (com.vaadin.flow.component.grid.Grid)1 EditorEvent (com.vaadin.flow.component.grid.editor.EditorEvent)1 EditorImpl (com.vaadin.flow.component.grid.editor.EditorImpl)1 TextField (com.vaadin.flow.component.textfield.TextField)1 Binder (com.vaadin.flow.data.binder.Binder)1 StatusChangeEvent (com.vaadin.flow.data.binder.StatusChangeEvent)1 ValueProvider (com.vaadin.flow.function.ValueProvider)1 VaadinSession (com.vaadin.flow.server.VaadinSession)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 ExpectedException (org.junit.rules.ExpectedException)1 Mockito.mock (org.mockito.Mockito.mock)1