### Question:
DataTypeList { void insertProperties(final DataObject dataObject) { final Optional<DataType> existing = findDataTypeByName(dataObject.getClassType()); existing.ifPresent(dataType -> findItem(dataType).ifPresent(item -> { for (final DataObjectProperty property : dataObject.getProperties()) { final DataType newDataType = createNewDataType(property); item.insertNestedField(newDataType); } })); } @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 testInsertProperties() { final DataObject dataObject = mock(DataObject.class); final String myImportedClass = "org.MyClass"; final DataType existingDt = mock(DataType.class); final DataTypeListItem dtListItem = mock(DataTypeListItem.class); final Optional<DataTypeListItem> dtListItemOptional = Optional.of(dtListItem); final DataObjectProperty property1 = mock(DataObjectProperty.class); final DataObjectProperty property2 = mock(DataObjectProperty.class); final List<DataObjectProperty> properties = Arrays.asList(property1, property2); final DataType property1DataType = mock(DataType.class); final DataType property2DataType = mock(DataType.class); when(dataObject.getClassType()).thenReturn(myImportedClass); when(dataObject.getProperties()).thenReturn(properties); doReturn(Optional.of(existingDt)).when(dataTypeList).findDataTypeByName(myImportedClass); doReturn(dtListItemOptional).when(dataTypeList).findItem(existingDt); doReturn(property1DataType).when(dataTypeList).createNewDataType(property1); doReturn(property2DataType).when(dataTypeList).createNewDataType(property2); dataTypeList.insertProperties(dataObject); verify(dtListItem).insertNestedField(property1DataType); verify(dtListItem).insertNestedField(property2DataType); }