### Question:
DataTypeList { DataType createNewDataType(final DataObjectProperty dataProperty) { final DataType newDataType = dataTypeManager.fromNew() .withType(dataProperty.getType()) .asList(dataProperty.isList()) .get(); newDataType.setName(dataProperty.getProperty()); return 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 testCreateNewDataTypeFromProperty() { final DataObjectProperty dataProperty = mock(DataObjectProperty.class); final String propertyName = "name"; final String propertyType = "type"; final DataType newType = mock(DataType.class); when(dataProperty.getProperty()).thenReturn(propertyName); when(dataProperty.getType()).thenReturn(propertyType); when(dataTypeManager.fromNew()).thenReturn(dataTypeManager); when(dataTypeManager.asList(anyBoolean())).thenReturn(dataTypeManager); when(dataTypeManager.withType(propertyType)).thenReturn(dataTypeManager); when(dataTypeManager.get()).thenReturn(newType); final DataType actual = dataTypeList.createNewDataType(dataProperty); assertEquals(newType, actual); verify(dataTypeManager).asList(false); verify(newType).setName(propertyName); }
@Test public void testCreateNewDataTypeFromPropertyWhenIsList() { final DataObjectProperty dataProperty = mock(DataObjectProperty.class); final String propertyName = "name"; final String propertyType = "type"; final DataType newType = mock(DataType.class); when(dataProperty.getProperty()).thenReturn(propertyName); when(dataProperty.getType()).thenReturn(propertyType); when(dataProperty.isList()).thenReturn(true); when(dataTypeManager.fromNew()).thenReturn(dataTypeManager); when(dataTypeManager.asList(anyBoolean())).thenReturn(dataTypeManager); when(dataTypeManager.withType(propertyType)).thenReturn(dataTypeManager); when(dataTypeManager.get()).thenReturn(newType); final DataType actual = dataTypeList.createNewDataType(dataProperty); assertEquals(newType, actual); verify(dataTypeManager).asList(true); verify(newType).setName(propertyName); }
@Test public void testCreateNewDataTypeFromDataObject() { final DataObject dataObject = mock(DataObject.class); final DataType dataType = mock(DataType.class); final String structure = "structure"; final String classType = "classType"; when(dataObject.getClassType()).thenReturn(classType); when(dataTypeManager.structure()).thenReturn(structure); when(dataTypeManager.fromNew()).thenReturn(dataTypeManager); when(dataTypeManager.withType(structure)).thenReturn(dataTypeManager); when(dataTypeManager.get()).thenReturn(dataType); final DataType actual = dataTypeList.createNewDataType(dataObject); assertEquals(dataType, actual); verify(dataType).setName(classType); }