GenericItem implements ActiveItem { public void dispose() { this.listeners.clear(); this.eventPublisher = null; this.stateDescriptionService = null; this.commandDescriptionService = null; this.unitProvider = null; this.itemStateConverter = null; } GenericItem(String type, String name); @Override State getState(); @Override T getStateAs(Class<T> typeClass); @Override String getUID(); @Override String getName(); @Override String getType(); @Override List<String> getGroupNames(); @Override void addGroupName(String groupItemName); @Override void addGroupNames(String... groupItemNames); @Override void addGroupNames(List<String> groupItemNames); @Override void removeGroupName(String groupItemName); void dispose(); void setEventPublisher(@Nullable EventPublisher eventPublisher); void setStateDescriptionService(@Nullable StateDescriptionService stateDescriptionService); void setCommandDescriptionService(@Nullable CommandDescriptionService commandDescriptionService); void setUnitProvider(@Nullable UnitProvider unitProvider); void setItemStateConverter(@Nullable ItemStateConverter itemStateConverter); void setState(State state); void send(RefreshType command); @Override String toString(); void addStateChangeListener(StateChangeListener listener); void removeStateChangeListener(StateChangeListener listener); @Override int hashCode(); @Override boolean equals(@Nullable Object obj); @Override Set<String> getTags(); @Override boolean hasTag(String tag); @Override void addTag(String tag); @Override void addTags(Collection<String> tags); @Override void addTags(String... tags); @Override void removeTag(String tag); @Override void removeAllTags(); @Override @Nullable String getLabel(); @Override void setLabel(@Nullable String label); @Override @Nullable String getCategory(); @Override void setCategory(@Nullable String category); @Override @Nullable StateDescription getStateDescription(); @Override @Nullable StateDescription getStateDescription(@Nullable Locale locale); @Override @Nullable CommandDescription getCommandDescription(@Nullable Locale locale); boolean isAcceptedState(List<Class<? extends State>> acceptedDataTypes, State state);  }
@Test public void testDispose() { TestItem item = new TestItem("test"); item.setEventPublisher(mock(EventPublisher.class)); item.setItemStateConverter(mock(ItemStateConverter.class)); item.setStateDescriptionService(null); item.setUnitProvider(mock(UnitProvider.class)); item.addStateChangeListener(mock(StateChangeListener.class)); item.dispose(); assertNull(item.eventPublisher); assertNull(item.itemStateConverter); assertNull(item.unitProvider); assertEquals(0, item.listeners.size()); }