Search in sources :

Example 1 with NotificationEvent

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

the class NotificationEditorWidgetViewImpl method ok.

@Override
public void ok() {
    // TODO looks like errai data binder doesn't support liststore widgets.
    current.setUsers(multipleLiveSearchSelectionHandlerUsers.getSelectedValues());
    current.setGroups(multipleLiveSearchSelectionHandlerGroups.getSelectedValues());
    current.setEmails(presenter.clearEmails(emails.getValue()));
    current.setBody(body.getValue());
    current.setSubject(subject.getValue());
    current.setFrom(searchSelectionFromHandler.getSelectedValue() != null ? searchSelectionFromHandler.getSelectedValue() : "");
    current.setReplyTo(searchSelectionReplyToHandler.getSelectedValue() != null ? searchSelectionReplyToHandler.getSelectedValue() : "");
    current.setExpiresAt(combineISO8601String());
    current.setExpiration(Expiration.get(taskExpiration.getValue()));
    current.setType(presenter.getNotificationType(notStartedInput.checked));
    notificationEvent.fire(new NotificationEvent(current));
    markEmailsAsCorrect();
    hide();
}
Also used : NotificationEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent)

Example 2 with NotificationEvent

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent 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 NotificationEvent

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent 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 NotificationEvent

use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent 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 NotificationEvent

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

the class NotificationEditorWidgetTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    GwtMockito.initMocks(this);
    BaseModal modal = mock(BaseModal.class);
    taskExpiration = mock(Select.class);
    setFieldValue(view, "taskExpiration", taskExpiration);
    Option notStarted = mock(Option.class);
    notCompleted = mock(Option.class);
    customerBinder = mock(DataBinder.class);
    searchSelectionReplyToHandler = mock(SingleLiveSearchSelectionHandler.class);
    searchSelectionFromHandler = mock(SingleLiveSearchSelectionHandler.class);
    multipleLiveSearchSelectionHandlerUsers = mock(MultipleLiveSearchSelectionHandler.class);
    multipleLiveSearchSelectionHandlerGroups = mock(MultipleLiveSearchSelectionHandler.class);
    notCompletedInput = mock(HTMLInputElement.class);
    notStartedInput = mock(HTMLInputElement.class);
    incorrectEmail = mock(ParagraphElement.class);
    doNothing().when(view).markEmailsAsCorrect();
    doNothing().when(modal).hide();
    doNothing().when(modal).show();
    doNothing().when(notificationEvent).fire(any(NotificationEvent.class));
    presenter = new NotificationEditorWidget(view, translationService);
    doCallRealMethod().when(typeSelect).setValue(any(String.class));
    doCallRealMethod().when(typeSelect).getValue();
    doCallRealMethod().when(view).setReadOnly(any(boolean.class));
    doNothing().when(view).createOrEdit(any(NotificationWidgetView.class), any(NotificationRow.class));
    doNothing().when(view).ok();
    setFieldValue(view, "modal", modal);
    setFieldValue(view, "body", body);
    setFieldValue(view, "customerBinder", customerBinder);
    setFieldValue(view, "notCompletedInput", notCompletedInput);
    setFieldValue(view, "notStartedInput", notStartedInput);
    setFieldValue(view, "subject", subject);
    setFieldValue(view, "emails", subject);
    setFieldValue(view, "searchSelectionFromHandler", searchSelectionFromHandler);
    setFieldValue(view, "searchSelectionReplyToHandler", searchSelectionReplyToHandler);
    setFieldValue(view, "multipleLiveSearchSelectionHandlerUsers", multipleLiveSearchSelectionHandlerUsers);
    setFieldValue(view, "multipleLiveSearchSelectionHandlerGroups", multipleLiveSearchSelectionHandlerGroups);
    setFieldValue(view, "notificationEvent", notificationEvent);
    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);
    setFieldValue(view, "incorrectEmail", incorrectEmail);
    doCallRealMethod().when(body).setValue(any(String.class));
    doCallRealMethod().when(body).getValue();
    doCallRealMethod().when(subject).setValue(any(String.class));
    doCallRealMethod().when(subject).getValue();
    doCallRealMethod().when(typeSelect).setValue(any(String.class));
    doCallRealMethod().when(typeSelect).getValue();
    setFieldValue(liveSearchReplyToDropDown, "view", liveSearchDropDownView);
    when(validator.validate(any(NotificationRow.class))).thenReturn(Collections.EMPTY_SET);
    doNothing().when(liveSearchReplyToDropDown).setSelectedItem(any(String.class));
    doCallRealMethod().when(view).init(any(NotificationEditorWidgetView.Presenter.class));
    when(translationService.getValue(any(String.class))).thenReturn("Notification");
}
Also used : MultipleLiveSearchSelectionHandler(org.uberfire.ext.widgets.common.client.dropdown.MultipleLiveSearchSelectionHandler) ParagraphElement(com.google.gwt.dom.client.ParagraphElement) HTMLInputElement(elemental2.dom.HTMLInputElement) SingleLiveSearchSelectionHandler(org.uberfire.ext.widgets.common.client.dropdown.SingleLiveSearchSelectionHandler) NotificationEvent(org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BaseModal(org.uberfire.ext.widgets.common.client.common.popups.BaseModal) Select(org.gwtbootstrap3.extras.select.client.ui.Select) NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) Option(org.gwtbootstrap3.extras.select.client.ui.Option) DataBinder(org.jboss.errai.databinding.client.api.DataBinder) HTMLButtonElement(elemental2.dom.HTMLButtonElement) Before(org.junit.Before)

Aggregations

NotificationEvent (org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.event.NotificationEvent)6 Before (org.junit.Before)4 NotificationRow (org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow)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 NotificationsEditorWidget (org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.NotificationsEditorWidget)3 ReflectionUtilsTest (org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest)3 NotificationTypeListValue (org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationTypeListValue)3 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)3 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)3