use of org.kie.workbench.common.forms.processing.engine.handling.FieldChangeHandler in project kie-wb-common by kiegroup.
the class SubFormWidgetTest method testAddFieldChangeHandler.
@Test
public void testAddFieldChangeHandler() {
FieldChangeHandler handler = mock(FieldChangeHandler.class);
subFormWidget.addFieldChangeHandler(handler);
verify(formRenderer).addFieldChangeHandler(same(handler));
}
use of org.kie.workbench.common.forms.processing.engine.handling.FieldChangeHandler in project kie-wb-common by kiegroup.
the class FormPropertiesWidgetTest method testShowDomainObject.
@Test
@SuppressWarnings("unchecked")
public void testShowDomainObject() {
tested.init();
final String fieldName = "fieldName";
final String fieldValue = "fieldValue";
final Command callback = mock(Command.class);
when(formsCanvasSessionHandler.getDiagram()).thenReturn(diagram);
when(domainObject.getDomainObjectUUID()).thenReturn(DOMAIN_OBJECT_UUID);
when(domainObject.getDomainObjectNameTranslationKey()).thenReturn(DOMAIN_OBJECT_TRANSLATION_KEY);
when(formsCanvasSessionHandler.getSession()).thenReturn(session);
verify(formsCanvasSessionHandler).setRenderer(formRendererArgumentCaptor.capture());
final FormsCanvasSessionHandler.FormRenderer formRenderer = formRendererArgumentCaptor.getValue();
formRenderer.render(GRAPH_UUID, domainObject, callback);
verify(formsContainer).render(eq(GRAPH_UUID), eq(DOMAIN_OBJECT_UUID), eq(domainObject), Mockito.<Path>any(), fieldChangeHandlerArgumentCaptor.capture(), eq(RenderMode.EDIT_MODE));
final FieldChangeHandler fieldChangeHandler = fieldChangeHandlerArgumentCaptor.getValue();
fieldChangeHandler.onFieldChange(fieldName, fieldValue);
verify(formsCanvasSessionHandler).executeUpdateDomainObjectProperty(eq(domainObject), eq(fieldName), eq(fieldValue));
verify(propertiesOpenedEvent).fire(formPropertiesOpenedArgumentCaptor.capture());
final FormPropertiesOpened formPropertiesOpened = formPropertiesOpenedArgumentCaptor.getValue();
assertThat(formPropertiesOpened.getUuid()).isEqualTo(DOMAIN_OBJECT_UUID);
assertThat(formPropertiesOpened.getName()).isEqualTo(DOMAIN_OBJECT_TRANSLATION_KEY);
assertThat(formPropertiesOpened.getSession()).isEqualTo(session);
verify(callback).execute();
}
use of org.kie.workbench.common.forms.processing.engine.handling.FieldChangeHandler in project kie-wb-common by kiegroup.
the class FormsContainerTest method testRender.
private FormDisplayer testRender(NodeImpl<Definition<?>> node, int expectedDisplayers, int currentDisplayerRender, RenderMode renderMode) {
// clear mocks
reset(renderer);
reset(formFieldChangedEvent);
formsContainer.render(GRAPH_UUID, node.getUUID(), node.getContent().getDefinition(), path, fieldChangeHandler, renderMode);
verify(displayersInstance, times(expectedDisplayers)).get();
assertThat(activeDisplayers).isNotEmpty().hasSize(expectedDisplayers);
FormDisplayer displayer = activeDisplayers.get(expectedDisplayers - 1);
verify(displayer, times(currentDisplayerRender)).render(node.getUUID(), node.getContent().getDefinition(), path, fieldChangeHandler, renderMode);
verify(displayer, times(currentDisplayerRender)).hide();
verify(view, times(currentDisplayerRender)).addDisplayer(displayer);
verify(displayer).show();
// test fire FormFieldChanged event
final ArgumentCaptor<FieldChangeHandler> fieldChangeHandlerArgumentCaptor = ArgumentCaptor.forClass(FieldChangeHandler.class);
verify(renderer).addFieldChangeHandler(fieldChangeHandlerArgumentCaptor.capture());
fieldChangeHandlerArgumentCaptor.getValue().onFieldChange("field", "value");
final ArgumentCaptor<FormFieldChanged> formFieldChangedArgumentCaptor = ArgumentCaptor.forClass(FormFieldChanged.class);
verify(formFieldChangedEvent).fire(formFieldChangedArgumentCaptor.capture());
final FormFieldChanged formFieldChanged = formFieldChangedArgumentCaptor.getValue();
assertThat(formFieldChanged.getName()).isEqualTo("field");
assertThat(formFieldChanged.getValue()).isEqualTo("value");
assertThat(formFieldChanged.getUuid()).isEqualTo(node.getUUID());
return displayer;
}
Aggregations