use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow in project kie-wb-common by kiegroup.
the class VariablesEditorFieldRenderer method isDuplicateName.
/**
* Tests whether a Row name occurs more than once in the list of rows
* @param name
* @return
*/
public boolean isDuplicateName(final String name) {
if (name == null || name.trim().isEmpty()) {
return false;
}
List<VariableRow> as = view.getVariableRows();
if (as != null && !as.isEmpty()) {
int nameCount = 0;
String currName = name.trim();
for (VariableRow row : as) {
String rowName = row.getName();
if (rowName != null && currName.compareTo(rowName.trim()) == 0) {
nameCount++;
if (nameCount > 1) {
return true;
}
}
}
}
return false;
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow in project kie-wb-common by kiegroup.
the class VariablesEditorFieldRenderer method addVariable.
@Override
public void addVariable() {
List<VariableRow> as = view.getVariableRows();
if (as.isEmpty()) {
view.setTableDisplayStyle();
}
VariableRow newVariable = new VariableRow();
newVariable.setVariableType(variableType);
as.add(newVariable);
VariableListItemWidgetView widget = view.getVariableWidget(view.getVariableRowsCount() - 1);
widget.setDataTypes(dataTypeListBoxValues);
widget.setParentWidget(this);
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow in project kie-wb-common by kiegroup.
the class VariableListItemWidgetViewImplTest method testHandleDeleteButton.
@Test
public void testHandleDeleteButton() {
VariablesEditorWidgetView.Presenter widget = mock(VariablesEditorWidgetView.Presenter.class);
VariableRow model = mock(VariableRow.class);
when(view.getModel()).thenReturn(model);
view.setParentWidget(widget);
view.handleDeleteButton(null);
verify(widget).removeVariable(model);
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow in project kie-wb-common by kiegroup.
the class VariablesEditorFieldRendererTest method testIsDuplicateName.
@Test
public void testIsDuplicateName() {
List<VariableRow> variableRows = new ArrayList<VariableRow>();
variableRows.add(new VariableRow(Variable.VariableType.PROCESS, "var1", "String", null));
variableRows.add(new VariableRow(Variable.VariableType.PROCESS, "var2", "Integer", null));
variableRows.add(new VariableRow(Variable.VariableType.PROCESS, "var3", "org.stuff.Potato", null));
variableRows.add(new VariableRow(Variable.VariableType.PROCESS, "var2", "Integer", null));
variableRows.add(new VariableRow(Variable.VariableType.PROCESS, null, "Object", null));
variableRows.add(new VariableRow(Variable.VariableType.PROCESS, null, null, null));
when(variablesEditorWidgetView.getVariableRows()).thenReturn(variableRows);
assertTrue(variablesEditor.isDuplicateName("var2"));
assertFalse(variablesEditor.isDuplicateName("var1"));
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.VariableRow in project kie-wb-common by kiegroup.
the class VariableListItemWidgetTest method initTestCase.
@Before
public void initTestCase() {
GwtMockito.initMocks(this);
dataType = mock(ValueListBox.class);
customDataType = mock(TextBox.class);
dataTypeComboBox = mock(ComboBox.class);
widget = GWT.create(VariableListItemWidgetViewImpl.class);
VariableRow variableRow = new VariableRow();
widget.dataType = dataType;
widget.customDataType = customDataType;
widget.dataTypeComboBox = dataTypeComboBox;
widget.name = name;
widget.deleteButton = deleteButton;
widget.variableRow = variable;
Mockito.doCallRealMethod().when(widget).setTextBoxModelValue(any(TextBox.class), anyString());
Mockito.doCallRealMethod().when(widget).setListBoxModelValue(any(ValueListBox.class), anyString());
Mockito.doCallRealMethod().when(widget).getModelValue(any(ValueListBox.class));
Mockito.doCallRealMethod().when(widget).setDataTypeDisplayName(anyString());
Mockito.doCallRealMethod().when(widget).getDataTypeDisplayName();
Mockito.doCallRealMethod().when(widget).setCustomDataType(anyString());
Mockito.doCallRealMethod().when(widget).getCustomDataType();
Mockito.doCallRealMethod().when(widget).setDataTypes(any(ListBoxValues.class));
Mockito.doCallRealMethod().when(widget).init();
Mockito.doCallRealMethod().when(widget).setModel(any(VariableRow.class));
when(widget.getModel()).thenReturn(variableRow);
}
Aggregations