@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")); }
@Override 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; }
VariablesEditorFieldRenderer extends FieldRenderer<VariablesEditorFieldDefinition, DefaultFormGroup> implements VariablesEditorWidgetView.Presenter { @Override 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; } }
VariablesEditorFieldRenderer extends FieldRenderer<VariablesEditorFieldDefinition, DefaultFormGroup> implements VariablesEditorWidgetView.Presenter { @Override 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; } @Inject  VariablesEditorFieldRenderer(final VariablesEditorWidgetView variablesEditor,
                                        final SessionManager sessionManager,
                                        final ErrorPopupPresenter errorPopupPresenter); }
VariablesEditorFieldRenderer extends FieldRenderer<VariablesEditorFieldDefinition, DefaultFormGroup> implements VariablesEditorWidgetView.Presenter { @Override 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; } @Inject  VariablesEditorFieldRenderer(final VariablesEditorWidgetView variablesEditor,
                                        final SessionManager sessionManager,
                                        final ErrorPopupPresenter errorPopupPresenter); @Override String getName(); @Override void doSave(); @Override void addVariable(); @Override void setDataTypes(final List<String> dataTypes,
                             final List<String> dataTypeDisplayNames); @Override void notifyModelChanged(); @Override List<VariableRow> deserializeVariables(final String s); @Override String serializeVariables(final List<VariableRow> variableRows); @Override boolean isDuplicateName(final String name); @Override boolean isBoundToNodes(String name); @Override void removeVariable(final VariableRow variableRow); @Override ListBoxValues.ValueTester dataTypesTester(); @Override Path getDiagramPath(); void setLastOverlayOpened(final Button overlayCloseButton); Button getLastOverlayOpened(); void closeLastOverlay(); static Set<String> getDefaultTagsSet(); }
VariablesEditorFieldRenderer extends FieldRenderer<VariablesEditorFieldDefinition, DefaultFormGroup> implements VariablesEditorWidgetView.Presenter { @Override 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; } @Inject  VariablesEditorFieldRenderer(final VariablesEditorWidgetView variablesEditor,
                                        final SessionManager sessionManager,
                                        final ErrorPopupPresenter errorPopupPresenter); @Override String getName(); @Override void doSave(); @Override void addVariable(); @Override void setDataTypes(final List<String> dataTypes,
                             final List<String> dataTypeDisplayNames); @Override void notifyModelChanged(); @Override List<VariableRow> deserializeVariables(final String s); @Override String serializeVariables(final List<VariableRow> variableRows); @Override boolean isDuplicateName(final String name); @Override boolean isBoundToNodes(String name); @Override void removeVariable(final VariableRow variableRow); @Override ListBoxValues.ValueTester dataTypesTester(); @Override Path getDiagramPath(); void setLastOverlayOpened(final Button overlayCloseButton); Button getLastOverlayOpened(); void closeLastOverlay(); static Set<String> getDefaultTagsSet();  }