Search in sources :

Example 1 with ReassignmentEvent

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent in project kie-wb-common by kiegroup.

the class ReassignmentEditorWidgetTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    GwtMockito.initMocks(this);
    modal = mock(BaseModal.class);
    notStarted = mock(Option.class);
    notCompleted = mock(Option.class);
    customerBinder = mock(DataBinder.class);
    multipleLiveSearchSelectionHandlerUsers = mock(MultipleLiveSearchSelectionHandler.class);
    multipleLiveSearchSelectionHandlerGroups = mock(MultipleLiveSearchSelectionHandler.class);
    doNothing().when(modal).hide();
    doNothing().when(modal).show();
    doNothing().when(reassignmentEvent).fire(any(ReassignmentEvent.class));
    doCallRealMethod().when(reassignmentEditorWidget).setReadOnly(any(boolean.class));
    doCallRealMethod().when(reassignmentEditorWidget).getNameHeader();
    setFieldValue(reassignmentEditorWidget, "view", view);
    setFieldValue(reassignmentEditorWidget, "translationService", translationService);
    doCallRealMethod().when(typeSelect).setValue(any(String.class));
    doCallRealMethod().when(typeSelect).getValue();
    doCallRealMethod().when(view).setReadOnly(any(boolean.class));
    doCallRealMethod().when(view).initTypeSelector();
    doCallRealMethod().when(view).createOrEdit(any(ReassignmentWidgetView.class), any(ReassignmentRow.class));
    doCallRealMethod().when(view).ok();
    setFieldValue(view, "modal", modal);
    setFieldValue(view, "customerBinder", customerBinder);
    setFieldValue(view, "multipleLiveSearchSelectionHandlerUsers", multipleLiveSearchSelectionHandlerUsers);
    setFieldValue(view, "multipleLiveSearchSelectionHandlerGroups", multipleLiveSearchSelectionHandlerGroups);
    setFieldValue(view, "reassignmentEvent", reassignmentEvent);
    setFieldValue(view, "validator", validator);
    setFieldValue(view, "closeButton", new HTMLButtonElement());
    setFieldValue(view, "okButton", new HTMLButtonElement());
    setFieldValue(view, "customerBinder", customerBinder);
    setFieldValue(view, "typeSelect", typeSelect);
    setFieldValue(view, "notStarted", notStarted);
    setFieldValue(view, "notCompleted", notCompleted);
    doCallRealMethod().when(typeSelect).setValue(any(String.class));
    doCallRealMethod().when(typeSelect).getValue();
    when(validator.validate(any(ReassignmentRow.class))).thenReturn(Collections.EMPTY_SET);
    doCallRealMethod().when(view).init(any(ReassignmentEditorWidgetView.Presenter.class));
    when(translationService.getValue(any(String.class))).thenReturn("Reassignment");
    view.initTypeSelector();
}
Also used : BaseModal(org.uberfire.ext.widgets.common.client.common.popups.BaseModal) MultipleLiveSearchSelectionHandler(org.uberfire.ext.widgets.common.client.dropdown.MultipleLiveSearchSelectionHandler) ReassignmentEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent) Option(org.gwtbootstrap3.extras.select.client.ui.Option) DataBinder(org.jboss.errai.databinding.client.api.DataBinder) HTMLButtonElement(elemental2.dom.HTMLButtonElement) ReassignmentRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow) Before(org.junit.Before)

Example 2 with ReassignmentEvent

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent in project kie-wb-common by kiegroup.

the class ReassignmentWidgetViewImplTest method testOnAddNewValueAndSave.

