### Question:
DataTypeList { public void importDataObjects(final List<DataObject> selectedDataObjects) { removeFullQualifiedNames(selectedDataObjects); for (final DataObject dataObject : selectedDataObjects) { final DataType newDataType = createNewDataType(dataObject); final Optional<DataType> existing = findDataTypeByName(dataObject.getClassType()); if (existing.isPresent()) { replace(existing.get(), newDataType); } else { insert(newDataType); } insertProperties(dataObject); } } @Inject  DataTypeList(final View view,
                        final ManagedInstance<DataTypeListItem> listItems,
                        final DataTypeManager dataTypeManager,
                        final DataTypeSearchBar searchBar,
                        final DNDListComponent dndListComponent,
                        final DataTypeStackHash dataTypeStackHash,
                        final DNDDataTypesHandler dndDataTypesHandler,
                        final DataTypeListHighlightHelper highlightHelper,
                        final IsKogito isKogito); HTMLElement getElement(); void setupItems(final List<DataType> dataTypes); Optional<DataTypeListItem> findItem(final DataType dataType); DNDListComponent getDNDListComponent(); List<DataTypeListItem> getItems(); void showNoDataTypesFound(); void showListItems(); void collapseAll(); void enableEditMode(final String dataTypeHash); void registerDataTypeListItemUpdateCallback(final Consumer<DataTypeListItem> onDataTypeListItemUpdate); Optional<DataTypeListItem> findItemByDataTypeHash(final String dataTypeHash); String calculateHash(final DataType dataType); void onDataTypeEditModeToggle(final @Observes DataTypeEditModeToggleEvent event); HTMLElement getListItems(); void importDataObjects(final List<DataObject> selectedDataObjects); void disableEditModeForChildren(final DataTypeListItem dataTypeListItem); List<String> getExistingDataTypesNames(); void highlightLevel(final DataType dataType); void highlightLevel(final Element element); void highlight(final Element element); void cleanLevelHighlightClass(); void cleanHighlightClass();  }### Answer:
@Test public void testImportDataObjects() { final DataObject present = mock(DataObject.class); final DataObject notPresent = mock(DataObject.class); final List<DataObject> selectedDataObjects = asList(present, notPresent); final DataType presentDataType = mock(DataType.class); final DataType notPresentDataType = mock(DataType.class); final String notPresentClass = "not.present"; final String importedPresentClass = "org.something.MyClass"; final DataType existingDataType = mock(DataType.class); doReturn(presentDataType).when(dataTypeList).createNewDataType(present); doReturn(notPresentDataType).when(dataTypeList).createNewDataType(notPresent); doReturn(Optional.of(existingDataType)).when(dataTypeList).findDataTypeByName(importedPresentClass); doReturn(Optional.empty()).when(dataTypeList).findDataTypeByName(notPresentClass); doNothing().when(dataTypeList).replace(existingDataType, presentDataType); doNothing().when(dataTypeList).insertProperties(present); doNothing().when(dataTypeList).insertProperties(notPresent); doNothing().when(dataTypeList).insert(notPresentDataType); doNothing().when(dataTypeList).removeFullQualifiedNames(selectedDataObjects); when(notPresent.getClassType()).thenReturn(notPresentClass); when(present.getClassType()).thenReturn(importedPresentClass); dataTypeList.importDataObjects(selectedDataObjects); verify(dataTypeList).findDataTypeByName(importedPresentClass); verify(dataTypeList).replace(existingDataType, presentDataType); verify(dataTypeList).insertProperties(present); verify(dataTypeList, never()).insert(presentDataType); verify(dataTypeList).insert(notPresentDataType); verify(dataTypeList).insertProperties(notPresent); verify(dataTypeList).removeFullQualifiedNames(selectedDataObjects); }