TerminationTreeItemContent implements IsElement { public void removeTreeItem() { TerminationTreeItemContent parent = (treeItem.getParentItem() == null ? this : (TerminationTreeItemContent) treeItem.getParentItem().getUserObject()); getTerminationManager(terminationConfigOption).removeModelValue(); parent.getView().addDropDownOption(terminationConfigOption); treeItem.remove(); terminationConfigForm.displayEmptyTreeLabel(terminationConfigForm.getRootTreeItem().getChildCount() == 0); terminationConfigForm.destroyTerminationTreeItemContent(this); } @Inject  TerminationTreeItemContent(final TerminationTreeItemContentView view,
                                      final TranslationService translationService); TreeItem getTreeItem(); TerminationConfigModel getModel(); TerminationConfigOption getTerminationConfigOption(); void removeDropDownOption(TerminationConfigOption terminationConfigOption); TerminationTreeItemContentView getView(); void setModel(TerminationConfigModel model); void setTerminationConfigOption(TerminationConfigOption terminationConfigOption); void setTreeItem(TreeItem treeItem); void onTerminationTypeSelected(String terminationType); void setTerminationConfigForm(TerminationConfigForm terminationConfigForm); void removeTreeItem(); void onDaysSpentChange(Long value); void onHoursSpentChange(Long value); void onMinutesSpentChange(Long value); void onSecondsSpentChange(Long value); void onMillisecondsSpentChange(Long value); void onUnimprovedDaysSpentChange(Long value); void onUnimprovedHoursSpentChange(Long value); void onUnimprovedMinutesSpentChange(Long value); void onUnimprovedSecondsSpentChange(Long value); void onUnimprovedMillisecondsSpentChange(Long value); void onStepCountLimitChange(Integer value); void onUnimprovedStepCountLimitChange(Integer value); void onScoreCalculationLimitChange(Long value); void onFeasibilityChange(Boolean value); void onBestScoreLimitChange(String value); void onTerminationCompositionStyleChange(TerminationCompositionStyleModel value); void setExistingValue(Object value,
                                 TerminationConfigOption terminationConfigOption); void setNewValue(TerminationConfigOption terminationConfigOption); @Override HTMLElement getElement(); static final long MINUTES_SPENT_DEFAULT_VALUE; static final long UNIMPROVED_MINUTES_SPENT_DEFAULT_VALUE; }
@Test public void removeTreeItem() { terminationTreeItemContent.setTreeItem(new TreeItem()); terminationTreeItemContent.setTerminationConfigOption(TerminationConfigOption.MILLISECONDS_SPENT_LIMIT); TreeItem rootTreeItem = mock(TreeItem.class); when(rootTreeItem.getChildCount()).thenReturn(0); when(terminationConfigForm.getRootTreeItem()).thenReturn(rootTreeItem); terminationTreeItemContent.removeTreeItem(); verify(terminationConfigModel, times(1)).setMillisecondsSpentLimit(null); verify(view, times(1)).addDropDownOption(TerminationConfigOption.MILLISECONDS_SPENT_LIMIT); verify(terminationConfigForm, times(1)).displayEmptyTreeLabel(true); }