use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class AddContextEntryCommandTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.context = new Context();
this.contextEntry = new ContextEntry() {
{
setVariable(new InformationItem() {
{
setName(new Name("variable"));
}
});
}
};
this.defaultResultContextEntry = new ContextEntry();
this.context.getContextEntry().add(defaultResultContextEntry);
this.uiModel = new BaseGridData();
this.uiModelRow = new DMNGridRow();
this.uiDefaultResultModelRow = new DMNGridRow();
this.uiModel.appendRow(uiDefaultResultModelRow);
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiNameColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
doReturn(uiModel).when(gridWidget).getModel();
doReturn(ruleManager).when(handler).getRuleManager();
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiNameColumn).getIndex();
doReturn(2).when(uiExpressionEditorColumn).getIndex();
this.uiModel.setCellValue(0, 2, new ExpressionCellValue(Optional.of(undefinedExpressionEditor)));
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
doReturn(parent).when(undefinedExpressionEditor).getParentInformation();
doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
this.uiModelMapper = new ContextUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(context), () -> expressionEditorDefinitions, listSelector, 0);
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class AddContextEntryCommandTest method testCanvasCommandExecuteMultipleEntries.
@Test
public void testCanvasCommandExecuteMultipleEntries() {
makeCommand();
// first row
command.newGraphCommand(handler).execute(gce);
final Command<AbstractCanvasHandler, CanvasViolation> firstEntryCanvasCommand = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, firstEntryCanvasCommand.execute(handler));
verify(command).updateRowNumbers();
verify(command).updateParentInformation();
// second row
final ContextEntry secondRowEntry = new ContextEntry() {
{
setVariable(new InformationItem() {
{
setName(new Name("last entry"));
}
});
}
};
final DMNGridRow uiSecondModelRow = new DMNGridRow();
command = spy(new AddContextEntryCommand(context, secondRowEntry, uiModel, uiSecondModelRow, context.getContextEntry().size() - 1, uiModelMapper, canvasOperation));
command.newGraphCommand(handler).execute(gce);
final Command<AbstractCanvasHandler, CanvasViolation> secondEntryCanvasCommand = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, secondEntryCanvasCommand.execute(handler));
verify(command).updateRowNumbers();
verify(command).updateParentInformation();
assertEquals(3, uiModel.getRowCount());
assertEquals(uiModelRow, uiModel.getRows().get(0));
assertEquals(uiSecondModelRow, uiModel.getRows().get(1));
assertEquals(uiDefaultResultModelRow, uiModel.getRows().get(2));
assertEquals(3, uiModel.getColumnCount());
assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
assertEquals(uiNameColumn, uiModel.getColumns().get(1));
assertEquals(uiExpressionEditorColumn, uiModel.getColumns().get(2));
assertEquals(3, uiModel.getRows().get(0).getCells().size());
assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
assertEquals("variable", uiModel.getCell(0, 1).getValue().getValue());
assertTrue(uiModel.getCell(0, 2).getValue() instanceof ExpressionCellValue);
assertEquals(3, uiModel.getRows().get(1).getCells().size());
assertEquals(2, uiModel.getCell(1, 0).getValue().getValue());
assertEquals("last entry", uiModel.getCell(1, 1).getValue().getValue());
assertTrue(uiModel.getCell(1, 2).getValue() instanceof ExpressionCellValue);
// Default row
assertEquals(1, uiModel.getRows().get(2).getCells().size());
assertTrue(uiModel.getCell(2, 2).getValue() instanceof ExpressionCellValue);
verify(canvasOperation, times(2)).execute();
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class DecisionTableGrid method initialiseUiModel.
@Override
public void initialiseUiModel() {
expression.ifPresent(e -> {
e.getRule().forEach(r -> {
int columnIndex = 0;
model.appendRow(new DMNGridRow());
uiModelMapper.fromDMNModel(model.getRowCount() - 1, columnIndex++);
for (int ici = 0; ici < e.getInput().size(); ici++) {
uiModelMapper.fromDMNModel(model.getRowCount() - 1, columnIndex++);
}
for (int oci = 0; oci < e.getOutput().size(); oci++) {
uiModelMapper.fromDMNModel(model.getRowCount() - 1, columnIndex++);
}
uiModelMapper.fromDMNModel(model.getRowCount() - 1, columnIndex);
});
});
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class RelationUIModelMapperTest method setup.
@Before
public void setup() {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiRelationColumn1);
this.uiModel.appendColumn(uiRelationColumn2);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiRelationColumn1).getIndex();
doReturn(2).when(uiRelationColumn2).getIndex();
this.relation = new Relation();
this.relation.getColumn().add(new InformationItem());
this.relation.getColumn().add(new InformationItem());
this.relation.getRow().add(new List() {
{
getExpression().add(new LiteralExpression() {
{
setText("le(1,0)");
}
});
getExpression().add(new LiteralExpression() {
{
setText("le(2,0)");
}
});
}
});
this.relation.getRow().add(new List() {
{
getExpression().add(new LiteralExpression() {
{
setText("le(1,1)");
}
});
getExpression().add(new LiteralExpression() {
{
setText("le(2,1)");
}
});
}
});
this.mapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector);
this.cellValueSupplier = Optional::empty;
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method testSelectFirstCellWithRowAndRowNumberColumnAndAnotherColumn.
@Test
public void testSelectFirstCellWithRowAndRowNumberColumnAndAnotherColumn() {
grid.getModel().appendRow(new DMNGridRow());
appendColumns(RowNumberColumn.class, GridColumn.class);
grid.selectFirstCell();
assertThat(grid.getModel().getSelectedCells()).isNotEmpty();
assertThat(grid.getModel().getSelectedCells()).contains(new GridData.SelectedCell(0, 1));
}
Aggregations