### Question:
ItemDefinitionDestroyHandler { public void destroy(final DataType dataType, final boolean notifyPropertiesPanel) { final ItemDefinition itemDefinition = findItemDefinition(dataType); final String destroyedItemDefinition = itemDefinition.getName().getValue(); final Optional<ItemDefinition> itemDefinitionParent = findItemDefinitionParent(dataType); itemDefinitionParent.ifPresent(parent -> { parent.getItemComponent().remove(itemDefinition); }); itemDefinitions().remove(itemDefinition); itemDefinitionStore.unIndex(dataType.getUUID()); if (notifyPropertiesPanel) { notifyPropertiesPanel(destroyedItemDefinition); } } @Inject  ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore,
                                        final DMNGraphUtils dmnGraphUtils,
                                        final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel);  }### Answer:
@Test public void testDestroy() { final String uuid = "uuid"; final String oldItemDefinitionName = "oldItemDefinitionName"; final DataType dataType = mock(DataType.class); final Name name = mock(Name.class); final ItemDefinition itemDefinition = makeItemDefinition(); final ItemDefinition itemDefinitionParent = makeItemDefinition(itemDefinition); final List<ItemDefinition> itemDefinitions = new ArrayList<ItemDefinition>() {{ add(itemDefinition); }}; when(name.getValue()).thenReturn(oldItemDefinitionName); when(itemDefinitionStore.get(uuid)).thenReturn(itemDefinition); when(dataType.getUUID()).thenReturn(uuid); doReturn(Optional.of(itemDefinitionParent)).when(handler).findItemDefinitionParent(dataType); doReturn(name).when(itemDefinition).getName(); doReturn(itemDefinitions).when(handler).itemDefinitions(); doNothing().when(handler).notifyPropertiesPanel(anyString()); handler.destroy(dataType, true); assertEquals(emptyList(), itemDefinitionParent.getItemComponent()); assertEquals(emptyList(), itemDefinitions); verify(handler).notifyPropertiesPanel(oldItemDefinitionName); }