@Test public void testRemoveFullQualifiedNames() { final String do1Class = "something.class1"; final String do2Class = "something.class2"; final String do3Class = "something.class3"; final String extractedName1 = "class1"; final String extractedName2 = "class2"; final String extractedName3 = "class3"; final String builtName1 = "name1"; final String builtName2 = "name2"; final String builtName3 = "name3"; final DataObject do1 = createDataObject(do1Class); final DataObject do2 = createDataObject(do2Class); final DataObject do3 = createDataObject(do3Class); final HashMap<String, Integer> namesCount = new HashMap<>(); final HashMap<String, String> renamed = new HashMap<>(); namesCount.put("trash", 0); renamed.put("trash.from.previous", "previous"); doReturn(namesCount).when(dataTypeList).getImportedNamesOccurrencesCount(); doReturn(renamed).when(dataTypeList).getRenamedImportedDataTypes(); final List<DataObject> imported = Arrays.asList(do1, do2, do3); when(do1.getClassNameWithoutPackage()).thenReturn(extractedName1); when(do2.getClassNameWithoutPackage()).thenReturn(extractedName2); when(do3.getClassNameWithoutPackage()).thenReturn(extractedName3); doReturn(builtName1).when(dataTypeList).buildName(extractedName1, namesCount); doReturn(builtName2).when(dataTypeList).buildName(extractedName2, namesCount); doReturn(builtName3).when(dataTypeList).buildName(extractedName3, namesCount); doNothing().when(dataTypeList).updatePropertiesReferences(imported, renamed); dataTypeList.removeFullQualifiedNames(imported); verify(do1).getClassNameWithoutPackage(); verify(dataTypeList).buildName(extractedName1, namesCount); assertTrue(renamed.containsKey(do1Class)); assertEquals(builtName1, renamed.get(do1Class)); verify(do1).setClassType(builtName1); verify(do2).getClassNameWithoutPackage(); verify(dataTypeList).buildName(extractedName2, namesCount); assertTrue(renamed.containsKey(do2Class)); assertEquals(builtName2, renamed.get(do2Class)); verify(do2).setClassType(builtName2); verify(do3).getClassNameWithoutPackage(); verify(dataTypeList).buildName(extractedName3, namesCount); assertTrue(renamed.containsKey(do3Class)); assertEquals(builtName3, renamed.get(do3Class)); verify(do3).setClassType(builtName3); assertEquals(3, renamed.size()); verify(dataTypeList).updatePropertiesReferences(imported, renamed); }
void removeFullQualifiedNames(final List<DataObject> imported) { final Map<String, Integer> namesCount = getImportedNamesOccurrencesCount(); final Map<String, String> renamed = getRenamedImportedDataTypes(); namesCount.clear(); renamed.clear(); for (final DataObject dataObject : imported) { final String nameCandidate = dataObject.getClassNameWithoutPackage(); final String newName = buildName(nameCandidate, namesCount); renamed.put(dataObject.getClassType(), newName); dataObject.setClassType(newName); } updatePropertiesReferences(imported, renamed); }
DataTypeList { void removeFullQualifiedNames(final List<DataObject> imported) { final Map<String, Integer> namesCount = getImportedNamesOccurrencesCount(); final Map<String, String> renamed = getRenamedImportedDataTypes(); namesCount.clear(); renamed.clear(); for (final DataObject dataObject : imported) { final String nameCandidate = dataObject.getClassNameWithoutPackage(); final String newName = buildName(nameCandidate, namesCount); renamed.put(dataObject.getClassType(), newName); dataObject.setClassType(newName); } updatePropertiesReferences(imported, renamed); } }
DataTypeList { void removeFullQualifiedNames(final List<DataObject> imported) { final Map<String, Integer> namesCount = getImportedNamesOccurrencesCount(); final Map<String, String> renamed = getRenamedImportedDataTypes(); namesCount.clear(); renamed.clear(); for (final DataObject dataObject : imported) { final String nameCandidate = dataObject.getClassNameWithoutPackage(); final String newName = buildName(nameCandidate, namesCount); renamed.put(dataObject.getClassType(), newName); dataObject.setClassType(newName); } updatePropertiesReferences(imported, renamed); } @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); }
DataTypeList { void removeFullQualifiedNames(final List<DataObject> imported) { final Map<String, Integer> namesCount = getImportedNamesOccurrencesCount(); final Map<String, String> renamed = getRenamedImportedDataTypes(); namesCount.clear(); renamed.clear(); for (final DataObject dataObject : imported) { final String nameCandidate = dataObject.getClassNameWithoutPackage(); final String newName = buildName(nameCandidate, namesCount); renamed.put(dataObject.getClassType(), newName); dataObject.setClassType(newName); } updatePropertiesReferences(imported, renamed); } @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(); }
DataTypeList { void removeFullQualifiedNames(final List<DataObject> imported) { final Map<String, Integer> namesCount = getImportedNamesOccurrencesCount(); final Map<String, String> renamed = getRenamedImportedDataTypes(); namesCount.clear(); renamed.clear(); for (final DataObject dataObject : imported) { final String nameCandidate = dataObject.getClassNameWithoutPackage(); final String newName = buildName(nameCandidate, namesCount); renamed.put(dataObject.getClassType(), newName); dataObject.setClassType(newName); } updatePropertiesReferences(imported, renamed); } @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();  }