Search in sources :

Example 1 with ComponentRemovedEvent

use of org.uberfire.ext.layout.editor.client.api.ComponentRemovedEvent in project kie-wb-common by kiegroup.

the class FormEditorPresenterTest method testRemoveEventWhenMovingFieldOnLayout.

@Test
public void testRemoveEventWhenMovingFieldOnLayout() {
    loadContent();
    loadAvailableFields();
    addAllFields();
    FormEditorPresenter presenterSpy = spy(presenter);
    FieldDefinition field = editorHelper.getFormDefinition().getFields().get(0);
    ComponentRemovedEvent event = new ComponentRemovedEvent(createLayoutComponent(presenter.getFormDefinition(), field), true);
    presenterSpy.onRemoveComponent(event);
    assertNotNull(editorHelper.getFormDefinition().getFieldById(field.getId()));
    verify(presenterSpy, never()).onSyncPalette(anyString());
    verify(editorHelper, never()).removeField(anyString(), anyBoolean());
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) ComponentRemovedEvent(org.uberfire.ext.layout.editor.client.api.ComponentRemovedEvent) Test(org.junit.Test)

Example 2 with ComponentRemovedEvent

use of org.uberfire.ext.layout.editor.client.api.ComponentRemovedEvent in project kie-wb-common by kiegroup.

the class FormEditorPresenterTest method testOnRemoveComponent.

public void testOnRemoveComponent(boolean noContext) {
    loadContent();
    loadAvailableFields();
    addAllFields();
    VerificationMode count = times(1);
    if (noContext) {
        when(editorHelper.getContent()).thenReturn(null);
        count = never();
    }
    FormEditorPresenter presenterSpy = spy(presenter);
    String formId = presenterSpy.getFormDefinition().getId();
    FieldDefinition field = editorHelper.getFormDefinition().getFields().get(0);
    ComponentRemovedEvent event = new ComponentRemovedEvent(createLayoutComponent(presenter.getFormDefinition(), field), false);
    presenterSpy.onRemoveComponent(event);
    verify(presenterSpy, count).onSyncPalette(formId);
    verify(editorHelper, count).removeField(anyString(), anyBoolean());
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) TextAreaFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition) ComponentRemovedEvent(org.uberfire.ext.layout.editor.client.api.ComponentRemovedEvent) Mockito.anyString(org.mockito.Mockito.anyString) VerificationMode(org.mockito.verification.VerificationMode)

Example 3 with ComponentRemovedEvent

use of org.uberfire.ext.layout.editor.client.api.ComponentRemovedEvent in project kie-wb-common by kiegroup.

the class FormEditorPresenterTest method testOnRemoveComponentWithoutLayoutComponent.

@Test
public void testOnRemoveComponentWithoutLayoutComponent() {
    loadContent();
    loadAvailableFields();
    addAllFields();
    FormEditorPresenter presenterSpy = spy(presenter);
    ComponentRemovedEvent event = new ComponentRemovedEvent(null);
    presenterSpy.onRemoveComponent(event);
    verify(presenterSpy, never()).onSyncPalette(anyString());
    verify(editorHelper, never()).removeField(anyString(), anyBoolean());
}
Also used : ComponentRemovedEvent(org.uberfire.ext.layout.editor.client.api.ComponentRemovedEvent) Test(org.junit.Test)

Aggregations

ComponentRemovedEvent (org.uberfire.ext.layout.editor.client.api.ComponentRemovedEvent)3 Test (org.junit.Test)2 TextAreaFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition)2 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)2 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)2 Mockito.anyString (org.mockito.Mockito.anyString)1 VerificationMode (org.mockito.verification.VerificationMode)1