@Test
public void testOnAddNewValueAndSave() {
    dataProvider.setList(new ArrayList<>());
    final ReassignmentTypeListValue[] value = new ReassignmentTypeListValue[1];
    ReassignmentsEditorWidget.GetReassignmentsCallback callback = v -> value[0] = v;
    setFieldValue(presenter, "view", view);
    reassignmentWidgetViewImpl.init(presenter, generateRows());
    presenter.setCallback(callback);
    setFieldValue(reassignmentWidgetViewImpl, "editor", reassignmentEditorWidget);
    setFieldValue(reassignmentEditorWidget, "view", reassignmentEditorWidgetImpl);
    ReassignmentRow newRow = new ReassignmentRow();
    newRow.setId(111);
    reassignmentWidgetViewImpl.addOrEdit(newRow);
    reassignmentWidgetViewImpl.onSubscription(new ReassignmentEvent(newRow));
    reassignmentWidgetViewImpl.ok();
    reassignmentWidgetViewImpl.hide();
    Assert.assertEquals(0, presenter.getValue().size());
    Assert.assertEquals(5, value[0].getValues().size());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mockito.doCallRealMethod(org.mockito.Mockito.doCallRealMethod) RunWith(org.junit.runner.RunWith) Mockito.spy(org.mockito.Mockito.spy) ArrayList(java.util.ArrayList) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) ReassignmentTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) ReassignmentEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent) SimpleTable(org.uberfire.ext.widgets.common.client.tables.SimpleTable) Before(org.junit.Before) HasData(com.google.gwt.view.client.HasData) ReassignmentsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.ReassignmentsEditorWidget) Test(org.junit.Test) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) BaseModal(org.uberfire.ext.widgets.common.client.common.popups.BaseModal) GwtMock(com.google.gwtmockito.GwtMock) List(java.util.List) ReassignmentRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow) ListDataProvider(com.google.gwt.view.client.ListDataProvider) GwtMockito(com.google.gwtmockito.GwtMockito) Assert(org.junit.Assert) Collections(java.util.Collections) ReassignmentEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent) ReassignmentTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue) ReassignmentsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.ReassignmentsEditorWidget) ReassignmentRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) Test(org.junit.Test)

Example 3 with ReassignmentEvent

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent in project kie-wb-common by kiegroup.

the class ReassignmentWidgetViewImplTest method testOnEditValueAndSave.

@Test
public void testOnEditValueAndSave() {
    dataProvider.setList(new ArrayList<>());
    final ReassignmentTypeListValue[] value = new ReassignmentTypeListValue[1];
    ReassignmentsEditorWidget.GetReassignmentsCallback callback = v -> value[0] = v;
    setFieldValue(presenter, "view", view);
    reassignmentWidgetViewImpl.init(presenter, generateRows());
    presenter.setCallback(callback);
    setFieldValue(reassignmentWidgetViewImpl, "editor", reassignmentEditorWidget);
    setFieldValue(reassignmentEditorWidget, "view", reassignmentEditorWidgetImpl);
    ReassignmentRow newRow = new ReassignmentRow();
    newRow.setId(1);
    reassignmentWidgetViewImpl.addOrEdit(newRow);
    reassignmentWidgetViewImpl.onSubscription(new ReassignmentEvent(newRow));
    reassignmentWidgetViewImpl.ok();
    reassignmentWidgetViewImpl.hide();
    Assert.assertEquals(0, presenter.getValue().size());
    Assert.assertEquals(4, value[0].getValues().size());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mockito.doCallRealMethod(org.mockito.Mockito.doCallRealMethod) RunWith(org.junit.runner.RunWith) Mockito.spy(org.mockito.Mockito.spy) ArrayList(java.util.ArrayList) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) ReassignmentTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) ReassignmentEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent) SimpleTable(org.uberfire.ext.widgets.common.client.tables.SimpleTable) Before(org.junit.Before) HasData(com.google.gwt.view.client.HasData) ReassignmentsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.ReassignmentsEditorWidget) Test(org.junit.Test) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) BaseModal(org.uberfire.ext.widgets.common.client.common.popups.BaseModal) GwtMock(com.google.gwtmockito.GwtMock) List(java.util.List) ReassignmentRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow) ListDataProvider(com.google.gwt.view.client.ListDataProvider) GwtMockito(com.google.gwtmockito.GwtMockito) Assert(org.junit.Assert) Collections(java.util.Collections) ReassignmentEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent) ReassignmentTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue) ReassignmentsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.ReassignmentsEditorWidget) ReassignmentRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) Test(org.junit.Test)

Example 4 with ReassignmentEvent

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent in project kie-wb-common by kiegroup.

