Search in sources :

Example 1 with ReassignmentRow

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

the class ReassignmentEditorWidgetTest method testCreateAndSave.

@Test
public void testCreateAndSave() {
    List<String> groups = Arrays.asList("AAA", "BBB", "CCC", "DDD");
    List<String> users = Arrays.asList("aaa", "bbb", "ccc");
    doNothing().when(view).hide();
    ReassignmentRow test = new ReassignmentRow();
    doNothing().when(view).hide();
    when(customerBinder.getModel()).thenReturn(test);
    when(notCompleted.getValue()).thenReturn(ReassignmentType.NotCompletedReassign.getAlias());
    when(typeSelect.getSelectedItem()).thenReturn(notCompleted);
    when(multipleLiveSearchSelectionHandlerGroups.getSelectedValues()).thenReturn(groups);
    when(multipleLiveSearchSelectionHandlerUsers.getSelectedValues()).thenReturn(users);
    view.createOrEdit(reassignmentWidgetViewImpl, test);
    view.ok();
    Assert.assertEquals(ReassignmentType.NotCompletedReassign, test.getType());
    Assert.assertEquals(groups, test.getGroups());
    Assert.assertEquals(users, test.getUsers());
}
Also used : 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 2 with ReassignmentRow

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

the class ReassignmentEditorWidgetTest method testCreateAndClose.

@Test
public void testCreateAndClose() {
    List<String> groups = Arrays.asList("AAA", "BBB", "CCC", "DDD");
    List<String> users = Arrays.asList("aaa", "bbb", "ccc");
    doNothing().when(view).hide();
    ReassignmentRow test = new ReassignmentRow();
    doNothing().when(view).hide();
    when(customerBinder.getModel()).thenReturn(test);
    when(notCompleted.getValue()).thenReturn(ReassignmentType.NotStartedReassign.getAlias());
    when(typeSelect.getSelectedItem()).thenReturn(notCompleted);
    when(multipleLiveSearchSelectionHandlerGroups.getSelectedValues()).thenReturn(groups);
    when(multipleLiveSearchSelectionHandlerUsers.getSelectedValues()).thenReturn(users);
    view.createOrEdit(reassignmentWidgetViewImpl, test);
    view.close();
    Assert.assertNotEquals(ReassignmentType.NotStartedReassign, test.getType());
    Assert.assertNotEquals(groups, test.getGroups());
    Assert.assertNotEquals(users, test.getUsers());
}
Also used : 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 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 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 4 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 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 5 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 initExpiresAt.

private void initExpiresAt() {
    TextCell expiresAt = new TextCell();
    Column<ReassignmentRow, String> expiresAtColumn = new Column<ReassignmentRow, String>(expiresAt) {

        @Override
        public String getValue(ReassignmentRow object) {
            if (object.getDuration() != null) {
                return object.getDuration();
            }
            return "";
        }
    };
    expiresAtColumn.setSortable(false);
    table.addColumn(expiresAtColumn, presenter.getExpiresAtLabel());
    table.setColumnWidth(expiresAtColumn, 80, Style.Unit.PX);
}
Also used : Column(com.google.gwt.user.cellview.client.Column) TextCell(com.google.gwt.cell.client.TextCell) 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