@Test public void testHandleAcceptButton() { view.setParentWidget(parent); view.setTagSet(new HashSet<>()); view.getTagSet().add("myCustomTag"); when(tagNamesComboBox.getValue()).thenReturn("myCustomTag"); view.handleAcceptButton(null); verify(view, never()).renderTagElementsBadges(); assertTrue(view.getTagSet().contains("myCustomTag")); when(tagNamesComboBox.getValue()).thenReturn(""); view.handleAcceptButton(null); verify(view, never()).renderTagElementsBadges(); assertFalse(view.getTagSet().contains("")); verify(view, never()).renderTagElementsBadges(); when(tagNamesComboBox.getValue()).thenReturn("myCustomTag"); view.getTagSet().clear(); view.getTagSet().addAll(Arrays.asList("internal", "outer", "tracked")); view.removeButtons = new HashMap<>(); view.handleAcceptButton(null); verify(view, times(1)).renderTagElementsBadges(); assertTrue(view.getTagSet().contains("myCustomTag")); when(view.getPreviousCustomValue()).thenReturn("myCustom"); view.getTagSet().clear(); view.getTagSet().addAll(Arrays.asList("internal", "outer", "tracked")); view.handleAcceptButton(null); verify(view, times(2)).renderTagElementsBadges(); assertTrue(view.getTagSet().contains("myCustomTag")); assertFalse(view.getTagSet().contains("myCustom")); view.getTagSet().clear(); view.getTagSet().addAll(Arrays.asList("internal", "outer", "tracked")); when(view.getPreviousCustomValue()).thenReturn("myCustomTag"); view.handleAcceptButton(null); verify(view, times(3)).renderTagElementsBadges(); assertTrue(view.getTagSet().contains("myCustomTag")); when(tagNamesComboBox.getValue()).thenReturn("input"); view.getTagSet().clear(); view.getTagSet().addAll(Arrays.asList("output")); when(view.getPreviousCustomValue()).thenReturn("myCustomTagX"); view.handleAcceptButton(null); verify(view, times(4)).renderTagElementsBadges(); assertTrue(view.getTagSet().contains("output")); }
@EventHandler("acceptButton") public void handleAcceptButton(final ClickEvent e) { final String tagAdded = tagNamesComboBox.getValue(); if (!Strings.isNullOrEmpty(tagAdded) && !tagSet.contains(tagAdded)) { for (final HTMLAnchorElement closeAnchor : removeButtons.values()) { closeAnchor.onclick.onInvoke(new elemental2.dom.Event("DoNotUpdateModel")); } removeButtons.clear(); tagSet.add(tagAdded); setCustomTags(setToList(tagSet)); notifyModelChanged(); if (!VariablesEditorFieldRenderer.getDefaultTagsSet().contains(tagAdded) && getPreviousCustomValue() != null && !tagAdded.equals(getPreviousCustomValue())) { tagSet.remove(getPreviousCustomValue()); } renderTagElementsBadges(); } }
VariableListItemWidgetViewImpl implements VariableListItemWidgetView,
                                                       ComboBoxView.ModelPresenter { @EventHandler("acceptButton") public void handleAcceptButton(final ClickEvent e) { final String tagAdded = tagNamesComboBox.getValue(); if (!Strings.isNullOrEmpty(tagAdded) && !tagSet.contains(tagAdded)) { for (final HTMLAnchorElement closeAnchor : removeButtons.values()) { closeAnchor.onclick.onInvoke(new elemental2.dom.Event("DoNotUpdateModel")); } removeButtons.clear(); tagSet.add(tagAdded); setCustomTags(setToList(tagSet)); notifyModelChanged(); if (!VariablesEditorFieldRenderer.getDefaultTagsSet().contains(tagAdded) && getPreviousCustomValue() != null && !tagAdded.equals(getPreviousCustomValue())) { tagSet.remove(getPreviousCustomValue()); } renderTagElementsBadges(); } } }
VariableListItemWidgetViewImpl implements VariableListItemWidgetView,
                                                       ComboBoxView.ModelPresenter { @EventHandler("acceptButton") public void handleAcceptButton(final ClickEvent e) { final String tagAdded = tagNamesComboBox.getValue(); if (!Strings.isNullOrEmpty(tagAdded) && !tagSet.contains(tagAdded)) { for (final HTMLAnchorElement closeAnchor : removeButtons.values()) { closeAnchor.onclick.onInvoke(new elemental2.dom.Event("DoNotUpdateModel")); } removeButtons.clear(); tagSet.add(tagAdded); setCustomTags(setToList(tagSet)); notifyModelChanged(); if (!VariablesEditorFieldRenderer.getDefaultTagsSet().contains(tagAdded) && getPreviousCustomValue() != null && !tagAdded.equals(getPreviousCustomValue())) { tagSet.remove(getPreviousCustomValue()); } renderTagElementsBadges(); } }  }
