summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorIlia Motornyi <elmot@vaadin.com>2017-03-14 14:33:02 +0200
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-03-16 16:21:24 +0200
commit48fb4b8afd4ba20c65e1bc46941e77334199ddbd (patch)
tree12c8f867248e4d1771265e4474ef046bdabf3dc5 /server
parent981c9146f3d02189d455cfd244fd6c7da82bddd6 (diff)
downloadvaadin-framework-48fb4b8afd4ba20c65e1bc46941e77334199ddbd.tar.gz
vaadin-framework-48fb4b8afd4ba20c65e1bc46941e77334199ddbd.zip
Make test for EditorSaveEvent.bean field
* Fixes #8810, #8658
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java3
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/grid/EditorImplTest.java28
2 files changed, 25 insertions, 6 deletions
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java b/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java
index dad45f0fbb..07b792a221 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java
@@ -265,9 +265,10 @@ public class EditorImpl<T> extends AbstractGridExtension<T>
}
private void doCancel(boolean afterBeingSaved) {
+ T editedBean = edited;
doClose();
if (!afterBeingSaved) {
- eventRouter.fireEvent(new EditorCancelEvent<>(this, edited));
+ eventRouter.fireEvent(new EditorCancelEvent<>(this, editedBean));
}
}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/EditorImplTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/EditorImplTest.java
index de3c6569e5..61fd282edf 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/grid/EditorImplTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/grid/EditorImplTest.java
@@ -18,6 +18,7 @@ package com.vaadin.tests.server.component.grid;
import java.util.Optional;
import java.util.stream.Stream;
+import com.vaadin.ui.Grid;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -43,6 +44,11 @@ public class EditorImplTest {
public static class TestEditorImpl extends EditorImpl<Object> implements
EditorSaveListener<Object>, EditorCancelListener<Object> {
+ @Override
+ public void doEdit(Object bean) {
+ super.doEdit(bean);
+ }
+
public TestEditorImpl() {
super(new PropertySet<Object>() {
@Override
@@ -56,6 +62,12 @@ public class EditorImplTest {
return null;
}
});
+
+ }
+
+ @Override
+ public Grid<Object> getParent() {
+ return new Grid<>();
}
EditorCancelEvent<Object> cancelEvent;
@@ -65,11 +77,6 @@ public class EditorImplTest {
EditorServerRpc rpc;
@Override
- public boolean isOpen() {
- return true;
- }
-
- @Override
public boolean isBuffered() {
return true;
}
@@ -99,6 +106,8 @@ public class EditorImplTest {
}
}
+ private Object beanToEdit = new Object();
+
private TestEditorImpl editor;
private Binder<Object> binder;
@@ -109,6 +118,8 @@ public class EditorImplTest {
editor.addCancelListener(editor);
binder = Mockito.mock(Binder.class);
editor.setBinder(binder);
+ editor.setEnabled(true);
+ editor.doEdit(beanToEdit);
}
@Test
@@ -121,6 +132,7 @@ public class EditorImplTest {
Assert.assertNull(editor.cancelEvent);
Assert.assertEquals(editor, editor.saveEvent.getSource());
+ Assert.assertEquals(beanToEdit, editor.saveEvent.getBean());
}
@Test
@@ -131,6 +143,8 @@ public class EditorImplTest {
Assert.assertNotNull(editor.cancelEvent);
Assert.assertEquals(editor, editor.cancelEvent.getSource());
+
+ Assert.assertEquals(beanToEdit, editor.cancelEvent.getBean());
}
@Test
@@ -143,6 +157,8 @@ public class EditorImplTest {
Assert.assertNull(editor.cancelEvent);
Assert.assertEquals(editor, editor.saveEvent.getSource());
+
+ Assert.assertEquals(beanToEdit, editor.saveEvent.getBean());
}
@Test
@@ -153,6 +169,8 @@ public class EditorImplTest {
Assert.assertNotNull(editor.cancelEvent);
Assert.assertEquals(editor, editor.cancelEvent.getSource());
+
+ Assert.assertEquals(beanToEdit, editor.cancelEvent.getBean());
}
@Test