Search in sources :

Example 6 with FormFieldChanged

use of org.kie.workbench.common.stunner.forms.client.event.FormFieldChanged 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;
}
Also used : FormDisplayer(org.kie.workbench.common.stunner.forms.client.widgets.container.displayer.FormDisplayer) FormFieldChanged(org.kie.workbench.common.stunner.forms.client.event.FormFieldChanged) FieldChangeHandler(org.kie.workbench.common.forms.processing.engine.handling.FieldChangeHandler)

Example 7 with FormFieldChanged

use of org.kie.workbench.common.stunner.forms.client.event.FormFieldChanged in project kie-wb-common by kiegroup.

the class FormsContainer method render.

public void render(final String graphUuid, final String domainObjectUUID, final Object domainObject, final Path diagramPath, final FieldChangeHandler changeHandler, final RenderMode renderMode) {
    FormDisplayer displayer = getDisplayer(graphUuid, domainObjectUUID);
    displayer.render(domainObjectUUID, domainObject, diagramPath, changeHandler, renderMode);
    if (null != currentDisplayer && !displayer.equals(currentDisplayer)) {
        currentDisplayer.hide();
    }
    displayer.show();
    currentDisplayer = displayer;
    currentDisplayer.getRenderer().addFieldChangeHandler((name, value) -> {
        formFieldChangedEvent.fire(new FormFieldChanged(name, value, domainObjectUUID));
    });
}
Also used : FormDisplayer(org.kie.workbench.common.stunner.forms.client.widgets.container.displayer.FormDisplayer) FormFieldChanged(org.kie.workbench.common.stunner.forms.client.event.FormFieldChanged)

Example 8 with FormFieldChanged

use of org.kie.workbench.common.stunner.forms.client.event.FormFieldChanged in project kie-wb-common by kiegroup.

the class MultipleInstanceNodeFilterProviderTest method testOnFormFieldChangedForOtherThanMultipleInstance.

@Test
public void testOnFormFieldChangedForOtherThanMultipleInstance() {
    FormFieldChanged formFieldChanged = mockFormFieldChanged("anyOtherField", "anyOtherUUID");
    filterProvider.onFormFieldChanged(formFieldChanged);
    verify(refreshFormPropertiesEvent, never()).fire(any());
}
Also used : FormFieldChanged(org.kie.workbench.common.stunner.forms.client.event.FormFieldChanged) Test(org.junit.Test)

Example 9 with FormFieldChanged

use of org.kie.workbench.common.stunner.forms.client.event.FormFieldChanged in project kie-wb-common by kiegroup.

the class MultipleInstanceNodeFilterProviderTest method testOnFormFieldChangedForMultipleInstance.

@Test
public void testOnFormFieldChangedForMultipleInstance() {
    FormFieldChanged formFieldChanged = mockFormFieldChanged(IS_MULTIPLE_INSTANCE, UUID);
    filterProvider.onFormFieldChanged(formFieldChanged);
    verifyFieldChangeFired();
}
Also used : FormFieldChanged(org.kie.workbench.common.stunner.forms.client.event.FormFieldChanged) Test(org.junit.Test)

Example 10 with FormFieldChanged

use of org.kie.workbench.common.stunner.forms.client.event.FormFieldChanged in project kie-wb-common by kiegroup.

the class BaseReusableSubProcessFilterProviderTest method testOnFormFieldChangedForIndependentField.

@Test
public void testOnFormFieldChangedForIndependentField() {
    FormFieldChanged formFieldChanged = mockFormFieldChanged(INDEPENDENT, UUID);
    filterProvider.onFormFieldChanged(formFieldChanged);
    verifyFieldChangeFired();
}
Also used : FormFieldChanged(org.kie.workbench.common.stunner.forms.client.event.FormFieldChanged) Test(org.junit.Test)

Aggregations

FormFieldChanged (org.kie.workbench.common.stunner.forms.client.event.FormFieldChanged)10 Test (org.junit.Test)7 FormDisplayer (org.kie.workbench.common.stunner.forms.client.widgets.container.displayer.FormDisplayer)2 FieldChangeHandler (org.kie.workbench.common.forms.processing.engine.handling.FieldChangeHandler)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1