### Question:
RelationUIModelMapper extends BaseUIModelMapper<Relation> { @Override public void fromDMNModel(final int rowIndex, final int columnIndex) { dmnModel.get().ifPresent(relation -> { final RelationUIModelMapperHelper.RelationSection section = RelationUIModelMapperHelper.getSection(relation, columnIndex); switch (section) { case ROW_INDEX: uiModel.get().setCell(rowIndex, columnIndex, () -> new RelationGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector, lineHeight)); uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE); break; case INFORMATION_ITEM: final org.kie.workbench.common.dmn.api.definition.model.List row = relation.getRow().get(rowIndex); final int iiIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, columnIndex); final HasExpression hasExpression = row.getExpression().get(iiIndex); final Expression e = hasExpression.getExpression(); final Optional<Expression> expression = Optional.ofNullable(e); expression.ifPresent(ex -> { final LiteralExpression le = (LiteralExpression) ex; uiModel.get().setCell(rowIndex, columnIndex, () -> new RelationGridCell<>(new BaseGridCellValue<>(le.getText().getValue()), listSelector, lineHeight)); }); } }); } RelationUIModelMapper(final Supplier<GridData> uiModel,
                                 final Supplier<Optional<Relation>> dmnModel,
                                 final ListSelectorView.Presenter listSelector,
                                 final double lineHeight); @Override void fromDMNModel(final int rowIndex,
                             final int columnIndex); @Override void toDMNModel(final int rowIndex,
                           final int columnIndex,
                           final Supplier<Optional<GridCellValue<?>>> cell);  }### Answer:
@Test public void testFromDMNModelRowNumber() { mapper.fromDMNModel(0, 0); mapper.fromDMNModel(1, 0); assertEquals(1, uiModel.getCell(0, 0).getValue().getValue()); assertEquals(RowSelectionStrategy.INSTANCE, uiModel.getCell(0, 0).getSelectionStrategy()); assertEquals(2, uiModel.getCell(1, 0).getValue().getValue()); assertEquals(RowSelectionStrategy.INSTANCE, uiModel.getCell(1, 0).getSelectionStrategy()); }
@Test public void testFromDMNModelLiteralExpressions() { mapper.fromDMNModel(0, 1); mapper.fromDMNModel(0, 2); mapper.fromDMNModel(1, 1); mapper.fromDMNModel(1, 2); assertEquals("le(1,0)", uiModel.getCell(0, 1).getValue().getValue()); assertEquals("le(2,0)", uiModel.getCell(0, 2).getValue().getValue()); assertEquals("le(1,1)", uiModel.getCell(1, 1).getValue().getValue()); assertEquals("le(2,1)", uiModel.getCell(1, 2).getValue().getValue()); }
@Test public void testFromDMNModelCellTypes() { IntStream.range(0, 2).forEach(rowIndex -> { mapper.fromDMNModel(rowIndex, 0); mapper.fromDMNModel(rowIndex, 1); mapper.fromDMNModel(rowIndex, 2); }); assertThat(uiModel.getCell(0, 0)).isInstanceOf(RelationGridCell.class); assertThat(uiModel.getCell(0, 1)).isInstanceOf(RelationGridCell.class); assertThat(uiModel.getCell(0, 2)).isInstanceOf(RelationGridCell.class); assertThat(uiModel.getCell(1, 0)).isInstanceOf(RelationGridCell.class); assertThat(uiModel.getCell(1, 1)).isInstanceOf(RelationGridCell.class); assertThat(uiModel.getCell(1, 2)).isInstanceOf(RelationGridCell.class); }