Search in sources :

Example 1 with FormPropertiesOpened

use of org.kie.workbench.common.stunner.forms.client.event.FormPropertiesOpened 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();
}
Also used : Command(org.uberfire.mvp.Command) FormPropertiesOpened(org.kie.workbench.common.stunner.forms.client.event.FormPropertiesOpened) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) FieldChangeHandler(org.kie.workbench.common.forms.processing.engine.handling.FieldChangeHandler) Test(org.junit.Test)

Example 2 with FormPropertiesOpened

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

the class FormsFlushManagerTest method testOnFormsOpenedEvent.

@Test
public void testOnFormsOpenedEvent() {
    tested.onFormsOpenedEvent(new FormPropertiesOpened(clientSession, ELEMENT_UUID, ""));
    assertEquals(ELEMENT_UUID, tested.formElementUUID);
}
Also used : FormPropertiesOpened(org.kie.workbench.common.stunner.forms.client.event.FormPropertiesOpened) Test(org.junit.Test)

Example 3 with FormPropertiesOpened

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

the class FormsFlushManagerTest method flush.

@Test
public void flush() {
    tested.onFormsOpenedEvent(new FormPropertiesOpened(clientSession, ELEMENT_UUID, ""));
    tested.container = null;
    tested.flush(clientSession);
    tested.container = formsContainer;
    tested.flush(clientSession);
    verify(formsContainer, times(1)).flush(GRAPH_UUID, ELEMENT_UUID);
}
Also used : FormPropertiesOpened(org.kie.workbench.common.stunner.forms.client.event.FormPropertiesOpened) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 FormPropertiesOpened (org.kie.workbench.common.stunner.forms.client.event.FormPropertiesOpened)3 FieldChangeHandler (org.kie.workbench.common.forms.processing.engine.handling.FieldChangeHandler)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Command (org.uberfire.mvp.Command)1