VariableListItemWidgetViewImpl implements VariableListItemWidgetView,
                                                       ComboBoxView.ModelPresenter { @EventHandler("acceptButton") public void handleAcceptButton(final ClickEvent e) { final String tagAdded = tagNamesComboBox.getValue(); if (!Strings.isNullOrEmpty(tagAdded) && !tagSet.contains(tagAdded)) { for (final HTMLAnchorElement closeAnchor : removeButtons.values()) { closeAnchor.onclick.onInvoke(new elemental2.dom.Event("DoNotUpdateModel")); } removeButtons.clear(); tagSet.add(tagAdded); setCustomTags(setToList(tagSet)); notifyModelChanged(); if (!VariablesEditorFieldRenderer.getDefaultTagsSet().contains(tagAdded) && getPreviousCustomValue() != null && !tagAdded.equals(getPreviousCustomValue())) { tagSet.remove(getPreviousCustomValue()); } renderTagElementsBadges(); } }  Set<String> getTagSet(); void setTagSet(Set<String> tagSet); String getPreviousCustomValue(); void setPreviousCustomValue(String previousCustomValue); void setParentWidget(final VariablesEditorWidgetView.Presenter parentWidget); @Override void setTextBoxModelValue(final TextBox textBox,
                                     final String value); @Override void setListBoxModelValue(final ValueListBox<String> listBox,
                                     final String value); @Override String getModelValue(final ValueListBox<String> listBox); @PostConstruct void init(); @Override VariableRow getModel(); @Override void setModel(final VariableRow model); @Override VariableType getVariableType(); @Override String getDataTypeDisplayName(); @Override void setDataTypeDisplayName(final String dataTypeDisplayName); @Override String getCustomDataType(); @Override void setCustomDataType(final String customDataType); @Override void setCustomTags(final List<String> tags); @Override List<String> getCustomTags(); @Override void setDataTypes(final ListBoxValues dataTypeListBoxValues); @Override void setTagTypes(final List<String> tagTypes); @Override void setReadOnly(final boolean readOnly); @EventHandler("deleteButton") void handleDeleteButton(final ClickEvent e); @EventHandler("closeButton") void handleCloseButton(final ClickEvent e); @EventHandler("acceptButton") void handleAcceptButton(final ClickEvent e); @Override void notifyModelChanged(); @Override void setTagsNotEnabled(); }
VariableListItemWidgetViewImpl implements VariableListItemWidgetView,
                                                       ComboBoxView.ModelPresenter { @EventHandler("acceptButton") public void handleAcceptButton(final ClickEvent e) { final String tagAdded = tagNamesComboBox.getValue(); if (!Strings.isNullOrEmpty(tagAdded) && !tagSet.contains(tagAdded)) { for (final HTMLAnchorElement closeAnchor : removeButtons.values()) { closeAnchor.onclick.onInvoke(new elemental2.dom.Event("DoNotUpdateModel")); } removeButtons.clear(); tagSet.add(tagAdded); setCustomTags(setToList(tagSet)); notifyModelChanged(); if (!VariablesEditorFieldRenderer.getDefaultTagsSet().contains(tagAdded) && getPreviousCustomValue() != null && !tagAdded.equals(getPreviousCustomValue())) { tagSet.remove(getPreviousCustomValue()); } renderTagElementsBadges(); } }  Set<String> getTagSet(); void setTagSet(Set<String> tagSet); String getPreviousCustomValue(); void setPreviousCustomValue(String previousCustomValue); void setParentWidget(final VariablesEditorWidgetView.Presenter parentWidget); @Override void setTextBoxModelValue(final TextBox textBox,
                                     final String value); @Override void setListBoxModelValue(final ValueListBox<String> listBox,
                                     final String value); @Override String getModelValue(final ValueListBox<String> listBox); @PostConstruct void init(); @Override VariableRow getModel(); @Override void setModel(final VariableRow model); @Override VariableType getVariableType(); @Override String getDataTypeDisplayName(); @Override void setDataTypeDisplayName(final String dataTypeDisplayName); @Override String getCustomDataType(); @Override void setCustomDataType(final String customDataType); @Override void setCustomTags(final List<String> tags); @Override List<String> getCustomTags(); @Override void setDataTypes(final ListBoxValues dataTypeListBoxValues); @Override void setTagTypes(final List<String> tagTypes); @Override void setReadOnly(final boolean readOnly); @EventHandler("deleteButton") void handleDeleteButton(final ClickEvent e); @EventHandler("closeButton") void handleCloseButton(final ClickEvent e); @EventHandler("acceptButton") void handleAcceptButton(final ClickEvent e); @Override void notifyModelChanged(); @Override void setTagsNotEnabled();  }