### Question:
DNDDataTypesHandler { public void deleteKeepingReferences(final DataType existing) { final Optional<DataTypeListItem> currentItem = getDataTypeList().findItem(existing); currentItem.ifPresent(item -> { item.destroyWithoutDependentTypes(); }); } @Inject  DNDDataTypesHandler(final DataTypeStore dataTypeStore,
                               final DataTypeManager dataTypeManager,
                               final ItemDefinitionStore itemDefinitionStore); void init(final DataTypeList dataTypeList); void onDropDataType(final Element currentElement,
                               final Element hoverElement); void deleteKeepingReferences(final DataType existing);  }### Answer:
@Test public void testDeleteKeepingReferences() { final DataType existing = mock(DataType.class); final DataTypeListItem dtListItem = mock(DataTypeListItem.class); final Optional<DataTypeListItem> item = Optional.of(dtListItem); when(dataTypeList.findItem(existing)).thenReturn(item); handler.deleteKeepingReferences(existing); verify(dtListItem).destroyWithoutDependentTypes(); }
@Test public void testDeleteKeepingReferencesItemNotPresent() { final DataType existing = mock(DataType.class); final DataTypeListItem dtListItem = mock(DataTypeListItem.class); final Optional<DataTypeListItem> item = Optional.empty(); when(dataTypeList.findItem(existing)).thenReturn(item); handler.deleteKeepingReferences(existing); verify(dtListItem, never()).destroyWithoutDependentTypes(); }