Search in sources :

Example 1 with NotificationTypeListValue

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

the class NotificationWidget method ok.

@Override
public void ok() {
    if (callback != null) {
        List<NotificationValue> notifications = getValue().stream().map(NotificationRow::toNotificationValue).collect(Collectors.toList());
        callback.getData(new NotificationTypeListValue(notifications));
    }
    view.hide();
}
Also used : NotificationTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationTypeListValue) NotificationValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue)

Example 2 with NotificationTypeListValue

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

the class NotificationWidgetViewImplTest method testOnAddNewValueAndSave.

@Test
public void testOnAddNewValueAndSave() {
    dataProvider.setList(new ArrayList<>());
    final NotificationTypeListValue[] value = new NotificationTypeListValue[1];
    NotificationsEditorWidget.GetNotificationsCallback callback = v -> value[0] = v;
    setFieldValue(presenter, "view", view);
    notificationWidgetViewImpl.init(presenter, generateRows());
    presenter.setCallback(callback);
    setFieldValue(notificationWidgetViewImpl, "editor", notificationEditorWidget);
    setFieldValue(notificationEditorWidget, "view", notificationEditorWidgetImpl);
    NotificationRow newRow = new NotificationRow();
    newRow.setId(111);
    notificationWidgetViewImpl.addOrEdit(newRow);
    notificationWidgetViewImpl.onSubscription(new NotificationEvent(newRow));
    notificationWidgetViewImpl.ok();
    notificationWidgetViewImpl.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) NotificationsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.NotificationsEditorWidget) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) SimpleTable(org.uberfire.ext.widgets.common.client.tables.SimpleTable) Before(org.junit.Before) HasData(com.google.gwt.view.client.HasData) 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) NotificationEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent) ListDataProvider(com.google.gwt.view.client.ListDataProvider) NotificationTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationTypeListValue) GwtMockito(com.google.gwtmockito.GwtMockito) Assert(org.junit.Assert) Collections(java.util.Collections) NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) NotificationsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.NotificationsEditorWidget) NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) NotificationEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent) NotificationTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationTypeListValue) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) Test(org.junit.Test)

Example 3 with NotificationTypeListValue

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

the class NotificationWidgetViewImplTest method testOnAddNewValueAndClose.

@Test
public void testOnAddNewValueAndClose() {
    dataProvider.setList(new ArrayList<>());
    final NotificationTypeListValue[] value = new NotificationTypeListValue[1];
    NotificationsEditorWidget.GetNotificationsCallback callback = v -> value[0] = v;
    setFieldValue(presenter, "view", view);
    notificationWidgetViewImpl.init(presenter, generateRows());
    presenter.setCallback(callback);
    setFieldValue(notificationWidgetViewImpl, "editor", notificationEditorWidget);
    setFieldValue(notificationEditorWidget, "view", notificationEditorWidgetImpl);
    NotificationRow newRow = new NotificationRow();
    newRow.setId(111);
    notificationWidgetViewImpl.addOrEdit(newRow);
    notificationWidgetViewImpl.onSubscription(new NotificationEvent(null));
    notificationWidgetViewImpl.ok();
    notificationWidgetViewImpl.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) NotificationsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.NotificationsEditorWidget) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) SimpleTable(org.uberfire.ext.widgets.common.client.tables.SimpleTable) Before(org.junit.Before) HasData(com.google.gwt.view.client.HasData) 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) NotificationEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent) ListDataProvider(com.google.gwt.view.client.ListDataProvider) NotificationTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationTypeListValue) GwtMockito(com.google.gwtmockito.GwtMockito) Assert(org.junit.Assert) Collections(java.util.Collections) NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) NotificationsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.NotificationsEditorWidget) NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) NotificationEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent) NotificationTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationTypeListValue) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) Test(org.junit.Test)

Example 4 with NotificationTypeListValue

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

the class NotificationWidgetViewImplTest method testOnEditValueAndSave.

@Test
public void testOnEditValueAndSave() {
    dataProvider.setList(new ArrayList<>());
    final NotificationTypeListValue[] value = new NotificationTypeListValue[1];
    NotificationsEditorWidget.GetNotificationsCallback callback = v -> value[0] = v;
    setFieldValue(presenter, "view", view);
    notificationWidgetViewImpl.init(presenter, generateRows());
    presenter.setCallback(callback);
    setFieldValue(notificationWidgetViewImpl, "editor", notificationEditorWidget);
    setFieldValue(notificationEditorWidget, "view", notificationEditorWidgetImpl);
    NotificationRow newRow = new NotificationRow();
    newRow.setId(1);
    notificationWidgetViewImpl.addOrEdit(newRow);
    notificationWidgetViewImpl.onSubscription(new NotificationEvent(newRow));
    notificationWidgetViewImpl.ok();
    notificationWidgetViewImpl.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) NotificationsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.NotificationsEditorWidget) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) SimpleTable(org.uberfire.ext.widgets.common.client.tables.SimpleTable) Before(org.junit.Before) HasData(com.google.gwt.view.client.HasData) 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) NotificationEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent) ListDataProvider(com.google.gwt.view.client.ListDataProvider) NotificationTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationTypeListValue) GwtMockito(com.google.gwtmockito.GwtMockito) Assert(org.junit.Assert) Collections(java.util.Collections) NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) NotificationsEditorWidget(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.NotificationsEditorWidget) NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) NotificationEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent) NotificationTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationTypeListValue) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) Test(org.junit.Test)

Example 5 with NotificationTypeListValue

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

the class NotificationsEditorWidget method setValue.

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

Aggregations

NotificationTypeListValue (org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationTypeListValue)6 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 Before (org.junit.Before)3 Test (org.junit.Test)3 RunWith (org.junit.runner.RunWith)3 NotificationRow (org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow)3 NotificationsEditorWidget (org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.NotificationsEditorWidget)3 NotificationEvent (org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent)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