### Question:
ContextGrid extends BaseExpressionGrid<Context, ContextGridData, ContextUIModelMapper> implements HasRowDragRestrictions,
                                                                                                               HasListSelectorControl { void addContextEntry(final int index) { getExpression().get().ifPresent(c -> { final ContextEntry ce = new ContextEntry(); final InformationItem informationItem = new InformationItem(); informationItem.setName(new Name()); ce.setVariable(informationItem); final CommandResult<CanvasViolation> result = sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddContextEntryCommand(c, ce, model, new ExpressionEditorGridRow(), index, uiModelMapper, () -> resize(BaseExpressionGrid.RESIZE_EXISTING))); if (!CommandUtils.isError(result)) { selectCell(index, ContextUIModelMapperHelper.NAME_COLUMN_INDEX, false, false); startEditingCell(index, ContextUIModelMapperHelper.NAME_COLUMN_INDEX); } }); } ContextGrid(final GridCellTuple parent,
                       final Optional<String> nodeUUID,
                       final HasExpression hasExpression,
                       final Optional<HasName> hasName,
                       final DMNGridPanel gridPanel,
                       final DMNGridLayer gridLayer,
                       final ContextGridData gridData,
                       final DefinitionUtils definitionUtils,
                       final SessionManager sessionManager,
                       final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                       final DefaultCanvasCommandFactory canvasCommandFactory,
                       final Event<ExpressionEditorChanged> editorSelectedEvent,
                       final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
                       final Event<DomainObjectSelectionEvent> domainObjectSelectionEvent,
                       final CellEditorControlsView.Presenter cellEditorControls,
                       final ListSelectorView.Presenter listSelector,
                       final TranslationService translationService,
                       final boolean isOnlyVisualChangeAllowed,
                       final int nesting,
                       final Supplier<ExpressionEditorDefinitions> expressionEditorDefinitionsSupplier,
                       final ValueAndDataTypePopoverView.Presenter headerEditor,
                       final ReadOnlyProvider readOnlyProvider); @Override ContextUIModelMapper makeUiModelMapper(); @Override void initialiseUiColumns(); @Override void initialiseUiRows(); @Override void initialiseUiCells(); @Override boolean isRowDragPermitted(final GridWidgetDnDHandlersState state); @Override @SuppressWarnings("unused") List<ListSelectorItem> getItems(final int uiRowIndex,
                                           final int uiColumnIndex); @Override void onItemSelected(final ListSelectorItem item); @Override void doAfterSelectionChange(final int uiRowIndex,
                                       final int uiColumnIndex); @Override void doAfterHeaderSelectionChange(final int uiHeaderRowIndex,
                                             final int uiHeaderColumnIndex);  }### Answer:
@Test public void testAddContextEntry() { setupGrid(0); addContextEntry(0); verify(parent).proposeContainingColumnWidth(eq(grid.getWidth() + grid.getPadding() * 2), eq(BaseExpressionGrid.RESIZE_EXISTING)); verify(gridLayer).batch(redrawCommandCaptor.capture()); verify(gridPanel).refreshScrollPosition(); verify(gridPanel).updatePanelSize(); final GridLayerRedrawManager.PrioritizedCommand redrawCommand = redrawCommandCaptor.getValue(); redrawCommand.execute(); verify(gridLayer).draw(); verify(headerEditor).bind(any(HasValueAndTypeRef.class), eq(0), eq(1)); verify(cellEditorControls).show(eq(headerEditor), anyInt(), anyInt()); }
@Test @SuppressWarnings("unchecked") public void testAddContextEntryAutoEditContextEntryName() { setupGrid(0); final InOrder inOrder = Mockito.inOrder(grid); addContextEntry(0); reset(sessionCommandManager); addContextEntry(1); inOrder.verify(grid).startEditingCell(0, ContextUIModelMapperHelper.NAME_COLUMN_INDEX); inOrder.verify(grid).startEditingCell(1, ContextUIModelMapperHelper.NAME_COLUMN_INDEX); }