Search in sources :

Example 1 with ReassignmentTypeListValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue 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 2 with ReassignmentTypeListValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue 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 3 with ReassignmentTypeListValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue in project kie-wb-common by kiegroup.

the class ReassignmentsInfos method of.

public static ReassignmentsInfo of(List<DataInputAssociation> dataInputAssociations) {
    ReassignmentTypeListValue reassignments = new ReassignmentTypeListValue();
    dataInputAssociations.forEach(din -> {
        DataInput targetRef = (DataInput) (din.getTargetRef());
        if (isReservedIdentifier(targetRef.getName())) {
            if (!din.getAssignment().isEmpty()) {
                Assignment assignment = din.getAssignment().get(0);
                if (assignment != null) {
                    String body = ((FormalExpression) assignment.getFrom()).getBody();
                    if (body != null) {
                        Arrays.stream(replaceBracket(body).split("\\^")).forEach(b -> {
                            reassignments.addValue(ParsedReassignmentsInfos.of(targetRef.getName(), b));
                        });
                    }
                }
            }
        }
    });
    return new ReassignmentsInfo(reassignments);
}
Also used : DataInput(org.eclipse.bpmn2.DataInput) Assignment(org.eclipse.bpmn2.Assignment) ReassignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentsInfo) ReassignmentTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue) FormalExpression(org.eclipse.bpmn2.FormalExpression)

Example 4 with ReassignmentTypeListValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue 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 ReassignmentTypeListValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue in project kie-wb-common by kiegroup.

the class ReassignmentsEditorWidget method setValue.

@Override
public void setValue(ReassignmentTypeListValue value, boolean fireEvents) {
    if (value != null) {
        ReassignmentTypeListValue oldValue = reassignmentTypeListValue;
        reassignmentTypeListValue = value;
        initTextBox();
        if (fireEvents) {
            ValueChangeEvent.fireIfNotEqual(this, oldValue, reassignmentTypeListValue);
        }
    }
}
Also used : ReassignmentTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue)

Aggregations

ReassignmentTypeListValue (org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentTypeListValue)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ReassignmentRow (org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.ReassignmentRow)4 ReassignmentsEditorWidget (org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.ReassignmentsEditorWidget)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 Assert (org.junit.Assert)3 Before (org.junit.Before)3 Test (org.junit.Test)3 RunWith (org.junit.runner.RunWith)3 ReassignmentEvent (org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent)3 ReflectionUtilsTest (org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest)3 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)3 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)3 Mockito.doCallRealMethod (org.mockito.Mockito.doCallRealMethod)3