Search in sources :

Example 11 with ReassignmentRow

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow 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 12 with ReassignmentRow

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow in project kie-wb-common by kiegroup.

the class ReassignmentWidgetViewImplTest method testRowCountOneAndTwo.

@Test
public void testRowCountOneAndTwo() {
    List<ReassignmentRow> rows = new ArrayList<>();
    rows.add(new ReassignmentRow());
    reassignmentWidgetViewImpl.init(presenter, rows);
    ListDataProvider<ReassignmentRow> dataProvider = getFieldValue(ReassignmentWidgetViewImpl.class, reassignmentWidgetViewImpl, "dataProvider");
    Assert.assertEquals(1, dataProvider.getList().size());
    rows = new ArrayList<>();
    rows.add(new ReassignmentRow());
    reassignmentWidgetViewImpl.init(presenter, rows);
    Assert.assertEquals(1, dataProvider.getList().size());
    rows.add(new ReassignmentRow());
    reassignmentWidgetViewImpl.init(presenter, rows);
    Assert.assertEquals(2, dataProvider.getList().size());
    reassignmentWidgetViewImpl.init(presenter, Collections.EMPTY_LIST);
    Assert.assertEquals(0, dataProvider.getList().size());
}
Also used : ArrayList(java.util.ArrayList) 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 13 with ReassignmentRow

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow in project kie-wb-common by kiegroup.

the class ReassignmentsEditorWidget method showReassignmentsDialog.

void showReassignmentsDialog() {
    reassignmentWidget.setValue(reassignmentTypeListValue.getValues().stream().map(r -> new ReassignmentRow(r)).collect(Collectors.toList()), true);
    reassignmentWidget.setCallback(data -> setValue(data, true));
    reassignmentWidget.show();
}
Also used : ReassignmentRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow)

Example 14 with ReassignmentRow

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow in project kie-wb-common by kiegroup.

the class ReassignmentWidgetViewImpl method initEdit.

private void initEdit() {
    AbstractCell<ReassignmentRow> buttonCell = new AbstractCell<ReassignmentRow>(ClickEvent.getType().getName()) {

        @Override
        public void render(Context context, ReassignmentRow value, SafeHtmlBuilder sb) {
            Button button = new Button();
            button.setSize(ButtonSize.SMALL);
            button.add(new Icon(IconType.EDIT));
            sb.append(SafeHtmlUtils.fromTrustedString(button.toString()));
        }

        @Override
        public void onBrowserEvent(Context context, Element parent, ReassignmentRow value, NativeEvent event, ValueUpdater<ReassignmentRow> valueUpdater) {
            if (!readOnly) {
                addOrEdit(value);
            }
        }
    };
    Column<ReassignmentRow, ReassignmentRow> editColumn = new Column<ReassignmentRow, ReassignmentRow>(buttonCell) {

        @Override
        public ReassignmentRow getValue(ReassignmentRow object) {
            return object;
        }
    };
    editColumn.setSortable(false);
    table.addColumn(editColumn, StunnerFormsClientFieldsConstants.CONSTANTS.Edit());
    table.setColumnWidth(editColumn, 50, Style.Unit.PX);
}
Also used : Button(org.gwtbootstrap3.client.ui.Button) ValueUpdater(com.google.gwt.cell.client.ValueUpdater) Column(com.google.gwt.user.cellview.client.Column) HTMLButtonElement(elemental2.dom.HTMLButtonElement) Element(com.google.gwt.dom.client.Element) AbstractCell(com.google.gwt.cell.client.AbstractCell) Icon(org.gwtbootstrap3.client.ui.Icon) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ReassignmentRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 15 with ReassignmentRow

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow in project kie-wb-common by kiegroup.

the class ReassignmentWidgetViewImpl method initUsers.

private void initUsers() {
    PopoverTextCell toUsers = new PopoverTextCell();
    Column<ReassignmentRow, String> toUsersColumn = new Column<ReassignmentRow, String>(toUsers) {

        @Override
        public String getValue(ReassignmentRow object) {
            if (object.getUsers() != null) {
                return object.getUsers().stream().collect(Collectors.joining(","));
            } else {
                return "";
            }
        }
    };
    toUsersColumn.setSortable(false);
    table.addColumn(toUsersColumn, presenter.getToUsersLabel());
    table.setColumnWidth(toUsersColumn, 250, Style.Unit.PX);
}
Also used : Column(com.google.gwt.user.cellview.client.Column) PopoverTextCell(org.uberfire.ext.widgets.common.client.tables.PopoverTextCell) ReassignmentRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow)

Aggregations

ReassignmentRow (org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow)17 Test (org.junit.Test)8 ReflectionUtilsTest (org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest)8 Column (com.google.gwt.user.cellview.client.Column)6 ArrayList (java.util.ArrayList)5 PopoverTextCell (org.uberfire.ext.widgets.common.client.tables.PopoverTextCell)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 Collections (java.util.Collections)3 List (java.util.List)3 Assert (org.junit.Assert)3 Before (org.junit.Before)3 RunWith (org.junit.runner.RunWith)3 ReassignmentsEditorWidget (org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.ReassignmentsEditorWidget)3 ReassignmentEvent (org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent)3 ReassignmentTypeListValue (org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue)3 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)3