use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem 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.api.definition.v1_1.InformationItem in project kie-wb-common by kiegroup.
the class RelationPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.v1_1.Relation dmnFromWB(final Relation wb) {
org.kie.dmn.model.v1_1.Relation result = new org.kie.dmn.model.v1_1.Relation();
result.setId(wb.getId().getValue());
result.setDescription(wb.getDescription().getValue());
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
for (InformationItem iitem : wb.getColumn()) {
org.kie.dmn.model.v1_1.InformationItem iitemConverted = InformationItemPropertyConverter.dmnFromWB(iitem);
result.getColumn().add(iitemConverted);
}
for (org.kie.workbench.common.dmn.api.definition.v1_1.List list : wb.getRow()) {
org.kie.dmn.model.v1_1.List listConverted = ListPropertyConverter.dmnFromWB(list);
result.getRow().add(listConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem in project kie-wb-common by kiegroup.
the class ContextEditorDefinition method getModelClass.
@Override
public Optional<Context> getModelClass() {
// Add one ContextEntry for the User to start with
final Context context = new Context();
final ContextEntry contextEntry = new ContextEntry();
contextEntry.setVariable(new InformationItem());
context.getContextEntry().add(contextEntry);
// Add (default) "result" entry
final ContextEntry resultEntry = new ContextEntry();
resultEntry.setExpression(new LiteralExpression());
context.getContextEntry().add(resultEntry);
return Optional.of(context);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem in project kie-wb-common by kiegroup.
the class RelationGridTest method testDeleteColumn.
@Test
public void testDeleteColumn() throws Exception {
relation.getColumn().add(new InformationItem());
setupGrid(0);
// Cannot delete column 0 since it is the RowNumber column. The first Relation column is 1.
grid.deleteColumn(RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
verify(sessionCommandManager).execute(eq(canvasHandler), deleteColumnCommand.capture());
deleteColumnCommand.getValue().execute(canvasHandler);
verify(parent).proposeContainingColumnWidth(grid.getWidth() + grid.getPadding() * 2);
verify(parentGridColumn).setWidth(grid.getWidth() + grid.getPadding() * 2);
verify(gridLayer).batch(any(GridLayerRedrawManager.PrioritizedCommand.class));
verify(gridPanel).refreshScrollPosition();
verify(gridPanel).updatePanelSize();
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem in project kie-wb-common by kiegroup.
the class RelationGridTest method testOnItemSelectedDeleteColumn.
@Test
public void testOnItemSelectedDeleteColumn() {
relation.getColumn().add(new InformationItem());
setupGrid(0);
// Cannot delete column 0 since it is the RowNumber column. The first Relation column is 1.
final java.util.List<HasListSelectorControl.ListSelectorItem> items = grid.getItems(0, RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
final HasListSelectorControl.ListSelectorTextItem ti = (HasListSelectorControl.ListSelectorTextItem) items.get(DELETE_COLUMN);
grid.onItemSelected(ti);
verify(cellEditorControls).hide();
verify(grid).deleteColumn(eq(1));
}
Aggregations