the class ReassignmentWidgetViewImplTest method testOnAddNewValueAndClose.

@Test
public void testOnAddNewValueAndClose() {
    dataProvider.setList(new ArrayList<>());
    final ReassignmentTypeListValue[] value = new ReassignmentTypeListValue[1];
    ReassignmentsEditorWidget.GetReassignmentsCallback callback = v -> value[0] = v;
    setFieldValue(presenter, "view", view);
    reassignmentWidgetViewImpl.init(presenter, generateRows());
    presenter.setCallback(callback);
    setFieldValue(reassignmentWidgetViewImpl, "editor", reassignmentEditorWidget);
    setFieldValue(reassignmentEditorWidget, "view", reassignmentEditorWidgetImpl);
    ReassignmentRow newRow = new ReassignmentRow();
    newRow.setId(111);
    reassignmentWidgetViewImpl.addOrEdit(newRow);
    reassignmentWidgetViewImpl.onSubscription(new ReassignmentEvent(null));
    reassignmentWidgetViewImpl.ok();
    reassignmentWidgetViewImpl.hide();
    Assert.assertEquals(0, presenter.getValue().size());
    Assert.assertEquals(4, value[0].getValues().size());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mockito.doCallRealMethod(org.mockito.Mockito.doCallRealMethod) RunWith(org.junit.runner.RunWith) Mockito.spy(org.mockito.Mockito.spy) ArrayList(java.util.ArrayList) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) ReassignmentTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) ReassignmentEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent) SimpleTable(org.uberfire.ext.widgets.common.client.tables.SimpleTable) Before(org.junit.Before) HasData(com.google.gwt.view.client.HasData) ReassignmentsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.ReassignmentsEditorWidget) Test(org.junit.Test) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) BaseModal(org.uberfire.ext.widgets.common.client.common.popups.BaseModal) GwtMock(com.google.gwtmockito.GwtMock) List(java.util.List) ReassignmentRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow) ListDataProvider(com.google.gwt.view.client.ListDataProvider) GwtMockito(com.google.gwtmockito.GwtMockito) Assert(org.junit.Assert) Collections(java.util.Collections) ReassignmentEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent) ReassignmentTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue) ReassignmentsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.ReassignmentsEditorWidget) ReassignmentRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) Test(org.junit.Test)

Example 5 with ReassignmentEvent

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent in project kie-wb-common by kiegroup.

the class ReassignmentEditorWidgetViewImpl method ok.

protected void ok() {
    // TODO looks like errai data binder doenst support liststore widgets.
    current.setUsers(multipleLiveSearchSelectionHandlerUsers.getSelectedValues());
    current.setGroups(multipleLiveSearchSelectionHandlerGroups.getSelectedValues());
    current.setType(customerBinder.getModel().getType());
    current.setDuration(customerBinder.getModel().getDuration());
    Set<ConstraintViolation<ReassignmentValue>> violations = validator.validate(current.toReassignmentValue());
    if (violations.isEmpty()) {
        reassignmentEvent.fire(new ReassignmentEvent(current));
        hide();
    } else {
        onViolationError(violations);
    }
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) ReassignmentEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent)

Aggregations

ReassignmentEvent (org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent)6 Before (org.junit.Before)4 ReassignmentRow (org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow)4 BaseModal (org.uberfire.ext.widgets.common.client.common.popups.BaseModal)4 LienzoMockitoTestRunner (com.ait.lienzo.test.LienzoMockitoTestRunner)3 HasData (com.google.gwt.view.client.HasData)3 ListDataProvider (com.google.gwt.view.client.ListDataProvider)3 GwtMock (com.google.gwtmockito.GwtMock)3 GwtMockito (com.google.gwtmockito.GwtMockito)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 List (java.util.List)3 Assert (org.junit.Assert)3 Test (org.junit.Test)3 RunWith (org.junit.runner.RunWith)3 ReassignmentsEditorWidget (org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.ReassignmentsEditorWidget)3 ReflectionUtilsTest (org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest)3 ReassignmentTypeListValue (org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue)3 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)3 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)3