Search in sources :

Example 81 with NotificationRow

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

the class NotificationWidgetViewImplTest method testRowCountOneAndTwo.

@Test
public void testRowCountOneAndTwo() {
    List<NotificationRow> rows = new ArrayList<>();
    rows.add(new NotificationRow());
    notificationWidgetViewImpl.init(presenter, rows);
    ListDataProvider<NotificationRow> dataProvider = getFieldValue(NotificationWidgetViewImpl.class, notificationWidgetViewImpl, "dataProvider");
    Assert.assertEquals(1, dataProvider.getList().size());
    rows = new ArrayList<>();
    rows.add(new NotificationRow());
    notificationWidgetViewImpl.init(presenter, rows);
    Assert.assertEquals(1, dataProvider.getList().size());
    rows.add(new NotificationRow());
    notificationWidgetViewImpl.init(presenter, rows);
    Assert.assertEquals(2, dataProvider.getList().size());
    notificationWidgetViewImpl.init(presenter, Collections.EMPTY_LIST);
    Assert.assertEquals(0, dataProvider.getList().size());
}
Also used : NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) ArrayList(java.util.ArrayList) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) Test(org.junit.Test)

Example 82 with NotificationRow

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

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

the class NotificationWidgetViewImplTest method testDeleteRow.

@Test
public void testDeleteRow() {
    NotificationRow row4 = new NotificationRow();
    row4.setId(4);
    notificationWidgetViewImpl.init(presenter, generateRows());
    ListDataProvider<NotificationRow> dataProvider = getFieldValue(NotificationWidgetViewImpl.class, notificationWidgetViewImpl, "dataProvider");
    Assert.assertEquals(4, dataProvider.getList().size());
    notificationWidgetViewImpl.delete(row4);
    Assert.assertEquals(3, dataProvider.getList().size());
}
Also used : NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) ReflectionUtilsTest(org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest) Test(org.junit.Test)

Example 84 with NotificationRow

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

the class NotificationValueValidatorTest method testP2y10M14dT20h13m.

@Test
public void testP2y10M14dT20h13m() {
    NotificationRow value = new NotificationRow();
    value.setExpiresAt("P2y10M14dT20h13m");
    boolean result = validator.isValid(value, context);
    assertTrue(result);
    assertTrue(errorMessages.isEmpty());
}
Also used : NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) Test(org.junit.Test)

Example 85 with NotificationRow

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

the class NotificationValueValidatorTest method testDayRepeatableUntilStateChangesNotification.

@Test
public void testDayRepeatableUntilStateChangesNotification() {
    NotificationRow notification = new NotificationRow();
    notification.setExpiresAt("R/P33D");
    boolean result = validator.isValid(notification, context);
    assertTrue(result);
    assertTrue(errorMessages.isEmpty());
}
Also used : NotificationRow(org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow) Test(org.junit.Test)

Aggregations

NotificationRow (org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.NotificationRow)140 Test (org.junit.Test)127 Column (com.google.gwt.user.cellview.client.Column)11 ReflectionUtilsTest (org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest)9 PopoverTextCell (org.uberfire.ext.widgets.common.client.tables.PopoverTextCell)9 ArrayList (java.util.ArrayList)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 LienzoMockitoTestRunner (com.ait.lienzo.test.LienzoMockitoTestRunner)3 TextCell (com.google.gwt.cell.client.TextCell)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 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