@Test public void test_noEventFiredWhenNoEventInChangedVariable() { final FormItemClickHandler handler = mock(FormItemClickHandler.class); formItemIcon.addFormItemClickHandler(handler); final Map<String, Object> variables = Maps.newHashMap(); variables.put("something", 1); formItemIcon.changeVariables(null, variables); verify(handler, never()).onFormItemClick(any(FormItemIconClickEvent.class)); }
@Test public void test_firesEventFromChangedVariables() { final FormItemClickHandler handler = mock(FormItemClickHandler.class); formItemIcon.addFormItemClickHandler(handler); final Map<String, Object> variables = Maps.newHashMap(); variables.put("formItemIconClickEvent.form", mock(DynamicForm.class)); variables.put("formItemIconClickEvent.item", mock(FormItem.class)); variables.put("formItemIconClickEvent.icon", mock(FormItemIcon.class)); formItemIcon.changeVariables(null, variables); final ArgumentCaptor<FormItemIconClickEvent> captor = ArgumentCaptor.forClass(FormItemIconClickEvent.class); verify(handler).onFormItemClick(captor.capture()); assertEquals(variables.get("formItemIconClickEvent.form"), captor.getValue().getForm()); assertEquals(variables.get("formItemIconClickEvent.item"), captor.getValue().getItem()); assertEquals(variables.get("formItemIconClickEvent.icon"), captor.getValue().getIcon()); }