### Question:
DataTypeListItem { public void enableEditMode() { if (view.isOnFocusMode()) { return; } oldName = getDataType().getName(); oldType = getDataType().getType(); oldConstraint = getDataType().getConstraint(); oldIsList = getDataType().isList(); oldConstraintType = getDataType().getConstraintType(); view.showSaveButton(); view.showDataTypeNameInput(); view.showListContainer(); view.hideListYesLabel(); view.enableFocusMode(); dataTypeSelectComponent.enableEditMode(); dataTypeConstraintComponent.enableEditMode(); editModeToggleEvent.fire(new DataTypeEditModeToggleEvent(true, this)); dataTypeList.fireOnDataTypeListItemUpdateCallback(this); } @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);  }### Answer:
@Test public void testEnableEditMode() { final DataType dataType = mock(DataType.class); final String expectedName = "name"; final String expectedType = "type"; final String expectedConstraint = "constraint"; final boolean expectedIsList = true; final String expectedConstraintType = ""; doReturn(dataType).when(listItem).getDataType(); when(dataType.getName()).thenReturn(expectedName); when(dataType.getType()).thenReturn(expectedType); when(dataType.getConstraint()).thenReturn(expectedConstraint); when(dataType.isList()).thenReturn(expectedIsList); when(view.isOnFocusMode()).thenReturn(false); listItem.enableEditMode(); assertEquals(expectedName, listItem.getOldName()); assertEquals(expectedType, listItem.getOldType()); assertEquals(expectedConstraint, listItem.getOldConstraint()); assertEquals(expectedIsList, listItem.getOldIsList()); assertEquals(expectedConstraintType, listItem.getOldConstraintType()); verify(view).showSaveButton(); verify(view).showDataTypeNameInput(); verify(view).enableFocusMode(); verify(view).hideListYesLabel(); verify(view).showListContainer(); verify(dataTypeSelectComponent).enableEditMode(); verify(dataTypeConstraintComponent).enableEditMode(); verify(editModeToggleEvent).fire(eventArgumentCaptor.capture()); verify(dataTypeList).fireOnDataTypeListItemUpdateCallback(listItem); assertTrue(eventArgumentCaptor.getValue().isEditModeEnabled()); }
@Test public void testEnableEditModeWhenDataTypeListItemIsAlreadyOnEditMode() { when(view.isOnFocusMode()).thenReturn(true); listItem.enableEditMode(); verify(view, never()).showSaveButton(); verify(view, never()).showDataTypeNameInput(); verify(view, never()).enableFocusMode(); verify(view, never()).hideListYesLabel(); verify(view, never()).showListContainer(); verify(dataTypeSelectComponent, never()).enableEditMode(); verify(dataTypeConstraintComponent, never()).enableEditMode(); verify(editModeToggleEvent, never()).fire(any()); verify(dataTypeList, never()).fireOnDataTypeListItemUpdateCallback(any(DataTypeListItem.class)); }