use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent in project kie-wb-common by kiegroup.
the class ReassignmentEditorWidgetTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
GwtMockito.initMocks(this);
modal = mock(BaseModal.class);
notStarted = mock(Option.class);
notCompleted = mock(Option.class);
customerBinder = mock(DataBinder.class);
multipleLiveSearchSelectionHandlerUsers = mock(MultipleLiveSearchSelectionHandler.class);
multipleLiveSearchSelectionHandlerGroups = mock(MultipleLiveSearchSelectionHandler.class);
doNothing().when(modal).hide();
doNothing().when(modal).show();
doNothing().when(reassignmentEvent).fire(any(ReassignmentEvent.class));
doCallRealMethod().when(reassignmentEditorWidget).setReadOnly(any(boolean.class));
doCallRealMethod().when(reassignmentEditorWidget).getNameHeader();
setFieldValue(reassignmentEditorWidget, "view", view);
setFieldValue(reassignmentEditorWidget, "translationService", translationService);
doCallRealMethod().when(typeSelect).setValue(any(String.class));
doCallRealMethod().when(typeSelect).getValue();
doCallRealMethod().when(view).setReadOnly(any(boolean.class));
doCallRealMethod().when(view).initTypeSelector();
doCallRealMethod().when(view).createOrEdit(any(ReassignmentWidgetView.class), any(ReassignmentRow.class));
doCallRealMethod().when(view).ok();
setFieldValue(view, "modal", modal);
setFieldValue(view, "customerBinder", customerBinder);
setFieldValue(view, "multipleLiveSearchSelectionHandlerUsers", multipleLiveSearchSelectionHandlerUsers);
setFieldValue(view, "multipleLiveSearchSelectionHandlerGroups", multipleLiveSearchSelectionHandlerGroups);
setFieldValue(view, "reassignmentEvent", reassignmentEvent);
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);
doCallRealMethod().when(typeSelect).setValue(any(String.class));
doCallRealMethod().when(typeSelect).getValue();
when(validator.validate(any(ReassignmentRow.class))).thenReturn(Collections.EMPTY_SET);
doCallRealMethod().when(view).init(any(ReassignmentEditorWidgetView.Presenter.class));
when(translationService.getValue(any(String.class))).thenReturn("Reassignment");
view.initTypeSelector();
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent 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());
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent 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());
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent 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());
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.reassignmentsEditor.event.ReassignmentEvent in project kie-wb-common by kiegroup.
the class ReassignmentEditorWidgetViewImpl method ok.
protected void ok() {
// TODO looks like errai data binder doenst support liststore widgets.
current.setUsers(multipleLiveSearchSelectionHandlerUsers.getSelectedValues());
current.setGroups(multipleLiveSearchSelectionHandlerGroups.getSelectedValues());
current.setType(customerBinder.getModel().getType());
current.setDuration(customerBinder.getModel().getDuration());
Set<ConstraintViolation<ReassignmentValue>> violations = validator.validate(current.toReassignmentValue());
if (violations.isEmpty()) {
reassignmentEvent.fire(new ReassignmentEvent(current));
hide();
} else {
onViolationError(violations);
}
}
Aggregations