### Question:
ItemDefinitionDestroyHandler { List<ItemDefinition> itemDefinitions() { final Optional<Definitions> definitions = Optional.ofNullable(dmnGraphUtils.getModelDefinitions()); if (definitions.isPresent()) { return definitions.get().getItemDefinition(); } return new ArrayList<>(); } @Inject  ItemDefinitionDestroyHandler(final ItemDefinitionStore itemDefinitionStore,
                                        final DMNGraphUtils dmnGraphUtils,
                                        final PropertiesPanelNotifier panelNotifier); void destroy(final DataType dataType, final boolean notifyPropertiesPanel);  }### Answer:
@Test public void testItemDefinitions() { final Definitions definitions = mock(Definitions.class); final ItemDefinition itemDefinition = makeItemDefinition(); final List<ItemDefinition> expectedItemDefinitions = singletonList(itemDefinition); when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions); when(definitions.getItemDefinition()).thenReturn(expectedItemDefinitions); final List<ItemDefinition> actualItemDefinitions = handler.itemDefinitions(); assertEquals(expectedItemDefinitions, actualItemDefinitions); }
@Test public void testItemDefinitionsWhenDefinitionsIsNull() { final List<ItemDefinition> expectedItemDefinitions = emptyList(); when(dmnGraphUtils.getModelDefinitions()).thenReturn(null); final List<ItemDefinition> actualItemDefinitions = handler.itemDefinitions(); assertEquals(expectedItemDefinitions, actualItemDefinitions); }