@Test public void testInsertNestedField() { final DataType newDataType = mock(DataType.class); final DataType reference = mock(DataType.class); final DataTypeListItem referenceItem = mock(DataTypeListItem.class); final List<DataType> updatedDataTypes = asList(mock(DataType.class), mock(DataType.class)); final String referenceDataTypeHash = "tDataType.id"; final String newDataTypeHash = "tDataType.id.value"; when(newDataType.create(reference, NESTED)).thenReturn(updatedDataTypes); when(dataTypeList.calculateHash(reference)).thenReturn(referenceDataTypeHash); when(dataTypeList.findItemByDataTypeHash(referenceDataTypeHash)).thenReturn(Optional.of(referenceItem)); doReturn(newDataTypeHash).when(listItem).getNewDataTypeHash(newDataType, referenceDataTypeHash); doReturn(dataTypeManager).when(dataTypeManager).fromNew(); doReturn(newDataType).when(dataTypeManager).get(); doReturn(reference).when(listItem).getDataType(); listItem.insertNestedField(); verify(dataTypeList).refreshItemsByUpdatedDataTypes(updatedDataTypes); verify(listItem).enableEditModeAndUpdateCallbacks(newDataTypeHash); verify(referenceItem).expand(); }
public void insertNestedField() { final DataType newDataType = newDataType(); final String referenceDataTypeHash = dataTypeList.calculateHash(getDataType()); insertNestedField(newDataType); enableEditModeAndUpdateCallbacks(getNewDataTypeHash(newDataType, referenceDataTypeHash)); }
DataTypeListItem { public void insertNestedField() { final DataType newDataType = newDataType(); final String referenceDataTypeHash = dataTypeList.calculateHash(getDataType()); insertNestedField(newDataType); enableEditModeAndUpdateCallbacks(getNewDataTypeHash(newDataType, referenceDataTypeHash)); } }
DataTypeListItem { public void insertNestedField() { final DataType newDataType = newDataType(); final String referenceDataTypeHash = dataTypeList.calculateHash(getDataType()); insertNestedField(newDataType); enableEditModeAndUpdateCallbacks(getNewDataTypeHash(newDataType, referenceDataTypeHash)); } @Inject  DataTypeListItem(final View view,
                            final DataTypeSelect dataTypeSelectComponent,
                            final DataTypeConstraint dataTypeConstraintComponent,
                            final SmallSwitchComponent dataTypeListComponent,
                            final DataTypeManager dataTypeManager,
                            final DataTypeConfirmation confirmation,
                            final DataTypeNameFormatValidator nameFormatValidator,
                            final Event<DataTypeEditModeToggleEvent> editModeToggleEvent,
                            final Event<DataTypeChangedEvent> dataTypeChangedEvent); }
DataTypeListItem { public void insertNestedField() { final DataType newDataType = newDataType(); final String referenceDataTypeHash = dataTypeList.calculateHash(getDataType()); insertNestedField(newDataType); enableEditModeAndUpdateCallbacks(getNewDataTypeHash(newDataType, referenceDataTypeHash)); } @Inject  DataTypeListItem(final View view,
                            final DataTypeSelect dataTypeSelectComponent,
                            final DataTypeConstraint dataTypeConstraintComponent,
                            final SmallSwitchComponent dataTypeListComponent,
                            final DataTypeManager dataTypeManager,
                            final DataTypeConfirmation confirmation,
                            final DataTypeNameFormatValidator nameFormatValidator,
                            final Event<DataTypeEditModeToggleEvent> editModeToggleEvent,
                            final Event<DataTypeChangedEvent> dataTypeChangedEvent); void init(final DataTypeList dataTypeList); DataType getDataType(); boolean isReadOnly(); int getLevel(); boolean isCollapsed(); void expand(); void collapse(); void enableEditMode(); void disableEditMode(); void saveAndCloseEditMode(); void remove(); Command removeItem(); Command destroy(); void destroyWithDependentTypes(); void destroyWithoutDependentTypes(); String getType(); void insertFieldAbove(); String insertFieldAbove(final DataType dataType); void insertFieldBelow(); String insertFieldBelow(final DataType dataType); void insertNestedField(); void insertNestedField(final DataType newDataType); HTMLElement getDragAndDropElement(); void highlightLevel(final DataType dataType); }
DataTypeListItem { public void insertNestedField() { final DataType newDataType = newDataType(); final String referenceDataTypeHash = dataTypeList.calculateHash(getDataType()); insertNestedField(newDataType); enableEditModeAndUpdateCallbacks(getNewDataTypeHash(newDataType, referenceDataTypeHash)); } @Inject  DataTypeListItem(final View view,
                            final DataTypeSelect dataTypeSelectComponent,
                            final DataTypeConstraint dataTypeConstraintComponent,
                            final SmallSwitchComponent dataTypeListComponent,
                            final DataTypeManager dataTypeManager,
                            final DataTypeConfirmation confirmation,
                            final DataTypeNameFormatValidator nameFormatValidator,
                            final Event<DataTypeEditModeToggleEvent> editModeToggleEvent,
                            final Event<DataTypeChangedEvent> dataTypeChangedEvent); void init(final DataTypeList dataTypeList); DataType getDataType(); boolean isReadOnly(); int getLevel(); boolean isCollapsed(); void expand(); void collapse(); void enableEditMode(); void disableEditMode(); void saveAndCloseEditMode(); void remove(); Command removeItem(); Command destroy(); void destroyWithDependentTypes(); void destroyWithoutDependentTypes(); String getType(); void insertFieldAbove(); String insertFieldAbove(final DataType dataType); void insertFieldBelow(); String insertFieldBelow(final DataType dataType); void insertNestedField(); void insertNestedField(final DataType newDataType); HTMLElement getDragAndDropElement(); void highlightLevel(final DataType dataType);  }