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());
}
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());
}
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);
}
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());
}
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);
}
}
}
Aggregations